Skip to main content

ComplexField

Trait ComplexField 

Source
pub trait ComplexField:
    NumAssign
    + Clone
    + Copy
    + Send
    + Sync
    + Debug
    + Zero
    + One
    + Neg<Output = Self>
    + 'static {
    type Real: Float + NumAssign + FromPrimitive + ToPrimitive + Send + Sync + Debug + 'static;

Show 14 methods // Required methods fn conj(&self) -> Self; fn norm_sqr(&self) -> Self::Real; fn from_real(r: Self::Real) -> Self; 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 { ... } fn vec_dot(x: &Array1<Self>, y: &Array1<Self>) -> Self { ... } fn vec_norm_sqr(x: &Array1<Self>) -> Self::Real { ... } fn vec_axpy(alpha: Self, x: &Array1<Self>, y: &mut Array1<Self>) { ... } fn vec_scale(x: &mut Array1<Self>, alpha: Self) { ... }
}
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.

Required Associated Types§

Source

type Real: Float + NumAssign + FromPrimitive + ToPrimitive + Send + Sync + Debug + 'static

The real number type underlying this field

Required Methods§

Source

fn conj(&self) -> Self

Complex conjugate

Source

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

Squared magnitude |z|²

Source

fn from_real(r: Self::Real) -> Self

Create from a real value

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

Source

fn vec_dot(x: &Array1<Self>, y: &Array1<Self>) -> Self

Inner product: Σ conj(x_i) * y_i

Source

fn vec_norm_sqr(x: &Array1<Self>) -> Self::Real

Squared vector norm: Σ |x_i|²

Source

fn vec_axpy(alpha: Self, x: &Array1<Self>, y: &mut Array1<Self>)

AXPY: y += α * x

Source

fn vec_scale(x: &mut Array1<Self>, alpha: Self)

In-place scale: x *= α

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§

type Real = f32

Source§

fn conj(&self) -> Self

Source§

fn norm_sqr(&self) -> f32

Source§

fn from_real(r: f32) -> Self

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§

fn vec_dot(x: &Array1<Self>, y: &Array1<Self>) -> Self

Source§

fn vec_norm_sqr(x: &Array1<Self>) -> Self

Source§

fn vec_axpy(alpha: Self, x: &Array1<Self>, y: &mut Array1<Self>)

Source§

fn vec_scale(x: &mut Array1<Self>, alpha: Self)

Source§

impl ComplexField for f64

Source§

type Real = f64

Source§

fn conj(&self) -> Self

Source§

fn norm_sqr(&self) -> f64

Source§

fn from_real(r: f64) -> Self

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§

fn vec_dot(x: &Array1<Self>, y: &Array1<Self>) -> Self

Source§

fn vec_norm_sqr(x: &Array1<Self>) -> Self

Source§

fn vec_axpy(alpha: Self, x: &Array1<Self>, y: &mut Array1<Self>)

Source§

fn vec_scale(x: &mut Array1<Self>, alpha: Self)

Source§

impl ComplexField for Complex32

Source§

type Real = f32

Source§

fn conj(&self) -> Self

Source§

fn norm_sqr(&self) -> f32

Source§

fn from_real(r: f32) -> Self

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§

type Real = f64

Source§

fn conj(&self) -> Self

Source§

fn norm_sqr(&self) -> f64

Source§

fn from_real(r: f64) -> Self

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§