@@ -131,30 +131,6 @@ where
131
131
}
132
132
133
133
134
- impl < A , S > FactorizedH < S >
135
- where
136
- A : Scalar ,
137
- S : DataMut < Elem = A > ,
138
- {
139
- /// Computes the inverse of the factorized matrix.
140
- ///
141
- /// **Warning: The inverse is stored only in the upper triangular portion
142
- /// of the result matrix!** If you want the lower triangular portion to be
143
- /// correct, you must fill it in according to the results in the upper
144
- /// triangular portion.
145
- pub fn into_inverseh ( mut self ) -> Result < ArrayBase < S , Ix2 > > {
146
- unsafe {
147
- A :: invh (
148
- self . a . square_layout ( ) ?,
149
- UPLO :: Upper ,
150
- self . a . as_allocated_mut ( ) ?,
151
- & self . ipiv ,
152
- ) ?
153
- } ;
154
- Ok ( self . a )
155
- }
156
- }
157
-
158
134
/// An interface for computing the Bunch–Kaufman factorization of Hermitian (or
159
135
/// real symmetric) matrix refs.
160
136
pub trait FactorizeH < S : Data > {
@@ -221,6 +197,42 @@ pub trait InverseHInto {
221
197
fn invh_into ( self ) -> Result < Self :: Output > ;
222
198
}
223
199
200
+ impl < A , S > InverseHInto for FactorizedH < S >
201
+ where
202
+ A : Scalar ,
203
+ S : DataMut < Elem = A > ,
204
+ {
205
+ type Output = ArrayBase < S , Ix2 > ;
206
+
207
+ fn invh_into ( mut self ) -> Result < ArrayBase < S , Ix2 > > {
208
+ unsafe {
209
+ A :: invh (
210
+ self . a . square_layout ( ) ?,
211
+ UPLO :: Upper ,
212
+ self . a . as_allocated_mut ( ) ?,
213
+ & self . ipiv ,
214
+ ) ?
215
+ } ;
216
+ Ok ( self . a )
217
+ }
218
+ }
219
+
220
+ impl < A , S > InverseH for FactorizedH < S >
221
+ where
222
+ A : Scalar ,
223
+ S : Data < Elem = A > ,
224
+ {
225
+ type Output = Array2 < A > ;
226
+
227
+ fn invh ( & self ) -> Result < Self :: Output > {
228
+ let f = FactorizedH {
229
+ a : replicate ( & self . a ) ,
230
+ ipiv : self . ipiv . clone ( ) ,
231
+ } ;
232
+ f. invh_into ( )
233
+ }
234
+ }
235
+
224
236
impl < A , S > InverseHInto for ArrayBase < S , Ix2 >
225
237
where
226
238
A : Scalar ,
@@ -230,7 +242,7 @@ where
230
242
231
243
fn invh_into ( self ) -> Result < Self :: Output > {
232
244
let f = self . factorizeh_into ( ) ?;
233
- f. into_inverseh ( )
245
+ f. invh_into ( )
234
246
}
235
247
}
236
248
@@ -243,6 +255,6 @@ where
243
255
244
256
fn invh ( & self ) -> Result < Self :: Output > {
245
257
let f = self . factorizeh ( ) ?;
246
- f. into_inverseh ( )
258
+ f. invh_into ( )
247
259
}
248
260
}
0 commit comments