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

Forward/back substitution for triangular systems. More...

#include "config.h"
#include "utilities/expected.h"
#include "matrix_traits.h"
#include "simple_type_traits.h"
#include "math/math_utils.h"
Include dependency graph for triangular_solve.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  matrix_algorithms
 

Functions

template<bool UnitDiag = false, typename T , my_size_t N>
Expected< FusedVector< T, N >, MatrixStatus > matrix_algorithms::forward_substitute (const FusedMatrix< T, N, N > &L, const FusedVector< T, N > &b)
 Solve the lower-triangular system Lx = b by forward substitution.
 
template<bool UnitDiag = false, typename T , my_size_t N>
Expected< FusedVector< T, N >, MatrixStatus > matrix_algorithms::back_substitute (const FusedMatrix< T, N, N > &U, const FusedVector< T, N > &b)
 Solve the upper-triangular system Ux = b by back substitution.
 
template<bool UnitDiag = false, typename T , my_size_t N, my_size_t Ncols>
Expected< FusedMatrix< T, N, Ncols >, MatrixStatus > matrix_algorithms::forward_substitute (const FusedMatrix< T, N, N > &L, const FusedMatrix< T, N, Ncols > &B)
 Solve the lower-triangular system LX = B for multiple right-hand sides.
 
template<bool UnitDiag = false, typename T , my_size_t N, my_size_t Ncols>
Expected< FusedMatrix< T, N, Ncols >, MatrixStatus > matrix_algorithms::back_substitute (const FusedMatrix< T, N, N > &U, const FusedMatrix< T, N, Ncols > &B)
 Solve the upper-triangular system UX = B for multiple right-hand sides.
 

Detailed Description

Forward/back substitution for triangular systems.

Provides solvers for triangular linear systems Lx = b and Ux = b, with compile-time dispatch for fixed-size unrolled paths (N ∈ {3, 4, 6}) and a UnitDiag template parameter for LU-style implicit unit diagonals.

Also includes multi-RHS overloads (LX = B, UX = B) for matrix right-hand sides, used by matrix inverse and related algorithms.


ALGORITHMS

Forward substitution (Lx = b, L lower-triangular):

For i = 0 … N−1:
x(i) = ( b(i) − Σ_{k=0}^{i-1} L(i,k)·x(k) ) / L(i,i)
(division skipped when UnitDiag = true)

Back substitution (Ux = b, U upper-triangular):

For i = N−1 … 0:
x(i) = ( b(i) − Σ_{k=i+1}^{N-1} U(i,k)·x(k) ) / U(i,i)
(division skipped when UnitDiag = true)

Complexity: O(N²/2) per substitution.


FAILURE MODES