5 #ifndef FML_PAR_CPU_LINALG_QR_H
6 #define FML_PAR_CPU_LINALG_QR_H
10 #include "../parmat.hh"
12 #include "../../../cpu/linalg/linalg_blas.hh"
13 #include "../../../cpu/linalg/linalg_invert.hh"
14 #include "../../../cpu/linalg/linalg_qr.hh"
16 #include "qr_allreduce.hh"
25 template <
typename REAL>
26 void qr_R(
const int root, parmat_cpu<REAL> &x, cpumat<REAL> &R,
27 cpumat<REAL> &R_local, cpuvec<REAL> &qraux)
29 const len_t n = x.ncols();
35 tsqr::qr_allreduce(root, n, n, R_local.data_ptr(), R.data_ptr(),
36 x.get_comm().get_comm());
40 template <
typename REAL>
41 void qr_R(
const int root, parmat_cpu<REAL> &x, cpumat<REAL> &R)
43 if (x.nrows() < (len_global_t) x.ncols())
44 throw std::runtime_error(
"impossible dimensions");
49 internals::qr_R(root, x, R, R_local, qraux);
56 template <
typename REAL>
57 void qr_Q(
const parmat_cpu<REAL> &x, parmat_cpu<REAL> &x_cpy,
58 cpumat<REAL> &R, cpumat<REAL> &R_local,
59 cpuvec<REAL> &qraux, parmat_cpu<REAL> &Q)
62 qr_R(mpi::REDUCE_TO_ALL, x_cpy, R, R_local, qraux);
68 template <
typename REAL>
69 void qr_Q(parmat_cpu<REAL> &x, cpuvec<REAL> &qraux, parmat_cpu<REAL> &Q)
71 cpumat<REAL> R, R_local;
73 qr_R(mpi::REDUCE_TO_ALL, x, R, R_local, qraux);