@@ -7,6 +7,7 @@ use super::convert::*;
77use super :: error:: * ;
88use super :: lapack_traits:: * ;
99use super :: layout:: * ;
10+ use super :: types:: * ;
1011
1112pub use lapack_traits:: { Pivot , Transpose } ;
1213
@@ -51,15 +52,19 @@ where
5152}
5253
5354pub trait Factorize < S : Data > {
54- fn factorize ( self ) -> Result < Factorized < S > > ;
55+ fn factorize ( & self ) -> Result < Factorized < S > > ;
5556}
5657
57- impl < A , S > Factorize < S > for ArrayBase < S , Ix2 >
58+ pub trait FactorizeInto < S : Data > {
59+ fn factorize_into ( self ) -> Result < Factorized < S > > ;
60+ }
61+
62+ impl < A , S > FactorizeInto < S > for ArrayBase < S , Ix2 >
5863where
59- A : LapackScalar ,
64+ A : Scalar ,
6065 S : DataMut < Elem = A > ,
6166{
62- fn factorize ( mut self ) -> Result < Factorized < S > > {
67+ fn factorize_into ( mut self ) -> Result < Factorized < S > > {
6368 let ipiv = A :: lu ( self . layout ( ) ?, self . as_allocated_mut ( ) ?) ?;
6469 Ok ( Factorized {
6570 a : self ,
@@ -68,41 +73,50 @@ where
6873 }
6974}
7075
71- impl < ' a , A , Si , So > Factorize < So > for & ' a ArrayBase < Si , Ix2 >
76+ impl < A , Si , So > Factorize < So > for ArrayBase < Si , Ix2 >
7277where
73- A : LapackScalar + Copy ,
78+ A : Scalar ,
7479 Si : Data < Elem = A > ,
7580 So : DataOwned < Elem = A > + DataMut ,
7681{
77- fn factorize ( self ) -> Result < Factorized < So > > {
82+ fn factorize ( & self ) -> Result < Factorized < So > > {
7883 let mut a: ArrayBase < So , Ix2 > = replicate ( self ) ;
7984 let ipiv = A :: lu ( a. layout ( ) ?, a. as_allocated_mut ( ) ?) ?;
8085 Ok ( Factorized { a : a, ipiv : ipiv } )
8186 }
8287}
8388
84- pub trait Inverse < Inv > {
85- fn inv ( self ) -> Result < Inv > ;
89+ pub trait Inverse {
90+ type Output ;
91+ fn inv ( & self ) -> Result < Self :: Output > ;
92+ }
93+
94+ pub trait InverseInto {
95+ type Output ;
96+ fn inv_into ( self ) -> Result < Self :: Output > ;
8697}
8798
88- impl < A , S > Inverse < ArrayBase < S , Ix2 > > for ArrayBase < S , Ix2 >
99+ impl < A , S > InverseInto for ArrayBase < S , Ix2 >
89100where
90- A : LapackScalar ,
101+ A : Scalar ,
91102 S : DataMut < Elem = A > ,
92103{
93- fn inv ( self ) -> Result < ArrayBase < S , Ix2 > > {
94- let f = self . factorize ( ) ?;
104+ type Output = Self ;
105+
106+ fn inv_into ( self ) -> Result < Self :: Output > {
107+ let f = self . factorize_into ( ) ?;
95108 f. into_inverse ( )
96109 }
97110}
98111
99- impl < ' a , A , Si , So > Inverse < ArrayBase < So , Ix2 > > for & ' a ArrayBase < Si , Ix2 >
112+ impl < A , Si > Inverse for ArrayBase < Si , Ix2 >
100113where
101- A : LapackScalar + Copy ,
114+ A : Scalar ,
102115 Si : Data < Elem = A > ,
103- So : DataOwned < Elem = A > + DataMut ,
104116{
105- fn inv ( self ) -> Result < ArrayBase < So , Ix2 > > {
117+ type Output = Array2 < A > ;
118+
119+ fn inv ( & self ) -> Result < Self :: Output > {
106120 let f = self . factorize ( ) ?;
107121 f. into_inverse ( )
108122 }
0 commit comments