8个版本
0.3.0 | 2022年6月27日 |
---|---|
0.2.5 | 2021年4月5日 |
0.2.3 | 2020年11月13日 |
0.2.2 | 2020年9月8日 |
0.1.0 | 2020年8月25日 |
#1317 在 数学
被 noise_fn 使用
24KB
464 行
sized_matrix
使用const generics实现尺寸矩阵,以实现更好的类型检查和性能。
use sized_matrix::{Matrix, Vector};
let a: Matrix<i32, 3, 4> = Matrix::rows([
[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12],
]);
let b: Matrix<i32, 4, 2> = Matrix::rows([
[ 0, 1],
[ 1, 2],
[ 3, 5],
[ 8, 13],
]);
let c: Matrix<i32, 3, 2> = a * b;
assert_eq!(c, Matrix::rows([
[ 43, 72],
[ 91, 156],
[139, 240],
]));
let d: Vector<i32, 2> = Matrix::vector([-1, 1]);
let e: Vector<i32, 3> = c * d;
assert_eq!(e, Matrix::vector([
29,
65,
101,
]));
要使用它,请在Cargo.toml中将它添加为依赖项
[dependencies]
sized_matrix = "^0.3.0"
lib.rs
:
使用const generics实现尺寸矩阵,以实现更好的类型检查和性能。
use sized_matrix::{Matrix, Vector};
let a: Matrix<i32, 3, 4> = Matrix::rows([
[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12],
]);
let b: Matrix<i32, 4, 2> = Matrix::rows([
[ 0, 1],
[ 1, 2],
[ 3, 5],
[ 8, 13],
]);
let c: Matrix<i32, 3, 2> = a * b;
assert_eq!(c, Matrix::rows([
[ 43, 72],
[ 91, 156],
[139, 240],
]));
let d: Vector<i32, 2> = Matrix::vector([-1, 1]);
let e: Vector<i32, 3> = c * d;
assert_eq!(e, Matrix::vector([
29,
65,
101,
]));
要使用它,请在Cargo.toml中将它添加为依赖项
[dependencies]
sized_matrix = "^0.3.0"
依赖项
~230KB