82 using idx_t = size_type<matrix_t>;
83 using range = pair<idx_t, idx_t>;
84 using TA = type_t<matrix_t>;
85 using real_t = real_type<TA>;
89 const type_t<work_t> zero(0);
90 const idx_t m = nrows(A);
91 const idx_t n = ncols(A);
92 const idx_t k = min(m, n);
93 const idx_t nb = min((idx_t)opts.nb, k);
96 auto [X, work2] = reshape(work, m, nb);
97 auto [Y, work3] = reshape(work2, n, nb);
98 laset(GENERAL, zero, zero, X);
99 laset(GENERAL, zero, zero, Y);
101 for (idx_t i = 0; i < k; i = i + nb) {
102 idx_t ib = min(nb, k - i);
106 auto A2 = slice(A, range{i, m}, range{i, n});
107 auto tauq = slice(tauv, range{i, i + ib});
108 auto taup = slice(tauw, range{i, i + ib});
109 auto X2 = slice(X, range{i, m}, range{0, ib});
110 auto Y2 = slice(Y, range{i, n}, range{0, ib});
111 labrd(A2, tauq, taup, X2, Y2);
117 if (i + ib < m && i + ib < n) {
119 auto A3 = slice(A, range{i + ib, m}, range{i + ib, n});
122 e =
real(A(i + ib - 1, i + ib));
123 A(i + ib - 1, i + ib) = one;
126 e =
real(A(i + ib, i + ib - 1));
127 A(i + ib, i + ib - 1) = one;
130 auto V = slice(A, range{i + ib, m}, range{i, i + ib});
131 auto Y3 = slice(Y, range{i + ib, n}, range{0, ib});
132 gemm(NO_TRANS, CONJ_TRANS, -one, V, Y3, one, A3);
133 auto U = slice(A, range{i, i + ib}, range{i + ib, n});
134 auto X3 = slice(X, range{i + ib, m}, range{0, ib});
135 gemm(NO_TRANS, NO_TRANS, -one, X3, U, one, A3);
138 A(i + ib - 1, i + ib) = e;
140 A(i + ib, i + ib - 1) = e;
207 using work_t = matrix_type<matrix_t, vector_t>;
208 using T = type_t<work_t>;
211 Create<work_t> new_matrix;
214 WorkInfo workinfo = gebrd_worksize<T>(A, tauv, tauw, opts);
215 std::vector<T> work_;
216 auto work = new_matrix(work_, workinfo.m, workinfo.n);
int labrd(A_t &A, vector_t &tauq, vector_t &taup, X_t &X, matrixY_t &Y)
Reduces the first nb rows and columns of a general m by n matrix A to upper or lower bidiagonal form ...
Definition labrd.hpp:55
void gemm(Op transA, Op transB, const alpha_t &alpha, const matrixA_t &A, const matrixB_t &B, const beta_t &beta, matrixC_t &C)
General matrix-matrix multiply:
Definition gemm.hpp:61
int gebrd_work(matrix_t &A, vector_t &tauv, vector_t &tauw, work_t &work, const GebrdOpts &opts={})
Reduces a general m by n matrix A to an upper real bidiagonal form B by a unitary transformation: W...
Definition gebrd.hpp:76