@@ -131,30 +131,6 @@ where
131131}
132132
133133
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-
158134/// An interface for computing the Bunch–Kaufman factorization of Hermitian (or
159135/// real symmetric) matrix refs.
160136pub trait FactorizeH < S : Data > {
@@ -221,6 +197,42 @@ pub trait InverseHInto {
221197 fn invh_into ( self ) -> Result < Self :: Output > ;
222198}
223199
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+
224236impl < A , S > InverseHInto for ArrayBase < S , Ix2 >
225237where
226238 A : Scalar ,
@@ -230,7 +242,7 @@ where
230242
231243 fn invh_into ( self ) -> Result < Self :: Output > {
232244 let f = self . factorizeh_into ( ) ?;
233- f. into_inverseh ( )
245+ f. invh_into ( )
234246 }
235247}
236248
@@ -243,6 +255,6 @@ where
243255
244256 fn invh ( & self ) -> Result < Self :: Output > {
245257 let f = self . factorizeh ( ) ?;
246- f. into_inverseh ( )
258+ f. invh_into ( )
247259 }
248260}
0 commit comments