24 using cplx = std::complex<double>;
25 auto factor = [&](
double tau) {
26 double alpha = tau / (4.0 *
h *
h);
28 cplx b(1.0, 2.0 * alpha);
33 td_half_ = factor(
dt * 0.5);
34 td_full_ = factor(
dt);
38 using cplx = std::complex<double>;
40 const cplx ia(0.0, tau / (4.0 *
h *
h));
41 const cplx diag(1.0, -2.0 * tau / (4.0 *
h *
h));
43 auto apply = [&](std::vector<cplx>& fiber) {
44 std::vector<cplx> rhs(
N);
45 for (
int i = 0; i <
N; ++i) {
46 cplx prev = (i > 0) ? fiber[i - 1] :
cplx{};
47 cplx next = (i <
N - 1) ? fiber[i + 1] :
cplx{};
48 rhs[i] = ia * prev + diag * fiber[i] + ia * next;
51 fiber = std::move(rhs);
void row_fiber_sweep(BasicVector< T > &data, int N, F &&f)
Apply a mutable 1D operation to each row fiber.
std::complex< real > cplx
void col_fiber_sweep(BasicVector< T > &data, int N, F &&f)
Apply a mutable 1D operation to each column fiber.
Higher-order stencil and grid-sweep utilities.
void solve(std::vector< cplx > &d) const
void factor(int n_, cplx a_, cplx b_, cplx c_)
CrankNicolsonADI(int N_, double dt_, double h_)
CrankNicolsonADI()=default
void sweep(CVector &psi, bool x_axis, double tau) const
Precomputed Thomas solver for constant-coefficient complex systems.
Dense vector storage and operations.