vector-victor/tests/ops.rs

26 lines
694 B
Rust
Raw Normal View History

2023-05-06 07:39:06 +00:00
#[macro_use]
mod common;
use common::Approx;
2022-08-19 04:07:05 +00:00
use generic_parameterize::parameterize;
use num_traits::real::Real;
use num_traits::Zero;
2022-08-19 04:07:05 +00:00
use std::fmt::Debug;
2022-12-05 04:24:57 +00:00
use std::iter::{zip, Product, Sum};
2022-08-19 04:07:05 +00:00
use std::ops;
use vector_victor::{Matrix, Vector};
2022-08-19 04:07:05 +00:00
2023-05-06 07:39:06 +00:00
#[parameterize(S = (i32, f32, f64, u32), M = [1,4], N = [1,4])]
2022-08-19 04:07:05 +00:00
#[test]
fn test_add<S: Copy + From<u16> + PartialEq + Debug, const M: usize, const N: usize>()
2022-08-19 04:07:05 +00:00
where
Matrix<S, M, N>: ops::Add<Output = Matrix<S, M, N>>,
{
let a = Matrix::<S, M, N>::fill(S::from(1));
let b = Matrix::<S, M, N>::fill(S::from(3));
let c: Matrix<S, M, N> = a + b;
2023-05-06 07:39:06 +00:00
for (_, ci) in c.elements().enumerate() {
2022-08-19 04:07:05 +00:00
assert_eq!(*ci, S::from(4));
}
}