matrix-basic/src/lib.rs

23 lines
677 B
Rust
Raw Normal View History

2023-05-24 21:46:25 -05:00
pub mod matrix;
#[cfg(test)]
mod tests {
use super::*;
use matrix::Matrix;
#[test]
fn mul_test() {
let a = Matrix::from(vec![vec![1, 2, 4], vec![3, 4, 9]]).unwrap();
let b = Matrix::from(vec![vec![1, 2], vec![2, 3], vec![5, 1]]).unwrap();
let c = Matrix::from(vec![vec![25, 12], vec![56, 27]]).unwrap();
assert_eq!(a * b, c);
}
#[test]
fn add_test() {
let a = Matrix::from(vec![vec![1, 2, 3], vec![0, 1, 2]]).unwrap();
let b = Matrix::from(vec![vec![0, 0, 1], vec![2, 1, 3]]).unwrap();
let c = Matrix::from(vec![vec![1, 2, 4], vec![2, 2, 5]]).unwrap();
assert_eq!(a + b, c);
}
}