minmath
Quick start example
use Matrix;
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check issues page.
Adding minmath
to dependencies
There are two ways to add the crate to your dependencies.
Manual
Add the following to your Cargo.toml
file.
[]
= "*"
# Check https://crates.io/crates/minmath for the latest version
Command Line
Run the following in your terminal.
Structures
Matrix
The following are derived for the Matrix structure.
Clone
Copy
PartialEq
Eq
When a matrix is declared the type and size (rows and columns) are implicitly derived. The type should implement the following traits.
Copy
Debug
Default
AddAssign
SubAssign
MulAssign
DivAssign
Functions
- Creates a new matrix of type T and size (ROWS, COLUMNS) from the provided 2D array.
e.g
let matrix: = new;
- Returns the size of the matrix as (rows, columns).
e.g
let matrix: = new;
let size: = matrix.size;
- Returns the determinant of the matrix (only works for 2x2 at the moment).
e.g
let matrix: = new;
let determinant: i32 = matrix.determinant;
Operators
All matrix sizes are supported by the operators (square and non-square).
Operation | With Scalar | With Matrix |
---|---|---|
Add | ✓ (+ ) |
✓ (+ ) |
Add Assign | ✓ (+= ) |
✓ (+= ) |
Subtract | ✓ (- ) |
✓ (- ) |
Subtract Assign | ✓ (-= ) |
✓ (-= ) |
Multiply | ✓ (* ) |
✓ (* ) |
Multiply Assign | ✓ (*= ) |
✓ (*= ) |
Divide | ✓ (/ ) |
|
Divide Assign | ✓ (/= ) |
Matrix multiplication
let a = new;
let b = new;
let c = a * b; // c is Matrix<i32, 2, 2>
Other implementations
Debug
Display
License
This project is licensed under the MIT License. See LICENSE for details.