ComplexField

Trait ComplexField 

Source
pub trait ComplexField:
    NumAssign
    + Clone
    + Copy
    + Send
    + Sync
    + Debug
    + Zero
    + One
    + Neg<Output = Self>
    + Lapack
    + 'static {
    // Required methods
    fn norm_sqr(&self) -> Self::Real;
    fn from_re_im(re: Self::Real, im: Self::Real) -> Self;
    fn re(&self) -> Self::Real;
    fn im(&self) -> Self::Real;
    fn inv(&self) -> Self;
    fn sqrt(&self) -> Self;

    // Provided methods
    fn norm(&self) -> Self::Real { ... }
    fn is_zero_approx(&self, tol: Self::Real) -> bool { ... }
}
Expand description

Trait for scalar types that can be used in linear algebra operations.

This trait abstracts over real and complex number types, providing a unified interface for operations like conjugation, norm computation, and conversion from real values.

§Implementations

Provided for:

  • Complex64 (default for most acoustic applications)
  • Complex32 (for memory-constrained applications)
  • f64 (for real-valued problems)
  • f32 (for real-valued, memory-constrained applications)

Required Methods§

Source

fn norm_sqr(&self) -> Self::Real

Squared magnitude |z|²

Source

fn from_re_im(re: Self::Real, im: Self::Real) -> Self

Create from real and imaginary parts

Source

fn re(&self) -> Self::Real

Real part

Source

fn im(&self) -> Self::Real

Imaginary part

Source

fn inv(&self) -> Self

Multiplicative inverse (1/z)

Source

fn sqrt(&self) -> Self

Square root

Provided Methods§

Source

fn norm(&self) -> Self::Real

Magnitude |z|

Source

fn is_zero_approx(&self, tol: Self::Real) -> bool

Check if this is approximately zero

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ComplexField for f32

Source§

fn norm_sqr(&self) -> f32

Source§

fn from_re_im(re: f32, _im: f32) -> Self

Source§

fn re(&self) -> f32

Source§

fn im(&self) -> f32

Source§

fn inv(&self) -> Self

Source§

fn sqrt(&self) -> Self

Source§

impl ComplexField for f64

Source§

fn norm_sqr(&self) -> f64

Source§

fn from_re_im(re: f64, _im: f64) -> Self

Source§

fn re(&self) -> f64

Source§

fn im(&self) -> f64

Source§

fn inv(&self) -> Self

Source§

fn sqrt(&self) -> Self

Source§

impl ComplexField for Complex32

Source§

fn norm_sqr(&self) -> f32

Source§

fn from_re_im(re: f32, im: f32) -> Self

Source§

fn re(&self) -> f32

Source§

fn im(&self) -> f32

Source§

fn inv(&self) -> Self

Source§

fn sqrt(&self) -> Self

Source§

impl ComplexField for Complex64

Source§

fn norm_sqr(&self) -> f64

Source§

fn from_re_im(re: f64, im: f64) -> Self

Source§

fn re(&self) -> f64

Source§

fn im(&self) -> f64

Source§

fn inv(&self) -> Self

Source§

fn sqrt(&self) -> Self

Implementors§