Trait totsu::linalg::LinAlg[][src]

pub trait LinAlg<F: Float> {
    fn norm(x: &[F]) -> F;
fn copy(x: &[F], y: &mut [F]);
fn scale(alpha: F, x: &mut [F]);
fn add(alpha: F, x: &[F], y: &mut [F]);
fn abssum(x: &[F]) -> F;
fn transform_di(alpha: F, mat: &[F], x: &[F], beta: F, y: &mut [F]); }
Expand description

Linear algebra trait

Required methods

Calculate 2-norm (or euclidean norm) \(\|x\|_2=\sqrt{\sum_i x_i^2}\).

Returns the calculated norm.

  • x is a vector \(x\).

Copy from a vector to another vector.

  • x is a slice to copy.
  • y is a slice being copied to. x and y shall have the same length.

Calculate \(\alpha x\).

  • alpha is a scalar \(\alpha\).
  • x is a vector \(x\) before entry, \(\alpha x\) on exit.

Calculate \(\alpha x + y\).

  • alpha is a scalar \(\alpha\).
  • x is a vector \(x\).
  • y is a vector \(y\) before entry, \(\alpha x + y\) on exit. x and y shall have the same length.

Calculate 1-norm (or sum of absolute values) \(\|x\|_1=\sum_i |x_i|\).

Returns the calculated norm.

  • x is a vector \(x\).

Calculate \(\alpha D x + \beta y\), where \(D={\bf diag}(d)\) is a diagonal matrix.

  • alpha is a scalar \(\alpha\).
  • mat is a diagonal vector \(d\) of \(D\).
  • x is a vector \(x\).
  • beta is a scalar \(\beta\).
  • y is a vector \(y\) before entry, \(\alpha D x + \beta y\) on exit. mat, x and y shall have the same length.

Implementors