linalg::scalar
Element types: Scalar is what every routine needs (f32, f64 and
their complex forms), Real adds ordering and the float functions
for the iterative routines (SVD, eigen) and for norms.
Traits
ScalarSource
pub trait Scalar: Copy + num::Zero + num::One + ops::Add<Output = Self> + ops::Sub<Output = Self>
+ ops::Mul<Output = Self> + ops::Div<Output = Self> + ops::Neg<Output = Self> + PartialEq + Debug + Send + SyncAn element type the routines accept: f32, f64, Complex<f32>,
Complex<f64>. Real is the type of a modulus or a norm.
nabi
use linalg::Scalar;
use core::num::Complex;
let z = 3.0 + 4.0i;
assert(z.modulus() == 5.0);
assert(z.conj() == Complex::new(3.0, -4.0));
truefor the complex types.The complex conjugate (the value itself for a real type).
The real part.
The imaginary part (0 for a real type).
|x|, without overflow for complex values.|re| + |im|, a cheap modulus for pivot searches.ras this type.self * rfor a realr.The principal square root.
trueunless a part is NaN or infinite.xrounded to this type.
RealSource
pub trait Real: Scalar<Real = Self> + FloatingPointA real element type, f32 or f64: what the SVD and the
eigensolvers take, and the type of every norm.
nabi
use core::array::Matrix;
fn top<T: linalg::Real>(a: Matrix<T>) -> T { (try! linalg::svdvals(a))[0] }
let a: Matrix<f32> = [[3, 0], [0, 1]];
assert(top(a) == 3.0f32);