mirror of
https://github.com/ivabus/matrix
synced 2024-12-04 22:15:07 +03:00
Fix tests
Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
parent
e43529b29f
commit
33ea6498cf
3 changed files with 15 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "matrix"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// use rand::{thread_rng, Rng};
|
||||
use std::ops::{Add, AddAssign, Mul, MulAssign};
|
||||
|
||||
use rand::{thread_rng, Rng};
|
||||
|
||||
pub(crate) type Matrix<T> = Vec<Vec<T>>;
|
||||
|
||||
fn check_valid<T>(a: &Matrix<T>) -> bool {
|
||||
|
@ -63,9 +64,12 @@ pub fn mul<T: Mul<Output = T> + Copy + AddAssign + MulAssign + std::fmt::Display
|
|||
|
||||
Some(c)
|
||||
}
|
||||
/*
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn gen_matrix<T>(i: usize, j: usize) -> Option<Matrix<T>> {
|
||||
fn gen_matrix<T: Mul<Output = T> + Copy + AddAssign + MulAssign + std::fmt::Display + From<i32>>(
|
||||
i: usize,
|
||||
j: usize,
|
||||
) -> Option<Matrix<T>> {
|
||||
if !(i > 0 && j > 0) {
|
||||
return None;
|
||||
}
|
||||
|
@ -76,7 +80,7 @@ fn gen_matrix<T>(i: usize, j: usize) -> Option<Matrix<T>> {
|
|||
for a in 0..i {
|
||||
m.push(vec![]);
|
||||
for _ in 0..j {
|
||||
m[a].push(rng.gen_range(0..100) as T);
|
||||
m[a].push(T::from(rng.gen_range(0..100)));
|
||||
}
|
||||
}
|
||||
Some(m)
|
||||
|
@ -84,8 +88,10 @@ fn gen_matrix<T>(i: usize, j: usize) -> Option<Matrix<T>> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use rand::{thread_rng, Rng};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn basic_sum() {
|
||||
let a = vec![vec![1., 2.], vec![3., 4.]];
|
||||
|
@ -145,10 +151,6 @@ mod test {
|
|||
let a: Matrix<f64> = gen_matrix(s1, s2).unwrap();
|
||||
let b: Matrix<f64> = gen_matrix(s2, s3).unwrap();
|
||||
let c: Matrix<f64> = gen_matrix(s3, s4).unwrap();
|
||||
assert_eq!(
|
||||
mul(&mul(&a, &b).unwrap(), &c).unwrap(),
|
||||
mul(&a, &mul(&b, &c).unwrap()).unwrap()
|
||||
)
|
||||
assert_eq!(mul(&mul(&a, &b).unwrap(), &c).unwrap(), mul(&a, &mul(&b, &c).unwrap()).unwrap())
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "matrix_graphics"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
|
@ -11,7 +11,7 @@ default = ["optimize"]
|
|||
[dependencies]
|
||||
env_logger = "0.10"
|
||||
log = "0.4"
|
||||
matrix = { version = "0.1.0", path = "../matrix" }
|
||||
matrix = { version = "0.1.2", path = "../matrix" }
|
||||
pixels = "0.11.0"
|
||||
winit = "0.28.1"
|
||||
winit_input_helper = "0.14.0"
|
||||
|
|
Loading…
Reference in a new issue