65 requires(mem::on_host<A>
and is_blas_lapack_v<get_value_t<A>>
and have_same_value_type_v<A, TAU>
67 int geqp3(A &&a, JPVT &&jpvt, TAU &&tau) {
68 static_assert(has_F_layout<A>,
"Error in nda::lapack::geqp3: C order not supported");
69 static_assert(std::is_same_v<get_value_t<JPVT>,
int>,
"Error in nda::lapack::geqp3: Pivoting array must have elements of type int");
70 static_assert(mem::have_host_compatible_addr_space<A, JPVT, TAU>,
"Error in nda::lapack::geqp3: Only CPU is supported");
72 auto [m, n] = a.shape();
73 EXPECTS(tau.size() >= std::min(m, n));
76 EXPECTS(a.indexmap().min_stride() == 1);
77 EXPECTS(jpvt.indexmap().min_stride() == 1);
78 EXPECTS(tau.indexmap().min_stride() == 1);
81 using value_type = get_value_t<A>;
82 value_type bufferSize_T{};
84 array<
double, 1> rwork(2 * n);
85 lapack::f77::geqp3(m, n, a.data(), get_ld(a), jpvt.data(), tau.data(), &bufferSize_T, -1, rwork
.data(), info);
86 int bufferSize =
static_cast<
int>(std::ceil(std::real(bufferSize_T)));
89 nda::array<value_type, 1> work(bufferSize);
90 lapack::f77::geqp3(m, n, a.data(), get_ld(a), jpvt.data(), tau.data(), work.data(), bufferSize, rwork
.data(), info);