numerics
Loading...
Searching...
No Matches
num::ComplexTriDiag Struct Reference

Constant-coefficient complex tridiagonal solver (precomputed LU). More...

#include <tridiag_complex.hpp>

Public Types

using cplx = std::complex< double >
 

Public Member Functions

void factor (int n_, cplx a_, cplx b_, cplx c_)
 Factor the tridiagonal matrix.
 
void solve (std::vector< cplx > &d) const
 In-place Thomas solve.
 

Public Attributes

std::vector< cplxc_mod
 Modified super-diagonal (precomputed from LU)
 
std::vector< cplxinv_b
 Inverse of modified main diagonal (precomputed)
 
int n = 0
 
cplx a_coeff
 Sub-diagonal value (constant across all rows)
 

Detailed Description

Constant-coefficient complex tridiagonal solver (precomputed LU).

std::complex<double> a(0.0, -alpha);
std::complex<double> b(1.0, 2.0*alpha);
std::complex<double> c(0.0, -alpha);
td.factor(n, a, b, c);
std::vector<std::complex<double>> rhs = ...;
td.solve(rhs); // rhs is overwritten with the solution
constexpr T ipow(T x) noexcept
Compute x^N at compile time via repeated squaring.
Constant-coefficient complex tridiagonal solver (precomputed LU).

Definition at line 36 of file tridiag_complex.hpp.

Member Typedef Documentation

◆ cplx

Definition at line 37 of file tridiag_complex.hpp.

Member Function Documentation

◆ factor()

void num::ComplexTriDiag::factor ( int  n_,
cplx  a_,
cplx  b_,
cplx  c_ 
)

Factor the tridiagonal matrix.

Parameters
n_System size
a_Sub-diagonal coefficient (row k depends on x[k-1])
b_Main-diagonal coefficient
c_Super-diagonal coefficient (row k depends on x[k+1])

Definition at line 5 of file tridiag_complex.cpp.

References a_coeff, c_mod, inv_b, num::ipow(), and n.

Referenced by num::CrankNicolsonADI::CrankNicolsonADI().

◆ solve()

void num::ComplexTriDiag::solve ( std::vector< cplx > &  d) const

In-place Thomas solve.

On entry d holds the right-hand side; on exit it holds the solution. The size of d must equal n (set by the last factor() call).

Definition at line 23 of file tridiag_complex.cpp.

References a_coeff, c_mod, inv_b, num::ipow(), and n.

Member Data Documentation

◆ a_coeff

cplx num::ComplexTriDiag::a_coeff

Sub-diagonal value (constant across all rows)

Definition at line 42 of file tridiag_complex.hpp.

Referenced by factor(), and solve().

◆ c_mod

std::vector<cplx> num::ComplexTriDiag::c_mod

Modified super-diagonal (precomputed from LU)

Definition at line 39 of file tridiag_complex.hpp.

Referenced by factor(), and solve().

◆ inv_b

std::vector<cplx> num::ComplexTriDiag::inv_b

Inverse of modified main diagonal (precomputed)

Definition at line 40 of file tridiag_complex.hpp.

Referenced by factor(), and solve().

◆ n

int num::ComplexTriDiag::n = 0

Definition at line 41 of file tridiag_complex.hpp.

Referenced by factor(), and solve().


The documentation for this struct was generated from the following files: