2 个版本
0.1.1 | 2024 年 5 月 19 日 |
---|---|
0.1.0 | 2024 年 5 月 19 日 |
418 in 数学
12KB
194 行
Matrix-math
一个简单的 Rust 库/CLI 应用程序,允许进行基本的数学矩阵操作。
入门指南
use matrix::prelude::*;
fn interactive_matrices_example() -> Result<(), Error> {
let matrix1 = matrix(1, None, None);
// By calling matrix2 with the length parameters of matrix1 like so. Doing the operations
// unchecked is **SAFE**.
let matrix2 = matrix(2, Some(matrix1.len()), Some(matrix1[0].len()));
let sum = matrix_operation_unchecked(MatrixOperation::Addition, &matrix1, &matrix2);
println!("Sum:\n{:#?}", sum);
let diff = matrix_operation_unchecked(MatrixOperation::Subtraction, &matrix1, &matrix2);
println!("Difference:\n{:#?}", diff);
let product = matrix_operation_unchecked(MatrixOperation::Multiplication, &matrix1, &matrix2);
println!("Product:\n{:#?}", product);
Ok(())
}
fn main() -> Result<(), Error> {
let args = Args::parse();
if args.interactive {
interactive_matrices_example()?;
}
Ok(())
}
依赖项
~1.3–2MB
~37K SLoC