File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -139,3 +139,21 @@ fn det_nonsquare() {
139139 }
140140 }
141141}
142+
143+ #[ test]
144+ fn solve_random ( ) {
145+ let a: Array2 < f64 > = random ( ( 3 , 3 ) ) ;
146+ let x: Array1 < f64 > = random ( 3 ) ;
147+ let b = a. dot ( & x) ;
148+ let y = a. solve_into ( b) . unwrap ( ) ;
149+ assert_close_l2 ! ( & x, & y, 1e-7 ) ;
150+ }
151+
152+ #[ test]
153+ fn solve_random_t ( ) {
154+ let a: Array2 < f64 > = random ( ( 3 , 3 ) . f ( ) ) ;
155+ let x: Array1 < f64 > = random ( 3 ) ;
156+ let b = a. dot ( & x) ;
157+ let y = a. solve_into ( b) . unwrap ( ) ;
158+ assert_close_l2 ! ( & x, & y, 1e-7 ) ;
159+ }
Original file line number Diff line number Diff line change 1+
2+ extern crate ndarray;
3+ #[ macro_use]
4+ extern crate ndarray_linalg;
5+ extern crate num_traits;
6+
7+ use ndarray:: * ;
8+ use ndarray_linalg:: * ;
9+
10+ #[ test]
11+ fn solveh_random ( ) {
12+ let a: Array2 < f64 > = random_hpd ( 3 ) ;
13+ let x: Array1 < f64 > = random ( 3 ) ;
14+ let b = a. dot ( & x) ;
15+ let y = a. solveh_into ( b) . unwrap ( ) ;
16+ assert_close_l2 ! ( & x, & y, 1e-7 ) ;
17+
18+ let b = a. dot ( & x) ;
19+ let f = a. factorizeh_into ( ) . unwrap ( ) ;
20+ let y = f. solveh_into ( b) . unwrap ( ) ;
21+ assert_close_l2 ! ( & x, & y, 1e-7 ) ;
22+ }
23+
24+ #[ test]
25+ fn solveh_random_t ( ) {
26+ let a: Array2 < f64 > = random_hpd ( 3 ) . reversed_axes ( ) ;
27+ let x: Array1 < f64 > = random ( 3 ) ;
28+ let b = a. dot ( & x) ;
29+ let y = a. solveh_into ( b) . unwrap ( ) ;
30+ assert_close_l2 ! ( & x, & y, 1e-7 ) ;
31+
32+ let b = a. dot ( & x) ;
33+ let f = a. factorizeh_into ( ) . unwrap ( ) ;
34+ let y = f. solveh_into ( b) . unwrap ( ) ;
35+ assert_close_l2 ! ( & x, & y, 1e-7 ) ;
36+ }
You can’t perform that action at this time.
0 commit comments