inline MKL_INT qr_factor(MKL_INT m, MKL_INT n, T r[], T tau[], T q[], T work[], MKL_INT len, void (*geqrf)(const MKL_INT*, const MKL_INT*, T*, const MKL_INT*, T*, T*, const MKL_INT*, MKL_INT*), void (*orgqr)(const MKL_INT*, const MKL_INT*, const MKL_INT*, T*, const MKL_INT*, const T*, T*, const MKL_INT*, MKL_INT*)) { MKL_INT info = 0; geqrf(&m, &n, r, &m, tau, work, &len, &info); for (MKL_INT i = 0; i < m; ++i) { for (MKL_INT j = 0; j < m && j < n; ++j) { if (i > j) { q[j * m + i] = r[j * m + i]; } } } //compute the q elements explicitly if (m <= n) { orgqr(&m, &m, &m, q, &m, tau, work, &len, &info); } else { orgqr(&m, &m, &n, q, &m, tau, work, &len, &info); } return info; }
inline int orgqr (A& a, Tau& tau, detail::workspace1<Work> workspace ) { typedef typename A::value_type value_type ; const int n = traits::matrix_size2 (a); traits::detail::array<value_type> work(std::max<int>(1, n)); return orgqr( a, tau, workspace.w_ ); }
inline MKL_INT qr_thin_factor(MKL_INT m, MKL_INT n, T q[], T tau[], T r[], T work[], MKL_INT len, void (*geqrf)(const MKL_INT*, const MKL_INT*, T*, const MKL_INT*, T*, T*, const MKL_INT*, MKL_INT*), void (*orgqr)(const MKL_INT*, const MKL_INT*, const MKL_INT*, T*, const MKL_INT*, const T*, T*, const MKL_INT*, MKL_INT*)) { MKL_INT info = 0; geqrf(&m, &n, q, &m, tau, work, &len, &info); for (MKL_INT i = 0; i < n; ++i) { for (MKL_INT j = 0; j < n; ++j) { if (i <= j) { r[j * n + i] = q[j * m + i]; } } } orgqr(&m, &n, &n, q, &m, tau, work, &len, &info); return info; }
inline int orgqr (A& a, Tau& tau) { return orgqr( a, tau, optimal_workspace() ); }