1565{
1566 bool ret = true;
1567 char doit = 'A';
1568 int rows =
static_cast<int>(A->
numRows());
1569 int cols =
static_cast<int>(A->
numColumns());
1570 int info;
1571 int min = (rows <= cols) ? rows : cols;
1572
1573 if (min == 0)
1574 {
1575 ERROR(
"expected a matrix with positive dimensions");
1576 return false;
1577 }
1578
1579 int max = (rows >= cols) ? rows : cols;
1581
1582 double *workspace = new double[2 * wsize];
1583 int *iworkspace =
new int[8 *
min];
1584 double *rwork =
new double[5 *
min *
min + 7 *
min];
1585
1587 std::vector<double> u(2 * rows * rows);
1588 std::vector<double> vt(2 * cols * cols);
1589 std::vector<double> sigma(2 * min);
1590
1592 &rows,
1593 &cols,
1594 copyA.data(),
1595 &rows,
1596 sigma.data(),
1597 u.data(),
1598 &rows,
1599 vt.data(),
1600 &cols,
1601 workspace,
1602 &wsize,
1603 rwork,
1604 iworkspace,
1605 &info);
1606
1607 if (info < 0)
1608 {
1609 ERROR(
"argument passed to zgesdd had an illegal value");
1610 ret = false;
1611 }
1612 else if (info > 0)
1613 {
1614 ERROR(
"zgesdd did not converge");
1615 ret = false;
1616 }
1617 else
1618 {
1625 }
1626
1627 delete[] workspace;
1628 delete[] iworkspace;
1629 delete[] rwork;
1630
1631 return ret;
1632}
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 zgesdd_(char *jobU, int *rows, int *cols, double *A, int *ldA, double *Sigma, double *U, int *ldU, double *VT, int *ldVT, double *w, int *lwork, double *rwork, int *iwork, int *info)
const mpreal min(const mpreal &x, const mpreal &y)