@@ -90,12 +90,12 @@ pub mod layout;
90
90
pub mod eig;
91
91
pub mod eigh;
92
92
pub mod eigh_generalized;
93
+ pub mod qr;
93
94
94
95
mod alloc;
95
96
mod cholesky;
96
97
mod least_squares;
97
98
mod opnorm;
98
- mod qr;
99
99
mod rcond;
100
100
mod solve;
101
101
mod solveh;
@@ -108,7 +108,6 @@ pub use self::cholesky::*;
108
108
pub use self :: flags:: * ;
109
109
pub use self :: least_squares:: * ;
110
110
pub use self :: opnorm:: * ;
111
- pub use self :: qr:: * ;
112
111
pub use self :: rcond:: * ;
113
112
pub use self :: solve:: * ;
114
113
pub use self :: solveh:: * ;
@@ -126,7 +125,6 @@ pub type Pivot = Vec<i32>;
126
125
/// Trait for primitive types which implements LAPACK subroutines
127
126
pub trait Lapack :
128
127
OperatorNorm_
129
- + QR_
130
128
+ SVD_
131
129
+ SVDDC_
132
130
+ Solve_
@@ -160,6 +158,18 @@ pub trait Lapack:
160
158
a : & mut [ Self ] ,
161
159
b : & mut [ Self ] ,
162
160
) -> Result < Vec < Self :: Real > > ;
161
+
162
+ /// Execute Householder reflection as the first step of QR-decomposition
163
+ ///
164
+ /// For C-continuous array,
165
+ /// this will call LQ-decomposition of the transposed matrix $ A^T = LQ^T $
166
+ fn householder ( l : MatrixLayout , a : & mut [ Self ] ) -> Result < Vec < Self > > ;
167
+
168
+ /// Reconstruct Q-matrix from Householder-reflectors
169
+ fn q ( l : MatrixLayout , a : & mut [ Self ] , tau : & [ Self ] ) -> Result < ( ) > ;
170
+
171
+ /// Execute QR-decomposition at once
172
+ fn qr ( l : MatrixLayout , a : & mut [ Self ] ) -> Result < Vec < Self > > ;
163
173
}
164
174
165
175
macro_rules! impl_lapack {
@@ -198,6 +208,26 @@ macro_rules! impl_lapack {
198
208
let work = EighGeneralizedWork :: <$s>:: new( calc_eigenvec, layout) ?;
199
209
work. eval( uplo, a, b)
200
210
}
211
+
212
+ fn householder( l: MatrixLayout , a: & mut [ Self ] ) -> Result <Vec <Self >> {
213
+ use qr:: * ;
214
+ let work = HouseholderWork :: <$s>:: new( l) ?;
215
+ work. eval( a)
216
+ }
217
+
218
+ fn q( l: MatrixLayout , a: & mut [ Self ] , tau: & [ Self ] ) -> Result <( ) > {
219
+ use qr:: * ;
220
+ let mut work = QWork :: <$s>:: new( l) ?;
221
+ work. calc( a, tau) ?;
222
+ Ok ( ( ) )
223
+ }
224
+
225
+ fn qr( l: MatrixLayout , a: & mut [ Self ] ) -> Result <Vec <Self >> {
226
+ let tau = Self :: householder( l, a) ?;
227
+ let r = Vec :: from( & * a) ;
228
+ Self :: q( l, a, & tau) ?;
229
+ Ok ( r)
230
+ }
201
231
}
202
232
} ;
203
233
}
0 commit comments