64 template<
class mat_t,
class vec_t,
class vec2_t>
66 vec_t &tau_U, vec2_t &tau_V) {
69 O2SCL_ERR2(
"Bidiagonal decomposition requires M>=N in ",
73 for (
size_t i=0;i<N;i++) {
82 O2SCL_IX(tau_U,i)=tau_i;
93 O2SCL_IX(tau_V,i)=tau2_i;
111 template<
class mat_t,
class vec_t,
class mat2_t,
class vec2_t,
112 class mat3_t,
class vec3_t,
class vec4_t>
114 const vec_t &tau_U, mat2_t &U,
const vec2_t &tau_V,
115 mat3_t &V, vec3_t &diag, vec4_t &superdiag) {
126 for (
size_t i=0;i<N;i++) {
127 O2SCL_IX(diag,i)=O2SCL_IX2(A,i,i);
132 for (
size_t i=0;i<N-1;i++) {
133 O2SCL_IX(superdiag,i)=O2SCL_IX2(A,i,i+1);
137 for(
size_t i=0;i<N;i++) {
138 for(
size_t j=0;j<N;j++) {
139 if (i==j) O2SCL_IX2(V,i,j)=1.0;
140 else O2SCL_IX2(V,i,j)=0.0;
144 for (
size_t i=N-1;i-- > 0;) {
152 for(
size_t i=0;i<M;i++) {
153 for(
size_t j=0;j<N;j++) {
154 if (i==j) O2SCL_IX2(U,i,j)=1.0;
155 else O2SCL_IX2(U,i,j)=0.0;
159 for (
size_t j=N;j-- > 0;) {
169 template<
class mat_t,
class vec_t,
class vec2_t,
class mat2_t>
171 vec2_t &tau_V, mat2_t &V) {
182 for(
size_t i=0;i<N;i++) {
183 for(
size_t j=0;j<N;j++) {
184 if (i==j) O2SCL_IX2(V,i,j)=1.0;
185 else O2SCL_IX2(V,i,j)=0.0;
189 for (
size_t i=N-1;i-- > 0;) {
198 for (
size_t i=0;i<N-1;i++) {
199 O2SCL_IX(tau_V,i)=O2SCL_IX2(A,i,i+1);
205 for (
size_t j=N; j-- > 0;) {
207 double tj=O2SCL_IX(tau_U,j);
208 O2SCL_IX(tau_U,j)=O2SCL_IX2(A,j,j);
218 template<
class mat_t,
class vec_t,
class vec2_t>
220 vec_t &diag, vec2_t &superdiag) {
226 for (
size_t i=0;i<K;i++) {
227 O2SCL_IX(diag,i)=O2SCL_IX2(A,i,i);
231 for (
size_t i=0;i<K-1;i++) {
232 O2SCL_IX(superdiag,i)=O2SCL_IX2(A,i,i+1);
int bidiag_unpack2(size_t M, size_t N, mat_t &A, vec_t &tau_U, vec2_t &tau_V, mat2_t &V)
Unpack a matrix A with the bidiagonal decomposition and create matrix V.
int bidiag_unpack(size_t M, size_t N, const mat_t &A, const vec_t &tau_U, mat2_t &U, const vec2_t &tau_V, mat3_t &V, vec3_t &diag, vec4_t &superdiag)
Unpack a matrix A with the bidiagonal decomposition and create matrices U, V, diagonal diag and super...
double householder_transform_subcol(mat_t &A, const size_t ir, const size_t ic, const size_t M)
Compute the Householder transform of a vector formed with n rows of a column of a matrix...
void householder_hm_subrow(mat_t &M, const size_t ir, const size_t ic, const size_t nr, const size_t nc, const mat_t &M2, const size_t ir2, const size_t ic2, double tau)
Apply a Householder transformation to the lower-right part of M when the transformation is stored in ...
double householder_transform_subrow(mat_t &A, const size_t ir, const size_t ic, const size_t N)
Compute the Householder transform of a vector formed with the last n columns of a row of a matrix...
matrix, vector lengths are not conformant
void householder_hm_subcol(mat_t &M, const size_t ir, const size_t ic, const size_t nr, const size_t nc, const mat_t &M2, const size_t ir2, const size_t ic2, double tau)
Apply a Householder transformation to the lower-right part of M when the transformation is stored in ...
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
The namespace for linear algebra classes and functions.
int bidiag_unpack_B(size_t M, size_t N, const mat_t &A, vec_t &diag, vec2_t &superdiag)
Unpack the diagonal and superdiagonal of the bidiagonal decomposition of A into diag and superdiag...
int bidiag_decomp(size_t M, size_t N, mat_t &A, vec_t &tau_U, vec2_t &tau_V)
Factor a matrix into bidiagonal form.
void householder_mh_subrow(mat_t &M, const size_t ir, const size_t ic, const size_t nr, const size_t nc, const mat2_t &M2, const size_t ir2, const size_t ic2, double tau)
Apply the Householder transformation (v,tau) to the right-hand side of the matrix A...
void householder_hm1_sub(const size_t M, const size_t N, double tau, mat_t &A, size_t ir, size_t ic)
Apply a Householder transformation to a matrix being build up from the identity matrix, using the first column of A as a Householder vector.