From 119e5b4dfa6d985199c161e6abd1e22bb20b78f9 Mon Sep 17 00:00:00 2001 From: Ferhat Mihoubi <ferhat.mihoubi@u-pec.fr> Date: Mon, 5 Jun 2017 18:51:43 +0200 Subject: [PATCH] Corrects bugs in bytecode related to the use of finite instead of isfinite and to mxMalloc tests --- mex/sources/bytecode/ErrorHandling.hh | 2 +- mex/sources/bytecode/Evaluate.cc | 4 ++-- mex/sources/bytecode/SparseMatrix.cc | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mex/sources/bytecode/ErrorHandling.hh b/mex/sources/bytecode/ErrorHandling.hh index b03599444..82d4b2c8c 100644 --- a/mex/sources/bytecode/ErrorHandling.hh +++ b/mex/sources/bytecode/ErrorHandling.hh @@ -2237,7 +2237,7 @@ public: inline test_mxMalloc(void *z, int line, string file, string func, int amount) { - if (!z && (amount > 0)) + if (z == NULL && (amount > 0)) { ostringstream tmp; tmp << " mxMalloc: out of memory " << amount << " bytes required at line " << line << " in function " << func << " (file " << file; diff --git a/mex/sources/bytecode/Evaluate.cc b/mex/sources/bytecode/Evaluate.cc index c0860b011..16b4e4d22 100644 --- a/mex/sources/bytecode/Evaluate.cc +++ b/mex/sources/bytecode/Evaluate.cc @@ -1539,14 +1539,14 @@ Evaluate::solve_simple_one_periods() Per_y_ = it_*y_size; ya = y[Block_Contain[0].Variable + Per_y_]; compute_block_time(0, false, false); - if (!finite(res1)) + if (!isfinite(res1)) { res1 = NAN; while ((isinf(res1) || isnan(res1)) && (slowc > 1e-9)) { it_code = start_code; compute_block_time(0, false, false); - if (!finite(res1)) + if (!isfinite(res1)) { slowc /= 1.5; mexPrintf("Reducing the path length in Newton step slowc=%f\n", slowc); diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc index 7526bbf4e..7db7341cb 100644 --- a/mex/sources/bytecode/SparseMatrix.cc +++ b/mex/sources/bytecode/SparseMatrix.cc @@ -663,9 +663,9 @@ dynSparseMatrix::Simple_Init(int Size, map<pair<pair<int, int>, int>, int> &IM, FNZE_C = (NonZeroElem **) mxMalloc(i); test_mxMalloc(FNZE_C, __LINE__, __FILE__, __func__, i); NonZeroElem **temp_NZE_R = (NonZeroElem **) mxMalloc(i); - test_mxMalloc(*temp_NZE_R, __LINE__, __FILE__, __func__, i); + test_mxMalloc(temp_NZE_R, __LINE__, __FILE__, __func__, i); NonZeroElem **temp_NZE_C = (NonZeroElem **) mxMalloc(i); - test_mxMalloc(*temp_NZE_C, __LINE__, __FILE__, __func__, i); + test_mxMalloc(temp_NZE_C, __LINE__, __FILE__, __func__, i); i = Size*sizeof(int); NbNZRow = (int *) mxMalloc(i); test_mxMalloc(NbNZRow, __LINE__, __FILE__, __func__, i); @@ -1900,9 +1900,9 @@ dynSparseMatrix::Init_GE(int periods, int y_kmin, int y_kmax, int Size, map<pair FNZE_C = (NonZeroElem **) mxMalloc(i); test_mxMalloc(FNZE_C, __LINE__, __FILE__, __func__, i); NonZeroElem **temp_NZE_R = (NonZeroElem **) mxMalloc(i); - test_mxMalloc(*temp_NZE_R, __LINE__, __FILE__, __func__, i); + test_mxMalloc(temp_NZE_R, __LINE__, __FILE__, __func__, i); NonZeroElem **temp_NZE_C = (NonZeroElem **) mxMalloc(i); - test_mxMalloc(*temp_NZE_C, __LINE__, __FILE__, __func__, i); + test_mxMalloc(temp_NZE_C, __LINE__, __FILE__, __func__, i); i = (periods+y_kmax+1)*Size*sizeof(int); NbNZRow = (int *) mxMalloc(i); test_mxMalloc(NbNZRow, __LINE__, __FILE__, __func__, i); -- GitLab