tesseract++ 0.0.1
N-dimensional tensor library for embedded systems
Loading...
Searching...
No Matches
cholesky_update.h
Go to the documentation of this file.
1#ifndef FUSED_ALGORITHMS_CHOLESKY_UPDATE_H
2#define FUSED_ALGORITHMS_CHOLESKY_UPDATE_H
3
4#include "config.h"
7#include "math/math_utils.h" // math::sqrt
8
43namespace matrix_algorithms
44{
45
58 template <typename T, my_size_t N>
60 const FusedMatrix<T, N, N> &L,
61 const FusedVector<T, N> &v)
62 {
63 static_assert(is_floating_point_v<T>,
64 "cholesky_rank1_update requires a floating-point scalar type");
65
66 FusedMatrix<T, N, N> Lp = L; // work on a copy
67 FusedVector<T, N> p = v; // work vector
68
69 for (my_size_t k = 0; k < N; ++k)
70 {
71 T r = math::sqrt(Lp(k, k) * Lp(k, k) + p(k) * p(k));
72 T c = Lp(k, k) / r;
73 T s = p(k) / r;
74
75 Lp(k, k) = r;
76
77 for (my_size_t i = k + 1; i < N; ++i)
78 {
79 T tmp = Lp(i, k);
80 Lp(i, k) = c * tmp + s * p(i);
81 p(i) = c * p(i) - s * tmp;
82 }
83 }
84
85 return Lp;
86 }
87
88} // namespace matrix_algorithms
89
90#endif // FUSED_ALGORITHMS_CHOLESKY_UPDATE_H
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
constexpr T sqrt(T x) noexcept
Compute the square root of a floating-point value.
Definition math_utils.h:29
Definition cholesky.h:52
FusedMatrix< T, N, N > cholesky_rank1_update(const FusedMatrix< T, N, N > &L, const FusedVector< T, N > &v)
Rank-1 Cholesky update: compute L' where L'L'ᵀ = LLᵀ + vvᵀ.
Definition cholesky_update.h:59