Matrix_Operations is a Rust crate for performing various matrix operations. It provides a set of functions for performing common matrix operations.
Add the following to your Cargo.toml file:
toml
[dependencies]
matrix_operations = "0.1.0"
This crate provides a wide range of operations that can be performed on matrices. Here are some examples of common operations:
```rust use matrixoperations::matrix; use matrixoperations::operations::transpose_matrix;
let matrix1 = matrix![[1, 2, 3], [4, 5, 6]];
let matrix2 = matrix![[7, 8, 9], [10, 11, 12]];
let mut matrix3 = matrix1.clone() + matrix2.clone() * 2; assert_eq!(matrix3, matrix![[15, 18, 21], [24, 27, 30]]);
matrix3 -= 1; assert_eq!(matrix3, matrix![[14, 17, 20], [23, 26, 29]]);
matrix3 /= 2; assert_eq!(matrix3, matrix![[7, 8, 10], [11, 13, 14]]);
matrix3 -= matrix1; assert_eq!(matrix3, matrix![[6, 6, 7], [7, 8, 8]]);
matrix3 = transposematrix(&matrix3); asserteq!(matrix3, matrix![[6, 7], [6, 8], [7, 8]]);
matrix3 *= matrix2; assert_eq!(matrix3, matrix![[112, 125, 138], [122, 136, 150], [129, 144, 159]]); ```
This crate also provides functionality to load and save matrices to a file:
```rust use matrixoperations::csv::{loadmatrixfromcsv, writematrixtocsv}; use matrixoperations::matrix;
let matrix1 = matrix![[1, 2, 3], [4, 5, 6]];
writematrixto_csv(&matrix1, "resources/matrix.csv", ",").unwrap();
let matrix2 = loadmatrixfrom_csv("resources/matrix.csv", ",").unwrap();
assert_eq!(matrix1, matrix2); ```