@@ -112,6 +112,22 @@ void cholesky_lsolve(Op transpose, Matrix<T>& A, Matrix<T>& X) {
112
112
TA_LAPACK (trtrs, uplo, transpose, diag, n, nrhs, a, lda, b, ldb);
113
113
}
114
114
115
+ template <typename T>
116
+ void qr_solve (Matrix<T>& A, Matrix<T>& B,
117
+ const TiledArray::detail::real_t <T> cond) {
118
+ integer m = A.rows ();
119
+ integer n = A.cols ();
120
+ integer nrhs = B.cols ();
121
+ T* a = A.data ();
122
+ integer lda = A.rows ();
123
+ T* b = B.data ();
124
+ integer ldb = B.rows ();
125
+ std::vector<integer> jpiv (n);
126
+ const TiledArray::detail::real_t <T> rcond = 1 / cond;
127
+ integer rank = -1 ;
128
+ TA_LAPACK (gelsy, m, n, nrhs, a, lda, b, ldb, jpiv.data (), rcond, &rank);
129
+ }
130
+
115
131
template <typename T>
116
132
void heig (Matrix<T>& A, std::vector<TiledArray::detail::real_t <T>>& W) {
117
133
auto jobz = lapack::Job::Vec;
@@ -250,7 +266,7 @@ void householder_qr(Matrix<T>& V, Matrix<T>& R) {
250
266
lapack::orgqr (m, n, k, v, ldv, tau.data ());
251
267
}
252
268
253
- #define TA_LAPACK_EXPLICIT (MATRIX, VECTOR ) \
269
+ #define TA_LAPACK_EXPLICIT (MATRIX, VECTOR, DOUBLE ) \
254
270
template void cholesky (MATRIX&); \
255
271
template void cholesky_linv (MATRIX&); \
256
272
template void cholesky_solve (MATRIX&, MATRIX&); \
@@ -261,11 +277,12 @@ void householder_qr(Matrix<T>& V, Matrix<T>& R) {
261
277
template void lu_solve (MATRIX&, MATRIX&); \
262
278
template void lu_inv (MATRIX&); \
263
279
template void householder_qr<true >(MATRIX&, MATRIX&); \
264
- template void householder_qr<false >(MATRIX&, MATRIX&);
280
+ template void householder_qr<false >(MATRIX&, MATRIX&); \
281
+ template void qr_solve (MATRIX&, MATRIX&, DOUBLE)
265
282
266
- TA_LAPACK_EXPLICIT (Matrix<double >, std::vector<double >);
267
- TA_LAPACK_EXPLICIT (Matrix<float >, std::vector<float >);
268
- TA_LAPACK_EXPLICIT (Matrix<std::complex<double >>, std::vector<double >);
269
- TA_LAPACK_EXPLICIT (Matrix<std::complex<float >>, std::vector<float >);
283
+ TA_LAPACK_EXPLICIT(Matrix<double >, std::vector<double >, double );
284
+ TA_LAPACK_EXPLICIT (Matrix<float >, std::vector<float >, float );
285
+ TA_LAPACK_EXPLICIT (Matrix<std::complex<double >>, std::vector<double >, double );
286
+ TA_LAPACK_EXPLICIT (Matrix<std::complex<float >>, std::vector<float >, float );
270
287
271
288
} // namespace TiledArray::math::linalg::rank_local
0 commit comments