Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
aigenlib.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2026 OpenUAS
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
24#pragma once
25
26#include <array>
27#include <cstddef>
28#include <vector>
29
30namespace dipla::aigenlib {
31
33inline constexpr std::size_t max_extent = 2601;
35inline constexpr double pseudoinverse_relative_cutoff = 1e-15;
37using Vector = std::vector<double>;
38
43struct Point {
44 std::array<double, 3> coordinates{};
46 Point(double east = 0.0, double north = 0.0, double altitude = 0.0);
48 double& x() noexcept;
50 double x() const noexcept;
52 double& y() noexcept;
54 double y() const noexcept;
56 double& z() noexcept;
58 double z() const noexcept;
60 double& operator[](std::size_t index);
62 double operator[](std::size_t index) const;
64 double norm() const noexcept;
66 bool finite() const noexcept;
68 Point& operator+=(const Point& other) noexcept;
70 Point& operator-=(const Point& other) noexcept;
71};
72
74Point operator+(Point left, const Point& right) noexcept;
76Point operator-(Point left, const Point& right) noexcept;
78Point operator*(Point point, double scale) noexcept;
80Point operator*(double scale, Point point) noexcept;
82Point operator/(Point point, double divisor);
84bool operator==(const Point& left, const Point& right) noexcept;
86bool operator!=(const Point& left, const Point& right) noexcept;
87
95class Matrix {
96public:
98 Matrix() = default;
100 Matrix(std::size_t rows, std::size_t columns, double value = 0.0);
102 Matrix(const Matrix& other) = default;
104 Matrix& operator=(const Matrix& other);
106 Matrix(Matrix&& other) noexcept;
108 Matrix& operator=(Matrix&& other) noexcept;
110 std::size_t rows() const noexcept;
112 std::size_t cols() const noexcept;
114 std::size_t size() const noexcept;
116 double& operator()(std::size_t row, std::size_t column);
118 double operator()(std::size_t row, std::size_t column) const;
120 double* row_data(std::size_t row);
122 const double* row_data(std::size_t row) const;
124 bool finite() const noexcept;
126 double trace() const;
127
128private:
129 std::size_t rows_ = 0;
130 std::size_t columns_ = 0;
132};
133
139
153Matrix solve_symmetric(const Matrix& system, const Matrix& right, SolveMethod* method = nullptr);
154
161struct Sensor {
162 std::vector<std::vector<int>> rows;
164};
165
176Matrix matern32(const std::vector<Point>& positions, double sigma2, double lengthscale);
187Matrix project(const Sensor& sensor, const Matrix& covariance);
195Matrix innovation(const Sensor& sensor, const Matrix& projected);
197Vector observe(const Sensor& sensor, const Vector& field);
208double expected_reduction(const Matrix& covariance, const std::vector<bool>& mask, const Sensor& sensor);
226void condition(Matrix& covariance, Vector* mean, const Sensor& sensor, const Vector* measurement);
227
228}
Owning, contiguous, row-major double matrix.
Definition aigenlib.hpp:95
Matrix(const Matrix &other)=default
Deep copy.
std::size_t rows_
Row extent.
Definition aigenlib.hpp:129
std::size_t cols() const noexcept
Column count.
Definition aigenlib.cpp:241
Matrix & operator=(const Matrix &other)
Deep assignment with strong exception guarantee.
Definition aigenlib.cpp:223
Vector values_
Contiguous owning storage.
Definition aigenlib.hpp:131
std::size_t columns_
Column extent.
Definition aigenlib.hpp:130
std::size_t size() const noexcept
Allocated scalar count.
Definition aigenlib.cpp:242
double * row_data(std::size_t row)
Borrow a row.
Definition aigenlib.cpp:251
double trace() const
Sum a square matrix's diagonal.
Definition aigenlib.cpp:262
Matrix()=default
Construct an empty matrix.
bool finite() const noexcept
Validate all stored scalars.
Definition aigenlib.cpp:259
std::size_t rows() const noexcept
Row count.
Definition aigenlib.cpp:240
Definition aigenlib.cpp:42
Vector observe(const Sensor &sensor, const Vector &field)
Average field values through a sensor.
Definition aigenlib.cpp:376
Matrix matern32(const std::vector< Point > &positions, double sigma2, double lengthscale)
Construct a symmetric Matern-3/2 covariance over supplied positions.
Definition aigenlib.cpp:324
double expected_reduction(const Matrix &covariance, const std::vector< bool > &mask, const Sensor &sensor)
Sum the masked posterior diagonal reduction without modifying belief.
Definition aigenlib.cpp:388
Matrix project(const Sensor &sensor, const Matrix &covariance)
Project covariance through sparse averaging rows: B = H P.
Definition aigenlib.cpp:342
std::vector< double > Vector
Owning scalar vector; size validation belongs to the consuming operation.
Definition aigenlib.hpp:37
Matrix solve_symmetric(const Matrix &system, const Matrix &right, SolveMethod *method)
Solve a finite symmetric system with multiple right-hand sides.
Definition aigenlib.cpp:269
constexpr double pseudoinverse_relative_cutoff
Relative spectral cutoff shared with the Eigen reference implementation.
Definition aigenlib.hpp:35
SolveMethod
Factorization selected for a solve.
Definition aigenlib.hpp:135
@ cholesky
Positive-definite triangular factorization.
Definition aigenlib.hpp:136
@ pseudoinverse
Signed spectral inverse with null-mode truncation.
Definition aigenlib.hpp:137
void condition(Matrix &covariance, Vector *mean, const Sensor &sensor, const Vector *measurement)
Condition a GP in place with optional measurement assimilation.
Definition aigenlib.cpp:409
constexpr std::size_t max_extent
Maximum matrix extent, matching the current dense GP grid ceiling.
Definition aigenlib.hpp:33
Matrix innovation(const Sensor &sensor, const Matrix &projected)
Construct innovation covariance S = H P H^T + R from B = H P.
Definition aigenlib.cpp:359
Three-dimensional value type for route arithmetic.
Definition aigenlib.hpp:43
double & y() noexcept
Access north.
Definition aigenlib.cpp:190
std::array< double, 3 > coordinates
East, north, altitude.
Definition aigenlib.hpp:44
bool finite() const noexcept
Check every coordinate.
Definition aigenlib.cpp:197
Point(double east=0.0, double north=0.0, double altitude=0.0)
Construct a point.
Definition aigenlib.cpp:187
double & x() noexcept
Access east.
Definition aigenlib.cpp:188
double & z() noexcept
Access altitude.
Definition aigenlib.cpp:192
double norm() const noexcept
Euclidean length.
Definition aigenlib.cpp:196
Sparse uniform-averaging measurement operator.
Definition aigenlib.hpp:161
Vector variances
Finite nonnegative independent noise variances.
Definition aigenlib.hpp:163
std::vector< std::vector< int > > rows
Cell indices in each measurement.
Definition aigenlib.hpp:162