Skip to main content

Crate tpt_math_linalg_complex

Crate tpt_math_linalg_complex 

Source
Expand description

Complex-valued linear algebra implemented entirely in-house (no external backend), for EM / quantum and other complex-domain work.

This crate builds on the storage pattern of tpt_math_linalg_dense and extends it to a Complex scalar, providing:

Like tpt_math_linalg_dense, the storage is hand-rolled (a plain Vec<Complex<T>>), so there is no faer/nalgebra dependency and no license exposure.

§Features

  • std (default) — enable the allocator and the std support of deps.
  • alloc — signal allocator availability (dynamic vectors need it).

§Examples

use tpt_math_linalg_complex::{Complex, ComplexDMatrix};

let a = ComplexDMatrix::from_real_row_slice(
    2, 2,
    &[1.0_f64, 2.0, 3.0, 4.0],
);
let inv = a.inverse().unwrap();
let prod = a.clone() * inv;
assert!((prod[(0, 0)].re - 1.0).abs() < 1e-12);
assert!((prod[(1, 1)].re - 1.0).abs() < 1e-12);

let z = Complex::new(0.0, 1.0);
assert_eq!(z * z, Complex::new(-1.0, 0.0));

Structs§

Cholesky
A Cholesky factorisation A = L Lᴴ of a Hermitian positive-definite complex matrix.
Complex
A complex number z = re + i·im with real and imaginary parts of type T.
ComplexDMatrix
A dynamically-sized complex matrix, stored column-major in a contiguous Vec ((i, j) lives at i + j * nrows).
ComplexDVector
A dynamically-sized complex column vector, stored as a contiguous Vec.

Enums§

ComplexDenseError
Errors returned by the complex dense linear-algebra routines.