LinalgScalar

Trait LinalgScalar 

Source
pub trait LinalgScalar:
    Clone
    + Debug
    + Default
    + PartialEq
    + NumAssign
    + Sum
    + for<'a> Sum<&'a Self>
    + ScalarOperand
    + 'static {
    type Real: Float + NumAssign + Sum + Debug + Default + 'static;

    // Required methods
    fn to_f64(&self) -> Result<f64, LinalgError>;
    fn from_f64(v: f64) -> Result<Self, LinalgError>;
    fn abs(&self) -> Self::Real;
    fn is_zero(&self) -> bool;
    fn zero() -> Self;
    fn one() -> Self;
    fn sqrt(&self) -> Self;
    fn conj(&self) -> Self;
    fn real(&self) -> Self::Real;
    fn epsilon() -> Self::Real;
}
Expand description

A trait that unifies numeric types suitable for linear algebra operations

Required Associated Types§

Source

type Real: Float + NumAssign + Sum + Debug + Default + 'static

Type used for norms and condition numbers (always real)

Required Methods§

Source

fn to_f64(&self) -> Result<f64, LinalgError>

Convert to f64 for certain calculations

Source

fn from_f64(v: f64) -> Result<Self, LinalgError>

Create from f64

Source

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

Get the absolute value

Source

fn is_zero(&self) -> bool

Check if value is zero

Source

fn zero() -> Self

Get the zero value

Source

fn one() -> Self

Get the one value

Source

fn sqrt(&self) -> Self

Square root

Source

fn conj(&self) -> Self

Get conjugate (for complex numbers, identity for real)

Source

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

Get real part

Source

fn epsilon() -> Self::Real

Get epsilon for this type

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§

fn to_f64(&self) -> Result<f64, LinalgError>

Source§

fn from_f64(v: f64) -> Result<Self, LinalgError>

Source§

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

Source§

fn is_zero(&self) -> bool

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn sqrt(&self) -> Self

Source§

fn conj(&self) -> Self

Source§

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

Source§

fn epsilon() -> Self::Real

Source§

impl LinalgScalar for f64

Source§

type Real = f64

Source§

fn to_f64(&self) -> Result<f64, LinalgError>

Source§

fn from_f64(v: f64) -> Result<Self, LinalgError>

Source§

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

Source§

fn is_zero(&self) -> bool

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn sqrt(&self) -> Self

Source§

fn conj(&self) -> Self

Source§

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

Source§

fn epsilon() -> Self::Real

Implementors§