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
andA += B
- Matrix subtraction:
A - B
andA -= B
- Matrix multiplication:
A * B
Scalar operations are also supported.
- Scalar addition:
A + s
andA += s
- Scalar subtraction:
A - s
andA -= s
- Scalar multiplication:
A * s
andA *= s
- Scalar division:
A / s
andA /= 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.
- Matrix
Transpose View - A static transposed view of matrix.
- Matrix
Transpose View Mut - A static mutable transposed view of a matrix.
- Matrix
View - A static view of a matrix.
- Matrix
View Mut - A static mutable view of a matrix.
- RowVector
- A static row vector type.
- RowVector
View - A row vector view of a
Vector
(transposed view) or aRowVector
. - RowVector
View Mut - A row vector view of a
Vector
(transposed view) or aRowVector
. - Vector
- A static column vector type.
- Vector
View - A column vector view of a
Vector
or aRowVector
(transposed view). - Vector
View Mut - A mutable column vector view of a
Vector
or aRowVector
(transposed view).
Traits§
- DotProduct
- Trait for the dot product operation.
- Float
Random - 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>
.