MyMatrix
My simple matrix library that can perform fraction operations.
1. Attribute
- Name: MyMatrix
- Goal: Provide a simple matrix library that can perform fraction operations
- Module: Fraction, Vector, Matrix
- Test: Using rstest for unit tests and ensure all tests passed
- Security: There is no
unsafe
code block
2. Usage
To use it, add the following lines to your Cargo.toml
file:
[]
= "0"
Some simple examples:
use ;
// Vector dot product
from * from; // 32
// Vector cross product
cross; // [-3 6 -3]
// Vector scalar product
from * from; // [2/5 4/5 6/5]
// Matrix rank
from.rank; // 3
// Matrix determinant
from.det; // 27
// Matrix inversion
from.inv.unwrap;
/*
[
-16/9 8/9 -1/9
14/9 -7/9 2/9
-1/9 2/9 -1/9
]
*/
let a = from;
let b = zeros;
let c = ones;
let d = identity;
.inv.unwrap;
/*
[
-11/6 5/6
5/3 -2/3
]
*/
let A = from;
assert_eq!; // A.adj = |A| * A.inv
assert_eq!; // |A.adj| = |A|^(n-1)