54 using cplx = std::complex<double>;
56 auto factor = [&](
double tau) {
57 double alpha = tau / (4.0 *
h *
h);
59 cplx b(1.0, 2.0 * alpha);
64 td_half_ = factor(
dt * 0.5);
65 td_full_ = factor(
dt);
72 using cplx = std::complex<double>;
74 const cplx ia(0.0, tau / (4.0 *
h *
h));
75 const cplx diag(1.0, -2.0 * tau / (4.0 *
h *
h));
77 auto apply = [&](std::vector<cplx>& fiber) {
78 std::vector<cplx> rhs(
N);
79 for (
int i = 0; i <
N; ++i) {
80 cplx prev = (i > 0) ? fiber[i - 1] :
cplx{};
81 cplx next = (i <
N - 1) ? fiber[i + 1] :
cplx{};
82 rhs[i] = ia * prev + diag * fiber[i] + ia * next;
85 fiber = std::move(rhs);
Dense vector with optional GPU storage, templated over scalar type T.
void row_fiber_sweep(BasicVector< T > &data, int N, F &&f)
std::complex< real > cplx
void col_fiber_sweep(BasicVector< T > &data, int N, F &&f)
Higher-order stencil and grid-sweep utilities.
Constant-coefficient complex tridiagonal solver (precomputed LU).
void solve(std::vector< cplx > &d) const
In-place Thomas solve.
void factor(int n_, cplx a_, cplx b_, cplx c_)
Factor the tridiagonal matrix.
CrankNicolsonADI(int N_, double dt_, double h_)
CrankNicolsonADI()=default
void sweep(CVector &psi, bool x_axis, double tau) const
Precomputed LU Thomas solver for constant-coefficient complex tridiagonal systems.