@@ -141,53 +141,39 @@ impl<A> Matrix for Array<A, (Ix, Ix)>
141
141
let ( n, m) = self . size ( ) ;
142
142
println ! ( "n={}, m={}" , n, m) ;
143
143
let k = min ( n, m) ;
144
- let ( p, l) = ImplSolve :: lu ( self . layout ( ) , n, m, self . clone ( ) . into_raw_vec ( ) ) ?;
145
- match self . layout ( ) {
144
+ let ( p, mut a) = match self . layout ( ) {
146
145
Layout :: ColumnMajor => {
147
146
println ! ( "ColumnMajor" ) ;
148
- let mut a = Array :: from_vec ( l) . into_shape ( ( m, n) ) . unwrap ( ) . reversed_axes ( ) ;
149
- println ! ( "a (after LU) = \n {:?}" , & a) ;
150
- let mut lm = Array :: zeros ( ( n, k) ) ;
151
- for ( ( i, j) , val) in lm. indexed_iter_mut ( ) {
152
- if i > j {
153
- * val = a[ ( i, j) ] ;
154
- } else if i == j {
155
- * val = A :: one ( ) ;
156
- }
157
- }
158
- for ( ( i, j) , val) in a. indexed_iter_mut ( ) {
159
- if i > j {
160
- * val = A :: zero ( ) ;
161
- }
162
- }
163
- let am = if n > k {
164
- a. slice ( s ! [ 0 ..k as isize , ..] ) . to_owned ( )
165
- } else {
166
- a
167
- } ;
168
- println ! ( "am = \n {:?}" , am) ;
169
- Ok ( ( p, lm, am) )
147
+ let ( p, l) = ImplSolve :: lu ( self . layout ( ) , n, m, self . clone ( ) . into_raw_vec ( ) ) ?;
148
+ ( p, Array :: from_vec ( l) . into_shape ( ( m, n) ) . unwrap ( ) . reversed_axes ( ) )
170
149
}
171
150
Layout :: RowMajor => {
172
151
println ! ( "RowMajor" ) ;
173
- let mut lm = Array :: from_vec ( l) . into_shape ( ( m, n) ) . unwrap ( ) ;
174
- println ! ( "a (after LU) = \n {:?}" , & lm) ;
175
- let mut um = Array :: zeros ( ( n, m) ) ;
176
- for ( ( i, j) , val) in um. indexed_iter_mut ( ) {
177
- if i <= j {
178
- * val = lm[ ( i, j) ] ;
179
- }
180
- }
181
- for ( ( i, j) , val) in lm. indexed_iter_mut ( ) {
182
- if i < j {
183
- * val = A :: zero ( ) ;
184
- } else if i == j {
185
- * val = A :: one ( ) ;
186
- }
187
- }
188
- Ok ( ( p, lm, um) )
152
+ let ( p, l) = ImplSolve :: lu ( self . layout ( ) , n, m, self . clone ( ) . into_raw_vec ( ) ) ?;
153
+ ( p, Array :: from_vec ( l) . into_shape ( ( n, m) ) . unwrap ( ) )
154
+ }
155
+ } ;
156
+ println ! ( "a (after LU) = \n {:?}" , & a) ;
157
+ let mut lm = Array :: zeros ( ( n, k) ) ;
158
+ for ( ( i, j) , val) in lm. indexed_iter_mut ( ) {
159
+ if i > j {
160
+ * val = a[ ( i, j) ] ;
161
+ } else if i == j {
162
+ * val = A :: one ( ) ;
189
163
}
190
164
}
165
+ for ( ( i, j) , val) in a. indexed_iter_mut ( ) {
166
+ if i > j {
167
+ * val = A :: zero ( ) ;
168
+ }
169
+ }
170
+ let am = if n > k {
171
+ a. slice ( s ! [ 0 ..k as isize , ..] ) . to_owned ( )
172
+ } else {
173
+ a
174
+ } ;
175
+ println ! ( "am = \n {:?}" , am) ;
176
+ Ok ( ( p, lm, am) )
191
177
}
192
178
fn permutate ( & mut self , ipiv : & Self :: Permutator ) {
193
179
let ( _, m) = self . size ( ) ;
0 commit comments