Matrix Operations
Matrix_Operations is a Rust crate for performing various matrix operations. It provides a set of functions for performing common matrix operations.
Installation
Add the following to your Cargo.toml file:
[]
= "0.1.5"
Usage
This crate provides a wide range of operations that can be performed on matrices. Here are some examples of common operations:
use matrix;
use transpose_matrix;
let matrix1 = matrix!;
let matrix2 = matrix!;
let mut matrix3 = matrix1.clone + matrix2.clone * 2;
assert_eq!;
matrix3 -= 1;
assert_eq!;
matrix3 /= 2;
assert_eq!;
matrix3 -= matrix1;
assert_eq!;
matrix3 = transpose_matrix;
assert_eq!;
matrix3 *= matrix2;
assert_eq!;
This crate also provides functionality to load and save matrices to a file:
use ;
use matrix;
let matrix1 = matrix!;
write_matrix_to_csv.unwrap;
let matrix2 = load_matrix_from_csv.unwrap;
assert_eq!;
Features
- Create a matrix
- Transpose a matrix
- Multiply / Add / Subtract two matrices
- Multiply / Divide / Add / Subtract a matrix by a scalar
- Add / Subtract each matrix rows / columns by a distinct value
- Apply a function to each element of a matrix (like multiplying by a scalar, or adding a constant)
- Apply a function on each element of two matrices (like multiplying two matrices element by element)
- Apply a function on each row or column of a matrix
- Get a matrix as a slice / vector / 2D vector
- Load / Save a matrix in a file
- Add / Remove rows / columns
- Concatenate matrices