1#ifndef FUSED_ALGORITHMS_LEAST_SQUARES_H
2#define FUSED_ALGORITHMS_LEAST_SQUARES_H
69 template <
typename T, my_
size_t M, my_
size_t N>
74 static_assert(is_floating_point_v<T>,
75 "least_squares requires a floating-point scalar type");
76 static_assert(M >= N,
"least_squares requires M >= N (overdetermined system)");
82 auto c = qr.apply_Qt(b);
91 R1(i, j) = qr.QR(i, j);
A discriminated union holding either a success value or an error.
Definition expected.h:86
Definition fused_matrix.h:12
Definition fused_vector.h:9
Global configuration for the tesseract tensor library.
#define my_size_t
Size/index type used throughout the library.
Definition config.h:126
A minimal, STL-free expected/result type for failable operations.
Runtime property descriptors and error codes for matrices.
Expected< FusedVector< T, N >, MatrixStatus > back_substitute(const FusedMatrix< T, N, N > &U, const FusedVector< T, N > &b)
Solve the upper-triangular system Ux = b by back substitution.
Definition triangular_solve.h:216
QRResult< T, M, N > qr_householder(const FusedMatrix< T, M, N > &A)
Compute the Householder QR decomposition of a rectangular matrix.
Definition qr.h:207
Expected< FusedVector< T, N >, MatrixStatus > least_squares(const FusedMatrix< T, M, N > &A, const FusedVector< T, M > &b)
Solve the least squares problem min ‖Ax - b‖² via QR.
Definition least_squares.h:70
MatrixStatus
Error codes for matrix decomposition and solver algorithms.
Definition matrix_traits.h:33
Householder QR decomposition for rectangular matrices.
Forward/back substitution for triangular systems.