Molecular Modeling Software
リビジョン | e09b1b8af6927299d26d39001e1c68416e110639 (tree) |
---|---|
日時 | 2021-08-13 14:10:22 |
作者 | toshinagata1964 <toshinagata1964@a2be...> |
コミッター | toshinagata1964 |
LAMatrix:SVD may cause random crashes. Fixed.
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@628 a2be9bc6-48de-4e38-9406-05402d4bc13c
@@ -587,12 +587,11 @@ LAMatrixSingularValueDecomposition(LAMatrix *matU, LAMatrix *matW, LAMatrix *mat | ||
587 | 587 | n = mat->column; |
588 | 588 | lda = m; |
589 | 589 | num = (m < n ? m : n); |
590 | - LAMatrixResize(matW, num, 1); | |
591 | - LAMatrixResize(matU, m, m); | |
592 | - LAMatrixResize(matV, n, n); | |
590 | + if (matW->row != num || matW->column != 1 || matU->row != m || matU->column != m || matV->row != n || matV->column != n) | |
591 | + return -1; /* Illegal dimension */ | |
593 | 592 | matData = (__CLPK_doublereal *)malloc(sizeof(__CLPK_doublereal) * n * m); |
594 | 593 | memmove(matData, mat->data, sizeof(__CLPK_doublereal) * n * m); |
595 | - iwork = (__CLPK_integer *)malloc(sizeof(__CLPK_integer) * num); | |
594 | + iwork = (__CLPK_integer *)malloc(sizeof(__CLPK_integer) * num * 8); | |
596 | 595 | lwork = -1; |
597 | 596 | info = 0; |
598 | 597 | dgesdd_("A", &m, &n, matData, &lda, matW->data, matU->data, &m, matV->data, &n, &workSize, &lwork, iwork, &info); |