1#ifndef FUSED_ALGORITHMS_QR_H
2#define FUSED_ALGORITHMS_QR_H
68 template <
typename T, my_
size_t M, my_
size_t N>
98 T dot = result(jj, k);
102 dot +=
QR(i, jj) * result(i, k);
106 result(jj, k) -= tj * dot;
110 result(i, k) -= tj *
QR(i, jj) * dot;
131 result(i, j) =
QR(i, j);
163 dot +=
QR(i, j) * result(i);
167 result(j) -= tj * dot;
171 result(i) -= tj *
QR(i, j) * dot;
206 template <
typename T, my_
size_t M, my_
size_t N>
209 static_assert(is_floating_point_v<T>,
210 "qr_householder requires a floating-point scalar type");
211 static_assert(M >= N,
"qr_householder requires M >= N");
224 norm_sq += result.
QR(i, j) * result.
QR(i, j);
231 result.
tau(j) = T(0);
236 T alpha = (result.
QR(j, j) >= T(0)) ? -norm : norm;
240 T v0 = result.
QR(j, j) - alpha;
248 vtv += result.
QR(i, j) * result.
QR(i, j);
251 T tj = T(2) * v0 * v0 / vtv;
257 result.
QR(i, j) /= v0;
265 T dot = result.
QR(j, k);
269 dot += result.
QR(i, j) * result.
QR(i, k);
272 result.
QR(j, k) -= tj * dot;
276 result.
QR(i, k) -= tj * result.
QR(i, j) * dot;
281 result.
QR(j, j) = alpha;
Definition fused_matrix.h:12
FusedMatrix & setIdentity(void)
Definition fused_matrix.h:234
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
#define PRECISION_TOLERANCE
Tolerance for floating-point comparisons (e.g. symmetry checks, Cholesky).
Definition config.h:117
constexpr T sqrt(T x) noexcept
Compute the square root of a floating-point value.
Definition math_utils.h:29
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
Result of Householder QR decomposition.
Definition qr.h:70
FusedVector< T, N > tau
Householder scaling factors.
Definition qr.h:72
FusedMatrix< T, M, M > Q() const
Extract the full orthogonal factor Q (M×M).
Definition qr.h:81
FusedVector< T, M > apply_Qt(const FusedVector< T, M > &b) const
Apply Qᵀ to a vector b without forming Q explicitly.
Definition qr.h:147
FusedMatrix< T, M, N > QR
Compact Householder + R storage.
Definition qr.h:71
FusedMatrix< T, M, N > R() const
Extract the upper-triangular factor R (M×N).
Definition qr.h:123