573{
574 bool ret = true;
575 char doit = 'A';
576 int rows =
static_cast<int>(A->
numRows());
578 int info;
579 int min = (rows <= cols) ? rows : cols;
580
581 if (min == 0)
582 {
583 ERROR(
"expected a matrix with positive dimensions");
584 return false;
585 }
586
587 int max = (rows >= cols) ? rows : cols;
589 double *workspace = new double[wsize];
590
592 std::vector<double> u(rows * rows);
593 std::vector<double> vt(cols * cols);
594 std::vector<double> sigma(min);
595
597 &doit,
598 &rows,
599 &cols,
600 copyA.data(),
601 &rows,
602 sigma.data(),
603 u.data(),
604 &rows,
605 vt.data(),
606 &cols,
607 workspace,
608 &wsize,
609 &info);
610
611 if (info < 0)
612 {
613 ERROR(
"argument passed to dgesvd had an illegal value");
614 ret = false;
615 }
616 else if (info > 0)
617 {
618 ERROR(
"dgesvd did not converge");
619 ret = false;
620 }
621 else
622 {
629 }
630
631 delete [] workspace;
632
633 return ret;
634}
void resize(size_t new_nrows, size_t new_ncols)
size_t numColumns() const
std::vector< double > make_lapack_array(const DMatRR &mat)
void fill_from_lapack_array(const std::vector< double > &doubles, DMatRR &mat)
int dgesvd_(char *jobU, char *jobV, int *rows, int *cols, double *A, int *ldA, double *Sigma, double *U, int *ldU, double *VT, int *ldVT, double *work, int *lwork, int *info)
const mpreal min(const mpreal &x, const mpreal &y)