17#if defined(NUMERICS_HAS_LAPACK)
19 const idx k = std::min(m, n);
22 std::vector<double> tau(k);
25 LAPACKE_dgeqrf(LAPACK_ROW_MAJOR,
static_cast<lapack_int
>(m),
26 static_cast<lapack_int
>(n), R.
data(),
27 static_cast<lapack_int
>(n),
30 throw std::runtime_error(
"qr (lapack): dgeqrf failed, info=" +
31 std::to_string(info));
35 for (
idx i = 1; i < m; ++i)
36 for (
idx j = 0; j < std::min(i, n); ++j)
41 for (
idx j = 0; j < k; ++j)
42 for (
idx i = 0; i < m; ++i)
45 info = LAPACKE_dorgqr(LAPACK_ROW_MAJOR,
static_cast<lapack_int
>(m),
46 static_cast<lapack_int
>(m),
static_cast<lapack_int
>(k),
48 static_cast<lapack_int
>(m),
51 throw std::runtime_error(
"qr (lapack): dorgqr failed, info=" +
52 std::to_string(info));
54 return {std::move(Q), std::move(Rmat)};