@@ -10,11 +10,7 @@ pub struct MGS<A> {
1010 q : Vec < Array1 < A > > ,
1111}
1212
13- /// Residual vector of orthogonalization
14- pub type Residual < S > = ArrayBase < S , Ix1 > ;
15- /// Residual vector of orthogonalization
16- pub type Coefficient < A > = Array1 < A > ;
17- /// Q-matrix (unitary matrix)
13+ /// Q-matrix (unitary)
1814pub type Q < A > = Array2 < A > ;
1915/// R-matrix (upper triangle)
2016pub type R < A > = Array2 < A > ;
@@ -49,7 +45,7 @@ impl<A: Scalar> MGS<A> {
4945 /// Panic
5046 /// -------
5147 /// - if the size of the input array mismaches to the dimension
52- pub fn orthogonalize < S > ( & self , mut a : ArrayBase < S , Ix1 > ) -> ( Residual < S > , Coefficient < A > )
48+ pub fn orthogonalize < S > ( & self , a : & mut ArrayBase < S , Ix1 > ) -> Array1 < A >
5349 where
5450 A : Lapack ,
5551 S : DataMut < Elem = A > ,
@@ -59,12 +55,12 @@ impl<A: Scalar> MGS<A> {
5955 for i in 0 ..self . len ( ) {
6056 let q = & self . q [ i] ;
6157 let c = q. inner ( & a) ;
62- azip ! ( mut a, q ( q) in { * a = * a - c * q } ) ;
58+ azip ! ( mut a ( & mut * a ) , q ( q) in { * a = * a - c * q } ) ;
6359 coef[ i] = c;
6460 }
6561 let nrm = a. norm_l2 ( ) ;
6662 coef[ self . len ( ) ] = A :: from_real ( nrm) ;
67- ( a , coef)
63+ coef
6864 }
6965
7066 /// Add new vector if the residual is larger than relative tolerance
@@ -85,13 +81,13 @@ impl<A: Scalar> MGS<A> {
8581 ///
8682 /// assert!(mgs.append(array![1.0, 2.0, 0.0], 1e-9).is_none()); // Cannot append dependent vector
8783 /// ```
88- pub fn append < S > ( & mut self , a : ArrayBase < S , Ix1 > , rtol : A :: Real ) -> Option < Coefficient < A > >
84+ pub fn append < S > ( & mut self , a : ArrayBase < S , Ix1 > , rtol : A :: Real ) -> Option < Array1 < A > >
8985 where
9086 A : Lapack ,
9187 S : Data < Elem = A > ,
9288 {
93- let a = a. into_owned ( ) ;
94- let ( mut a , coef) = self . orthogonalize ( a) ;
89+ let mut a = a. into_owned ( ) ;
90+ let coef = self . orthogonalize ( & mut a) ;
9591 let nrm = coef[ coef. len ( ) - 1 ] . re ( ) ;
9692 if nrm < rtol {
9793 // Linearly dependent
0 commit comments