LinalgScalar

Trait LinalgScalar 

Source
pub trait LinalgScalar:
    Scalar
    + Sub<Output = Self>
    + Neg<Output = Self>
    + Div<Output = Self>
    + NumCast
    + Debug
    + 'static {
    type Real: LinalgScalar<Real = Self::Real, Complex = Self::Complex> + Float;
    type Complex: LinalgScalar<Real = Self::Real, Complex = Self::Complex>;

    // Required methods
    fn abs_real(&self) -> Self::Real;
    fn real_epsilon() -> Self::Real;
    fn conj(&self) -> Self;
    fn from_parts(real: Self::Real, imag: Self::Real) -> Self;
    fn real_part(&self) -> Self::Real;
    fn imag_part(&self) -> Self::Real;

    // Provided method
    fn from_real(real: Self::Real) -> Self { ... }
}
Expand description

Scalar types supported by linalg kernel contracts.

§Examples

use tenferro_linalg_prims::LinalgScalar;

fn needs_linalg_scalar<T: LinalgScalar>(x: T) -> T { x }
assert_eq!(needs_linalg_scalar(1.0_f64), 1.0);

Required Associated Types§

Source

type Real: LinalgScalar<Real = Self::Real, Complex = Self::Complex> + Float

Source

type Complex: LinalgScalar<Real = Self::Real, Complex = Self::Complex>

Required Methods§

Source

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

Return the scalar magnitude in the associated real field.

Source

fn real_epsilon() -> Self::Real

Return a reasonable machine epsilon for the associated real field.

Source

fn conj(&self) -> Self

Return the algebraic conjugate.

Source

fn from_parts(real: Self::Real, imag: Self::Real) -> Self

Build a scalar from explicit real/imaginary parts.

Source

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

Return the real part in the associated real field.

Source

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

Return the imaginary part in the associated real field.

Provided Methods§

Source

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

Build a scalar from the associated real field.

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 LinalgScalar for f32

Source§

type Real = f32

Source§

type Complex = Complex<f32>

Source§

fn abs_real(&self) -> f32

Source§

fn real_epsilon() -> f32

Source§

fn conj(&self) -> f32

Source§

fn from_parts(real: Self::Real, _imag: Self::Real) -> Self

Source§

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

Source§

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

Source§

impl LinalgScalar for f64

Source§

type Real = f64

Source§

type Complex = Complex<f64>

Source§

fn abs_real(&self) -> f64

Source§

fn real_epsilon() -> f64

Source§

fn conj(&self) -> f64

Source§

fn from_parts(real: Self::Real, _imag: Self::Real) -> Self

Source§

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

Source§

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

Source§

impl LinalgScalar for Complex32

Source§

type Real = f32

Source§

type Complex = Complex<f32>

Source§

fn abs_real(&self) -> f32

Source§

fn real_epsilon() -> f32

Source§

fn conj(&self) -> Complex32

Source§

fn from_parts(real: Self::Real, imag: Self::Real) -> Self

Source§

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

Source§

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

Source§

impl LinalgScalar for Complex64

Source§

type Real = f64

Source§

type Complex = Complex<f64>

Source§

fn abs_real(&self) -> f64

Source§

fn real_epsilon() -> f64

Source§

fn conj(&self) -> Complex64

Source§

fn from_parts(real: Self::Real, imag: Self::Real) -> Self

Source§

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

Source§

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

Implementors§