1#ifndef FUSED_ALGORITHMS_TOEPLITZ_H
2#define FUSED_ALGORITHMS_TOEPLITZ_H
90 template <
typename T, my_
size_t N>
95 static_assert(is_floating_point_v<T>,
96 "levinson_durbin requires a floating-point scalar type");
105 if constexpr (N == 1)
126 err = r(0) * (T(1) - f(0) * f(0));
130 return Unexpected{MatrixStatus::NotConverged};
137 T delta = b(1) - r(1) * x0_prev;
138 x(0) = x0_prev + (delta / err) * f(0);
152 T lambda_num = r(m + 1);
155 lambda_num += f_prev(k) * r(m - k);
157 T lambda = -lambda_num / err;
162 f(k) = f_prev(k) + lambda * f_prev(m - 1 - k);
167 err *= (T(1) - lambda * lambda);
171 return Unexpected{MatrixStatus::NotConverged};
184 delta -= r(m + 1 - k) * x_prev(k);
187 T correction = delta / err;
192 x(k) = x_prev(k) + correction * f(m - k);
194 x(m + 1) = correction;
A discriminated union holding either a success value or an error.
Definition expected.h:86
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
A minimal, STL-free expected/result type for failable operations.
Runtime property descriptors and error codes for matrices.
constexpr T abs(T x) noexcept
Compute the absolute value of a numeric value.
Definition math_utils.h:48
Expected< FusedVector< T, N >, MatrixStatus > levinson_durbin(const FusedVector< T, N > &r, const FusedVector< T, N > &b)
Solve a symmetric Toeplitz system Tx = b using Levinson-Durbin.
Definition toeplitz.h:91
MatrixStatus
Error codes for matrix decomposition and solver algorithms.
Definition matrix_traits.h:33
constexpr remove_reference_t< T > && move(T &&t) noexcept
Cast to rvalue reference (replacement for std::move).
Definition simple_type_traits.h:178
Tag type for constructing an Expected in the error state.
Definition expected.h:30