File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change
1
+
2
+ extern crate ndarray;
3
+ extern crate ndarray_linalg;
4
+
5
+ use ndarray:: * ;
6
+ use ndarray_linalg:: * ;
7
+
8
+ // Solve `Ax=b` for many b with fixed A
9
+ fn factorize ( ) -> Result < ( ) , error:: LinalgError > {
10
+ let a: Array2 < f64 > = random ( ( 3 , 3 ) ) ;
11
+ let f = a. factorize_into ( ) ?; // LU factorize A (A is consumed)
12
+ for _ in 0 ..10 {
13
+ let b: Array1 < f64 > = random ( 3 ) ;
14
+ let x = f. solve ( Transpose :: No , b) ?; // solve Ax=b using factorized L, U
15
+ }
16
+ Ok ( ( ) )
17
+ }
18
+
19
+ fn main ( ) {
20
+ factorize ( ) . unwrap ( ) ;
21
+ }
Original file line number Diff line number Diff line change @@ -75,14 +75,13 @@ where
75
75
}
76
76
}
77
77
78
- impl < A , Si , So > Factorize < So > for ArrayBase < Si , Ix2 >
78
+ impl < A , Si > Factorize < OwnedRepr < A > > for ArrayBase < Si , Ix2 >
79
79
where
80
80
A : Scalar ,
81
81
Si : Data < Elem = A > ,
82
- So : DataOwned < Elem = A > + DataMut ,
83
82
{
84
- fn factorize ( & self ) -> Result < Factorized < So > > {
85
- let mut a: ArrayBase < So , Ix2 > = replicate ( self ) ;
83
+ fn factorize ( & self ) -> Result < Factorized < OwnedRepr < A > > > {
84
+ let mut a: Array2 < A > = replicate ( self ) ;
86
85
let ipiv = unsafe { A :: lu ( a. layout ( ) ?, a. as_allocated_mut ( ) ?) ? } ;
87
86
Ok ( Factorized { a : a, ipiv : ipiv } )
88
87
}
You can’t perform that action at this time.
0 commit comments