pub struct ComplexMatrix {
pub data: Vec<Complex>,
pub rows: usize,
pub cols: usize,
}Expand description
Complex matrix with row-major storage.
Fields§
§data: Vec<Complex>§rows: usize§cols: usizeImplementations§
Source§impl ComplexMatrix
impl ComplexMatrix
Sourcepub fn from_data(data: Vec<Complex>, rows: usize, cols: usize) -> Self
pub fn from_data(data: Vec<Complex>, rows: usize, cols: usize) -> Self
Create matrix from data.
Sourcepub fn add(&self, other: &ComplexMatrix) -> ComplexMatrix
pub fn add(&self, other: &ComplexMatrix) -> ComplexMatrix
Matrix addition.
Sourcepub fn sub(&self, other: &ComplexMatrix) -> ComplexMatrix
pub fn sub(&self, other: &ComplexMatrix) -> ComplexMatrix
Matrix subtraction.
Sourcepub fn scale(&self, scalar: Complex) -> ComplexMatrix
pub fn scale(&self, scalar: Complex) -> ComplexMatrix
Scalar multiplication.
Sourcepub fn mul(&self, other: &ComplexMatrix) -> ComplexMatrix
pub fn mul(&self, other: &ComplexMatrix) -> ComplexMatrix
Matrix multiplication.
Sourcepub fn transpose(&self) -> ComplexMatrix
pub fn transpose(&self) -> ComplexMatrix
Matrix transpose.
Sourcepub fn hermitian(&self) -> ComplexMatrix
pub fn hermitian(&self) -> ComplexMatrix
Conjugate transpose (Hermitian transpose).
Sourcepub fn determinant(&self) -> Complex
pub fn determinant(&self) -> Complex
Matrix determinant (for small matrices).
Sourcepub fn lu_decomposition(
&self,
) -> Option<(ComplexMatrix, ComplexMatrix, Vec<usize>)>
pub fn lu_decomposition( &self, ) -> Option<(ComplexMatrix, ComplexMatrix, Vec<usize>)>
LU decomposition with partial pivoting.
Sourcepub fn solve(&self, b: &[Complex]) -> Option<Vec<Complex>>
pub fn solve(&self, b: &[Complex]) -> Option<Vec<Complex>>
Solve linear system Ax = b using LU decomposition.
Sourcepub fn inverse(&self) -> Option<ComplexMatrix>
pub fn inverse(&self) -> Option<ComplexMatrix>
Matrix inverse.
Sourcepub fn is_hermitian(&self, tolerance: f64) -> bool
pub fn is_hermitian(&self, tolerance: f64) -> bool
Check if matrix is Hermitian (equal to its conjugate transpose).
Sourcepub fn is_unitary(&self, tolerance: f64) -> bool
pub fn is_unitary(&self, tolerance: f64) -> bool
Check if matrix is unitary (A * A^H = I).
Sourcepub fn frobenius_norm(&self) -> f64
pub fn frobenius_norm(&self) -> f64
Frobenius norm.
Sourcepub fn power(&self, n: usize) -> ComplexMatrix
pub fn power(&self, n: usize) -> ComplexMatrix
Matrix power A^n.
Sourcepub fn exp(&self, iterations: usize) -> ComplexMatrix
pub fn exp(&self, iterations: usize) -> ComplexMatrix
Matrix exponential e^A using Taylor series with scaling-and-squaring: compute e^(A/2^k) then square k times.
Sourcepub fn ln(&self, iterations: usize) -> Option<ComplexMatrix>
pub fn ln(&self, iterations: usize) -> Option<ComplexMatrix>
Matrix logarithm ln(A) using Taylor series around identity.
Returns None if the series cannot converge, i.e. if any eigenvalue
of A is outside the disk |λ - 1| < 1 (checked via a Frobenius-norm
bound on A - I, which is conservative but safe).
Trait Implementations§
Source§impl Clone for ComplexMatrix
impl Clone for ComplexMatrix
Source§fn clone(&self) -> ComplexMatrix
fn clone(&self) -> ComplexMatrix
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more