tesseract++ 0.0.1
N-dimensional tensor library for embedded systems
Loading...
Searching...
No Matches
Namespaces | Functions
least_squares.h File Reference

Least squares solve: min ‖Ax - b‖² via QR decomposition. More...

#include "config.h"
#include "utilities/expected.h"
#include "matrix_traits.h"
#include "fused/fused_matrix.h"
#include "fused/fused_vector.h"
#include "algorithms/decomposition/qr.h"
#include "algorithms/solvers/triangular_solve.h"
Include dependency graph for least_squares.h:

Go to the source code of this file.

Namespaces

namespace  matrix_algorithms
 

Functions

template<typename T , my_size_t M, my_size_t N>
Expected< FusedVector< T, N >, MatrixStatus > matrix_algorithms::least_squares (const FusedMatrix< T, M, N > &A, const FusedVector< T, M > &b)
 Solve the least squares problem min ‖Ax - b‖² via QR.
 

Detailed Description

Least squares solve: min ‖Ax - b‖² via QR decomposition.

For an overdetermined system A (M×N, M≥N) and vector b (M), finds x (N) that minimizes the 2-norm of the residual.


ALGORITHM

  1. Decompose A = Q·R via qr_householder(A)
  2. Compute c = Qᵀ·b via apply_Qt (no explicit Q formation)
  3. Solve R₁·x = c₁ via back substitution where R₁ = R(0:N-1, 0:N-1) and c₁ = c(0:N-1)

The residual norm is ‖c₂‖ where c₂ = c(N:M-1).

Complexity: O(2MN² - 2N³/3) for QR + O(N²) for back substitution.


FAILURE MODES