43 const idx m =
A.rows();
44 const idx n =
A.cols();
45 const idx r = (
m > n) ? n :
m - 1;
51 std::vector<std::vector<real>>
vs(
r);
56 std::vector<real> x(
len);
63 std::vector<real> v = x;
90 for (
idx k =
r;
k-- > 0; ) {
91 const std::vector<real>& v =
vs[
k];
92 const idx len =
static_cast<idx>(v.size());
105 for (
idx j = 0;
j < std::min(
i, n); ++
j)
108 return {std::move(Q), std::move(R)};
120 const idx m =
f.Q.rows();
121 const idx n =
f.R.cols();
130 for (
idx i = n;
i-- > 0; ) {
132 for (
idx j =
i + 1;
j < n; ++
j)
Dense row-major matrix with optional GPU storage.
void qr_solve(const QRResult &f, const Vector &b, Vector &x)
Solve the least-squares problem min ||A*x - b||_2.
constexpr T ipow(T x) noexcept
Compute x^N at compile time via repeated squaring.
QRResult qr(const Matrix &A)
QR factorization of an mxn matrix A (m >= n) via Householder reflections.
QR factorization via Householder reflections.
Result of a QR factorization: A = Q * R.