Skip to content

Commit 0b90ff5

Browse files
committed
Add test
1 parent f72d7a0 commit 0b90ff5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/inner.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use ndarray::*;
2+
use ndarray_linalg::*;
3+
4+
#[should_panic]
5+
#[test]
6+
fn size_shoter() {
7+
let a: Array1<f32> = Array::zeros(3);
8+
let b = Array::zeros(4);
9+
a.inner(&b);
10+
}
11+
12+
#[should_panic]
13+
#[test]
14+
fn size_longer() {
15+
let a: Array1<f32> = Array::zeros(3);
16+
let b = Array::zeros(4);
17+
b.inner(&a);
18+
}
19+
20+
#[test]
21+
fn abs() {
22+
let a: Array1<c32> = random(1);
23+
let aa = a.inner(&a);
24+
assert_aclose!(aa.re(), a.norm().powi(2), 1e-5);
25+
assert_aclose!(aa.im(), 0.0, 1e-5);
26+
}

0 commit comments

Comments
 (0)