640{
641 bool ret = true;
642 char doit = 'A';
643 int rows =
static_cast<int>(A->
numRows());
645 int info;
646 int min = (rows <= cols) ? rows : cols;
647
648 if (min == 0)
649 {
650 ERROR(
"expected a matrix with positive dimensions");
651 return false;
652 }
653
654 int max = (rows >= cols) ? rows : cols;
656
657 double *workspace = new double[wsize];
658 int* iworkspace =
new int[8 *
min];
659
661 std::vector<double> u(rows * rows);
662 std::vector<double> vt(cols * cols);
663 std::vector<double> sigma(min);
664
666 &rows,
667 &cols,
668 copyA.data(),
669 &rows,
670 sigma.data(),
671 u.data(),
672 &rows,
673 vt.data(),
674 &cols,
675 workspace,
676 &wsize,
677 iworkspace,
678 &info);
679
680 if (info < 0)
681 {
682 ERROR(
"argument passed to dgesdd had an illegal value");
683 ret = false;
684 }
685 else if (info > 0)
686 {
687 ERROR(
"dgesdd did not converge");
688 ret = false;
689 }
690 else
691 {
698 }
699
700 delete [] workspace;
701 delete [] iworkspace;
702
703 return ret;
704}
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 dgesdd_(char *jobU, int *rows, int *cols, double *A, int *ldA, double *Sigma, double *U, int *ldU, double *VT, int *ldVT, double *work, int *lwork, int *iwork, int *info)
const mpreal min(const mpreal &x, const mpreal &y)