summaryrefslogtreecommitdiffstats
path: root/scilab/modules
diff options
context:
space:
mode:
authorClément DAVID <clement.david@esi-group.com>2021-05-18 09:53:15 +0200
committerStéphane MOTTELET <stephane.mottelet@utc.fr>2021-05-18 12:02:59 +0200
commit18e9fd43fc2a5d034e5ff7a8f79e9c6a55e195cf (patch)
tree0b71cb10f6bef53c66d01e1a2e11d7f7f3352b79 /scilab/modules
parent8e75c840b88eaa088922dabcbb787b266eac1ed2 (diff)
downloadscilab-18e9fd43fc2a5d034e5ff7a8f79e9c6a55e195cf.zip
scilab-18e9fd43fc2a5d034e5ff7a8f79e9c6a55e195cf.tar.gz
* Bug 15330 fixed: spec.tst was crashing on Linux
https://bugzilla.scilab.org/show_bug.cgi?id=15330 After lapack source code read, zgeev.f need rwork storage for detecting its work sizes. Other memory leaks have also been fixed in this commit. Change-Id: I8c90ce927caea264def831a484ab7a2173c3a46a
Diffstat (limited to 'scilab/modules')
-rw-r--r--scilab/modules/linear_algebra/sci_gateway/cpp/sci_spec.cpp14
-rw-r--r--scilab/modules/linear_algebra/src/c/eigen.c5
2 files changed, 16 insertions, 3 deletions
diff --git a/scilab/modules/linear_algebra/sci_gateway/cpp/sci_spec.cpp b/scilab/modules/linear_algebra/sci_gateway/cpp/sci_spec.cpp
index 468e0c9..ca038ab 100644
--- a/scilab/modules/linear_algebra/sci_gateway/cpp/sci_spec.cpp
+++ b/scilab/modules/linear_algebra/sci_gateway/cpp/sci_spec.cpp
@@ -163,12 +163,12 @@ types::Function::ReturnValue sci_spec(types::typed_list &in, int _iRetCount, typ
163 if (_iRetCount == 2) 163 if (_iRetCount == 2)
164 { 164 {
165 vGetPointerFromDoubleComplex((doublecomplex*)pDataA, pDblA->getSize(), pDblEigenVectors->getReal(), pDblEigenVectors->getImg()); 165 vGetPointerFromDoubleComplex((doublecomplex*)pDataA, pDblA->getSize(), pDblEigenVectors->getReal(), pDblEigenVectors->getImg());
166 vFreeDoubleComplexFromPointer((doublecomplex*)pDataA);
167 expandToDiagonalOfMatrix(pDblEigenValues->getReal(), pDblA->getCols()); 166 expandToDiagonalOfMatrix(pDblEigenValues->getReal(), pDblA->getCols());
168 out.push_back(pDblEigenVectors); 167 out.push_back(pDblEigenVectors);
169 } 168 }
170 out.push_back(pDblEigenValues); 169 out.push_back(pDblEigenValues);
171 pDblA->killMe(); 170 pDblA->killMe();
171 vFreeDoubleComplexFromPointer((doublecomplex*)pDataA);
172 } 172 }
173 else // not symmetric 173 else // not symmetric
174 { 174 {
@@ -228,6 +228,10 @@ types::Function::ReturnValue sci_spec(types::typed_list &in, int _iRetCount, typ
228 228
229 if (_iRetCount == 2) 229 if (_iRetCount == 2)
230 { 230 {
231 if (pDblEigenVectors)
232 {
233 pDblEigenVectors->killMe();
234 }
231 expandToDiagonalOfMatrix(pDblEigenValues->getReal(), pDblA->getCols()); 235 expandToDiagonalOfMatrix(pDblEigenValues->getReal(), pDblA->getCols());
232 out.push_back(pDblA); 236 out.push_back(pDblA);
233 } 237 }
@@ -245,6 +249,10 @@ types::Function::ReturnValue sci_spec(types::typed_list &in, int _iRetCount, typ
245 if (iRet < 0) 249 if (iRet < 0)
246 { 250 {
247 pDblA->killMe(); 251 pDblA->killMe();
252 if (pDblEigenVectors)
253 {
254 pDblEigenVectors->killMe();
255 }
248 Scierror(998, _("%s: On entry to ZHEEV parameter number 3 had an illegal value (lapack library problem).\n"), "spec"); 256 Scierror(998, _("%s: On entry to ZHEEV parameter number 3 had an illegal value (lapack library problem).\n"), "spec");
249 return types::Function::Error; 257 return types::Function::Error;
250 } 258 }
@@ -252,6 +260,10 @@ types::Function::ReturnValue sci_spec(types::typed_list &in, int _iRetCount, typ
252 if (iRet > 0) 260 if (iRet > 0)
253 { 261 {
254 pDblA->killMe(); 262 pDblA->killMe();
263 if (pDblEigenVectors)
264 {
265 pDblEigenVectors->killMe();
266 }
255 Scierror(24, _("%s: The QR algorithm failed to compute all the eigenvalues, and no eigenvectors have been computed. Elements and %d+1:N of WR and WI contain eigenvalues which have converged.\n"), "spec", iRet); 267 Scierror(24, _("%s: The QR algorithm failed to compute all the eigenvalues, and no eigenvectors have been computed. Elements and %d+1:N of WR and WI contain eigenvalues which have converged.\n"), "spec", iRet);
256 return types::Function::Error; 268 return types::Function::Error;
257 } 269 }
diff --git a/scilab/modules/linear_algebra/src/c/eigen.c b/scilab/modules/linear_algebra/src/c/eigen.c
index 9257722..1ff3816 100644
--- a/scilab/modules/linear_algebra/src/c/eigen.c
+++ b/scilab/modules/linear_algebra/src/c/eigen.c
@@ -98,8 +98,9 @@ static int zheevWorkSizes(int iCols, int* optWorkSize, int* minWorkSize)
98static int zgeevWorkSizes(int iCols, int lhs, int* optWorkSize, int* minWorkSize) 98static int zgeevWorkSizes(int iCols, int lhs, int* optWorkSize, int* minWorkSize)
99{ 99{
100 int info = 0, query = -1; 100 int info = 0, query = -1;
101 double rwork;
101 doublecomplex opt; 102 doublecomplex opt;
102 C2F(zgeev)("N", (lhs == 1 ? "N" : "V"), &iCols, NULL, &iCols, NULL, NULL, &iCols, NULL, &iCols, &opt, &query, NULL, &info ); 103 C2F(zgeev)("N", (lhs == 1 ? "N" : "V"), &iCols, NULL, &iCols, NULL, NULL, &iCols, NULL, &iCols, &opt, &query, &rwork, &info );
103 *optWorkSize = (int)opt.r; 104 *optWorkSize = (int)opt.r;
104 *minWorkSize = Max(1, 2 * iCols); 105 *minWorkSize = Max(1, 2 * iCols);
105 return info; 106 return info;
@@ -119,7 +120,7 @@ static int dgeevWorkSizes(int iCols, int lhs, int* optWorkSize, int* minWorkSize
119{ 120{
120 int info = 0, query = -1; 121 int info = 0, query = -1;
121 double opt; 122 double opt;
122 C2F(dgeev)("N", "N", &iCols, NULL, &iCols, NULL, NULL, NULL, &iCols, NULL, &iCols, &opt, &query, &info); 123 C2F(dgeev)("N", (lhs == 1 ? "N" : "V"), &iCols, NULL, &iCols, NULL, NULL, NULL, &iCols, NULL, &iCols, &opt, &query, &info);
123 *optWorkSize = (int)opt; 124 *optWorkSize = (int)opt;
124 125
125 *minWorkSize = (lhs == 2) ? Max(1, 4 * iCols) : Max(1, 3 * iCols); 126 *minWorkSize = (lhs == 2) ? Max(1, 4 * iCols) : Max(1, 3 * iCols);