88 template<
int Rows=Dynamic,
int Cols=Rows,
typename Precision=DefaultPrecision>
92 static const int Min_Dim = Rows<Cols?Rows:Cols;
108 template <
int R2,
int C2,
typename P2,
typename B2>
112 my_square(
std::min(m.num_rows(),m.num_cols()),
std::min(m.num_rows(),m.num_cols()))
118 template <
int R2,
int C2,
typename P2,
typename B2>
126 Precision*
const a =
my_copy.my_data;
130 Precision*
const uorvt =
my_square.my_data;
156 dgesvd_( &JOBVT, &JOBU, &m, &n, a, &lda, s, uorvt,
157 &ldvt, uorvt, &ldu, &size, &LWORK, &INFO);
159 LWORK = (
long int)(size);
160 wk =
new Precision[LWORK];
162 dgesvd_( &JOBVT, &JOBU, &m, &n, a, &lda, s, uorvt,
163 &ldvt, uorvt, &ldu, wk, &LWORK, &INFO);
180 template <
int Rows2,
int Cols2,
typename P2,
typename B2>
193 template <
int Size,
typename P2,
typename B2>
224 int rank(
const Precision condition = condition_no) {
227 for(
int i=0; i<
min_dim(); i++){
270 for(
int i=0; i<
min_dim(); i++){
274 inv_diag[i]=
static_cast<Precision
>(1)/
my_diagonal[i];
293 template<
int Size,
typename Precision>
299 SQSVD(
int size) :
SVD<Size,Size,Precision>(size, size) {}
301 template <
int R2,
int C2,
typename P2,
typename B2>
SVD(const Matrix< R2, C2, P2, B2 > &m)
Matrix< Rows, Min_Dim, Precision, Reference::RowMajor > get_U()
SQSVD(const Matrix< R2, C2, P2, B2 > &m)
Matrix< Rows, Cols, Precision, RowMajor > my_copy
Everything lives inside this namespace.
Matrix< Cols, Cols2, typename Internal::MultiplyType< Precision, P2 >::type > backsub(const Matrix< Rows2, Cols2, P2, B2 > &rhs, const Precision condition=condition_no)
Matrix< Min_Dim, Min_Dim, Precision, RowMajor > my_square
SVD()
default constructor for Rows>0 and Cols>0
Matrix< Cols, Rows > get_pinv(const Precision condition=condition_no)
Vector< Min_Dim, Precision > & get_diagonal()
Return the singular values as a vector.
void compute(const Matrix< R2, C2, P2, B2 > &m)
Compute the SVD decomposition of M, typically used after the default constructor. ...
void get_inv_diag(Vector< Min_Dim > &inv_diag, const Precision condition)
Matrix< Min_Dim, Cols, Precision, Reference::RowMajor > get_VT()
Vector< Min_Dim, Precision > my_diagonal
SVD(int rows, int cols)
constructor for Rows=-1 or Cols=-1 (or both)
int rank(const Precision condition=condition_no)
static const double condition_no
void dgesvd_(const char *JOBU, const char *JOBVT, int *M, int *N, double *A, int *lda, double *S, double *U, int *ldu, double *VT, int *ldvt, double *WORK, int *lwork, int *INFO)
Vector< Internal::Sizer< S1, S2 >::size, typename Internal::MultiplyType< P1, P2 >::type > diagmult(const Vector< S1, P1, B1 > &v1, const Vector< S2, P2, B2 > &v2)
Vector< Cols, typename Internal::MultiplyType< Precision, P2 >::type > backsub(const Vector< Size, P2, B2 > &rhs, const Precision condition=condition_no)