summaryrefslogtreecommitdiffstats
path: root/scilab
diff options
context:
space:
mode:
authormottelet <stephane.mottelet@utc.fr>2020-07-01 16:12:34 +0200
committerCédric DELAMARRE <cdl@esi-group.com>2020-10-16 10:22:43 +0200
commit0f0fa3c20d2161ad432e7ca0264a63c78ca6d2f3 (patch)
tree9278abcf1dca737d7d125115c050689c05b4dc0f /scilab
parent06d3e18eff3c252cdb7db523141bcfcc41df4536 (diff)
downloadscilab-0f0fa3c20d2161ad432e7ca0264a63c78ca6d2f3.zip
scilab-0f0fa3c20d2161ad432e7ca0264a63c78ca6d2f3.tar.gz
* Bug 16362 fixed: now sparse([]) can be concatenated
http://bugzilla.scilab.org/show_bug.cgi?id=16362 Change-Id: Iac41cef877b114d9b6c24d344c0e09f4fa58acfd
Diffstat (limited to 'scilab')
-rw-r--r--scilab/CHANGES.md1
-rw-r--r--scilab/modules/ast/src/cpp/ast/run_MatrixExp.hpp8
-rw-r--r--scilab/modules/ast/tests/nonreg_tests/bug_16362.tst31
3 files changed, 36 insertions, 4 deletions
diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md
index af6e926..b1c467b 100644
--- a/scilab/CHANGES.md
+++ b/scilab/CHANGES.md
@@ -308,6 +308,7 @@ Bug Fixes
308* [#16342](https://bugzilla.scilab.org/16342): `strcat()` was much slower in Scilab 6.0.2. 308* [#16342](https://bugzilla.scilab.org/16342): `strcat()` was much slower in Scilab 6.0.2.
309* [#16350](https://bugzilla.scilab.org/16350): in if/while conditions, the empty sparse boolean was considered as TRUE. 309* [#16350](https://bugzilla.scilab.org/16350): in if/while conditions, the empty sparse boolean was considered as TRUE.
310* [#16358](https://bugzilla.scilab.org/16358): `isdef([],..)` yielded an error instead of returning []. 310* [#16358](https://bugzilla.scilab.org/16358): `isdef([],..)` yielded an error instead of returning [].
311* [#16362](https://bugzilla.scilab.org/16362): sparse empty matrix could no be concatenated.
311* [#16365](https://bugzilla.scilab.org/16365): `median(m,"r")` and `median(m,"c")` yielded wrong results (6.1.0 regression) 312* [#16365](https://bugzilla.scilab.org/16365): `median(m,"r")` and `median(m,"c")` yielded wrong results (6.1.0 regression)
312* [#16366](https://bugzilla.scilab.org/16366): `plot([0 1], ":")` plotted a dash-dotted curve instead of a dotted one. 313* [#16366](https://bugzilla.scilab.org/16366): `plot([0 1], ":")` plotted a dash-dotted curve instead of a dotted one.
313* [#16369](https://bugzilla.scilab.org/16369): Right divisions / involving one or two sparse numerical matrices were no longer supported. 314* [#16369](https://bugzilla.scilab.org/16369): Right divisions / involving one or two sparse numerical matrices were no longer supported.
diff --git a/scilab/modules/ast/src/cpp/ast/run_MatrixExp.hpp b/scilab/modules/ast/src/cpp/ast/run_MatrixExp.hpp
index 1babc57..8d5eacd 100644
--- a/scilab/modules/ast/src/cpp/ast/run_MatrixExp.hpp
+++ b/scilab/modules/ast/src/cpp/ast/run_MatrixExp.hpp
@@ -215,7 +215,7 @@ void RunVisitorT<T>::visitprivate(const MatrixExp &e)
215 types::GenericType* pGTResult = poRow->getAs<types::GenericType>(); 215 types::GenericType* pGTResult = poRow->getAs<types::GenericType>();
216 216
217 //check dimension 217 //check dimension
218 if (pGT->getDims() != 2 || pGT->getRows() != pGTResult->getRows()) 218 if (pGT->getDims() != 2 || ( (pGT->getRows() != pGTResult->getRows()) && pGT->getRows() != 0 && pGTResult->getRows() != 0) )
219 { 219 {
220 poRow->killMe(); 220 poRow->killMe();
221 if (poRow != pGT) 221 if (poRow != pGT)
@@ -274,7 +274,7 @@ void RunVisitorT<T>::visitprivate(const MatrixExp &e)
274 delete[] piRank; 274 delete[] piRank;
275 } 275 }
276 276
277 types::InternalType *pNewSize = AddElementToVariable(NULL, poRow, pGTResult->getRows(), pGTResult->getCols() + pGT->getCols()); 277 types::InternalType *pNewSize = AddElementToVariable(NULL, poRow, std::max(pGTResult->getRows(),pGT->getRows()), pGTResult->getCols() + pGT->getCols());
278 types::InternalType* p = AddElementToVariable(pNewSize, pGT, 0, pGTResult->getCols()); 278 types::InternalType* p = AddElementToVariable(pNewSize, pGT, 0, pGTResult->getCols());
279 if (p != pNewSize) 279 if (p != pNewSize)
280 { 280 {
@@ -363,7 +363,7 @@ void RunVisitorT<T>::visitprivate(const MatrixExp &e)
363 } 363 }
364 364
365 //check dimension 365 //check dimension
366 if (pGT->getCols() != pGTResult->getCols()) 366 if ((pGT->getCols() != pGTResult->getCols()) && pGT->getCols() != 0 && pGTResult->getCols() != 0)
367 { 367 {
368 poRow->killMe(); 368 poRow->killMe();
369 if (poResult) 369 if (poResult)
@@ -390,7 +390,7 @@ void RunVisitorT<T>::visitprivate(const MatrixExp &e)
390 pGTResult = poResult->getAs<types::GenericType>(); 390 pGTResult = poResult->getAs<types::GenericType>();
391 } 391 }
392 392
393 types::InternalType* pNewSize = AddElementToVariable(NULL, poResult, pGTResult->getRows() + pGT->getRows(), pGT->getCols()); 393 types::InternalType* pNewSize = AddElementToVariable(NULL, poResult, pGTResult->getRows() + pGT->getRows(), std::max(pGT->getCols(),pGTResult->getCols()));
394 types::InternalType* p = AddElementToVariable(pNewSize, pGT, pGTResult->getRows(), 0); 394 types::InternalType* p = AddElementToVariable(pNewSize, pGT, pGTResult->getRows(), 0);
395 if (p != pNewSize) 395 if (p != pNewSize)
396 { 396 {
diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_16362.tst b/scilab/modules/ast/tests/nonreg_tests/bug_16362.tst
new file mode 100644
index 0000000..08c9a0e
--- /dev/null
+++ b/scilab/modules/ast/tests/nonreg_tests/bug_16362.tst
@@ -0,0 +1,31 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2020 - Stéphane MOTTELET
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7//
8// <-- CLI SHELL MODE -->
9// <-- NO CHECK REF -->
10//
11// <-- Non-regression test for bug 16362 -->
12//
13// <-- Bugzilla URL -->
14// http://bugzilla.scilab.org/16362
15//
16// <-- Short Description -->
17// sparse([]) can no longer be concatenated
18
19esp = sparse([]);
20a = [1 2;3 4];
21asp = sparse(a);
22
23assert_checkequal([a, esp], asp);
24assert_checkequal([esp, a], asp);
25assert_checkequal([a; esp], asp);
26assert_checkequal([esp; a], asp);
27
28assert_checkequal([asp, esp], asp);
29assert_checkequal([esp, asp], asp);
30assert_checkequal([asp; esp], asp);
31assert_checkequal([esp; asp], asp); \ No newline at end of file