Crate ferrix

Source
Expand description

A simple static matrix library for Rust.

This crate implements three main types: Vector, RowVector, and Matrix.

Alongside, various views are implemented to minimize memory allocation and copying.

Common matrix operations are implemented via operator overloading.

  • Matrix addition: A + B and A += B
  • Matrix subtraction: A - B and A -= B
  • Matrix multiplication: A * B

Scalar operations are also supported.

  • Scalar addition: A + s and A += s
  • Scalar subtraction: A - s and A -= s
  • Scalar multiplication: A * s and A *= s
  • Scalar division: A / s and A /= s

The DotProduct trait is implemented for Vector and RowVector.

§Example

use ferrix::*;

// Initialize a 3x3 matrix
let a = Matrix3::from([
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0],
    [7.0, 8.0, 9.0],
]);

// Initialize a 3x1 column vector
let b = Vector3::from([1.0, 2.0, 3.0]);

// Perform matrix multiplication
let c = a * b;
assert_eq!(c, Matrix::from([[14.0], [32.0], [50.0]]));

Structs§

Matrix
A static matrix type.
MatrixTransposeView
A static transposed view of matrix.
MatrixTransposeViewMut
A static mutable transposed view of a matrix.
MatrixView
A static view of a matrix.
MatrixViewMut
A static mutable view of a matrix.
RowVector
A static row vector type.
RowVectorView
A row vector view of a Vector (transposed view) or a RowVector.
RowVectorViewMut
A row vector view of a Vector (transposed view) or a RowVector.
Vector
A static column vector type.
VectorView
A column vector view of a Vector or a RowVector (transposed view).
VectorViewMut
A mutable column vector view of a Vector or a RowVector (transposed view).

Traits§

DotProduct
Trait for the dot product operation.
FloatRandom
Trait for floating-point random number generation.
IntRandom
Trait for integer random number generation.

Type Aliases§

Matrix2
A static 2x2 matrix alias for Matrix<T, 2, 2>.
Matrix3
A static 3x3 matrix alias for Matrix<T, 3, 3>.
Vector2
A static 2D vector alias for Vector<T, 2>.
Vector3
A static 3D vector alias for Vector<T, 3>.