From: Stéphane Mottelet Date: Tue, 9 Jun 2020 10:29:28 +0000 (+0200) Subject: * Bug 16463 fixed: now matrix(sparse([]),[0 0]) is empty sparse X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=f4d3c5ea17c8235f96fce1f844a597f0a229bd2b * Bug 16463 fixed: now matrix(sparse([]),[0 0]) is empty sparse http://bugzilla.scilab.org/show_bug.cgi?id=16463 test_run elementary_functions bug_16463 mode_nwni_profiling Change-Id: I9b985f44868743aa41bcb38ad25b43e02a1d2ed5 --- diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index e62ba83..f015e36 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -545,3 +545,4 @@ Bug Fixes * [#16333](https://bugzilla.scilab.org/16333): `tree_show` crashed for an input Xcos block. * [#16373](https://bugzilla.scilab.org/16373): Scilab Crashed or showing wrong output when running on Arm processor * [#16459](https://bugzilla.scilab.org/16459): The display of one column hypermatrix was wrong. +* [#16463](https://bugzilla.scilab.org/16463): `matrix(sparse([]),[0 0])` yielded `[]` instead of `sparse([])`. \ No newline at end of file diff --git a/scilab/modules/elementary_functions/sci_gateway/cpp/sci_matrix.cpp b/scilab/modules/elementary_functions/sci_gateway/cpp/sci_matrix.cpp index 52d51c3..5b9b9eb 100644 --- a/scilab/modules/elementary_functions/sci_gateway/cpp/sci_matrix.cpp +++ b/scilab/modules/elementary_functions/sci_gateway/cpp/sci_matrix.cpp @@ -52,8 +52,8 @@ types::Function::ReturnValue sci_matrix(types::typed_list &in, int _iRetCount, t } if (in[0]->isArrayOf() == false && - in[0]->isSparse() == false && - in[0]->isSparseBool() == false) + in[0]->isSparse() == false && + in[0]->isSparseBool() == false) { std::wstring wstFuncName = L"%" + in[0]->getShortTypeStr() + L"_matrix"; return Overload::call(wstFuncName, in, _iRetCount, out); @@ -62,19 +62,7 @@ types::Function::ReturnValue sci_matrix(types::typed_list &in, int _iRetCount, t pGTIn = in[0]->getAs(); if (pGTIn->getSize() == 0) { - if (pGTIn->isStruct()) - { - out.push_back(new types::Struct()); - } - else if (pGTIn->isCell()) - { - out.push_back(new types::Cell()); - } - else - { - out.push_back(types::Double::Empty()); - } - + out.push_back(pGTIn->clone()); return types::Function::OK; } diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_16463.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_16463.tst new file mode 100644 index 0000000..fac08d0 --- /dev/null +++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_16463.tst @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2020 - Stéphane MOTTELET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// <-- NO CHECK REF --> +// +// <-- Non-regression test for bug 16463 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/16463 +// +// <-- Short Description --> +// matrix(sparse([]), [0 0]) returns [] instead of sparse([]) + +ef = []; +esp = sparse([]); +espb = (esp>0)([]); + +assert_checkequal(matrix(ef, [0 0]),ef); +assert_checkequal(matrix(esp, [0 0]),esp); +assert_checkequal(matrix(espb, [0 0]),espb);