1495{
1496 bool ret = true;
1497 char doit = 'A';
1498 int rows =
static_cast<int>(A->
numRows());
1499 int cols =
static_cast<int>(A->
numColumns());
1500 int info;
1501 int min = (rows <= cols) ? rows : cols;
1502
1503 if (min == 0)
1504 {
1505 ERROR(
"expected a matrix with positive dimensions");
1506 return false;
1507 }
1508
1509 int max = (rows >= cols) ? rows : cols;
1510 int wsize = 2 *
min +
max;
1511 double *workspace = new double[2 * wsize];
1512 double *rwork =
new double[5 *
min];
1513
1515 std::vector<double> u(2 * rows * rows);
1516 std::vector<double> vt(2 * cols * cols);
1517 std::vector<double> sigma(2 * min);
1518
1520 &doit,
1521 &rows,
1522 &cols,
1523 copyA.data(),
1524 &rows,
1525 sigma.data(),
1526 u.data(),
1527 &rows,
1528 vt.data(),
1529 &cols,
1530 workspace,
1531 &wsize,
1532 rwork,
1533 &info);
1534
1535 if (info < 0)
1536 {
1537 ERROR(
"argument passed to zgesvd had an illegal value");
1538 ret = false;
1539 }
1540 else if (info > 0)
1541 {
1542 ERROR(
"zgesvd did not converge");
1543 ret = false;
1544 }
1545 else
1546 {
1553 }
1554
1555 delete[] workspace;
1556 delete[] rwork;
1557
1558 return ret;
1559}
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 zgesvd_(char *jobU, char *jobV, 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 *info)
const mpreal min(const mpreal &x, const mpreal &y)