summaryrefslogtreecommitdiffstats
path: root/scilab
diff options
context:
space:
mode:
authorSamuel GOUGEON <sgougeon@free.fr>2021-01-01 15:43:09 +0100
committerClément David <clement.david@esi-group.com>2021-02-18 18:53:10 +0100
commit8c8ebb886cee8ae01d43cef04385677df9519ad9 (patch)
treeeb897e6d800b8da205711c4a381e0f6bb99320fa /scilab
parentc79031ff5be0fe30a657060807cbce6706e2cbec (diff)
downloadscilab-8c8ebb886cee8ae01d43cef04385677df9519ad9.zip
scilab-8c8ebb886cee8ae01d43cef04385677df9519ad9.tar.gz
* Bug 16622 fixed: inv() now overloadable for hypermat of doubles
http://bugzilla.scilab.org/16622 Test: inv(rand(2,2,2)) should display: Function not defined for given argument type(s), check arguments or define function %s_inv for overloading. Change-Id: I81284ea373149add6d6c55f3522c556a24f0c55a
Diffstat (limited to 'scilab')
-rw-r--r--scilab/CHANGES.md1
-rw-r--r--scilab/modules/linear_algebra/sci_gateway/cpp/sci_inv.cpp18
2 files changed, 16 insertions, 3 deletions
diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md
index 506007d..4387dc4 100644
--- a/scilab/CHANGES.md
+++ b/scilab/CHANGES.md
@@ -353,6 +353,7 @@ Bug Fixes
353* [#16553](https://bugzilla.scilab.org/16553): `unique(["" ""])` returned `["" ""]`. 353* [#16553](https://bugzilla.scilab.org/16553): `unique(["" ""])` returned `["" ""]`.
354* [#16557](https://bugzilla.scilab.org/16557): `macr2tree` + `tree2code` translated `e={2}` into `"e=1"` and `e={2,"ab"}` into `"e=[2,"ab"]"`. 354* [#16557](https://bugzilla.scilab.org/16557): `macr2tree` + `tree2code` translated `e={2}` into `"e=1"` and `e={2,"ab"}` into `"e=[2,"ab"]"`.
355* [#16559](https://bugzilla.scilab.org/16553): `isempty(A)` was true for sparse matrix of dimension 2^16 or larger. 355* [#16559](https://bugzilla.scilab.org/16553): `isempty(A)` was true for sparse matrix of dimension 2^16 or larger.
356* [#16622](https://bugzilla.scilab.org/16622): `inv` could no longer be overloaded for hypermatrices of decimal or complex numbers.
356* [#16623](https://bugzilla.scilab.org/16623): `rand(2,2,2)^2` yielded a wrong result instead of trying to call the `%s_p_s` overload for input hypermatrices. 357* [#16623](https://bugzilla.scilab.org/16623): `rand(2,2,2)^2` yielded a wrong result instead of trying to call the `%s_p_s` overload for input hypermatrices.
357* [#16644](https://bugzilla.scilab.org/16644): `input("message:")` yielded a wrong error message about `mprintf` in case of non-interpretable input. 358* [#16644](https://bugzilla.scilab.org/16644): `input("message:")` yielded a wrong error message about `mprintf` in case of non-interpretable input.
358 359
diff --git a/scilab/modules/linear_algebra/sci_gateway/cpp/sci_inv.cpp b/scilab/modules/linear_algebra/sci_gateway/cpp/sci_inv.cpp
index e86c699..c7c1cc3 100644
--- a/scilab/modules/linear_algebra/sci_gateway/cpp/sci_inv.cpp
+++ b/scilab/modules/linear_algebra/sci_gateway/cpp/sci_inv.cpp
@@ -37,7 +37,7 @@ types::Function::ReturnValue sci_inv(types::typed_list &in, int _iRetCount, type
37 double* pData = NULL; 37 double* pData = NULL;
38 int ret = 0; 38 int ret = 0;
39 39
40 if (in.size() != 1) 40 if (in.size() < 1)
41 { 41 {
42 Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "inv", 1); 42 Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "inv", 1);
43 return types::Function::Error; 43 return types::Function::Error;
@@ -51,9 +51,15 @@ types::Function::ReturnValue sci_inv(types::typed_list &in, int _iRetCount, type
51 51
52 pDbl = in[0]->getAs<types::Double>()->clone()->getAs<types::Double>(); // input data will be modified 52 pDbl = in[0]->getAs<types::Double>()->clone()->getAs<types::Double>(); // input data will be modified
53 53
54 if (pDbl->getRows() != pDbl->getCols()) 54 if (pDbl->getDims() > 2)
55 {
56 std::wstring wstFuncName = L"%s_inv";
57 return Overload::call(wstFuncName, in, _iRetCount, out);
58 }
59
60 if (in.size() > 1)
55 { 61 {
56 Scierror(20, _("%s: Wrong type for argument %d: Square matrix expected.\n"), "inv", 1); 62 Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "inv", 1);
57 return types::Function::Error; 63 return types::Function::Error;
58 } 64 }
59 65
@@ -63,6 +69,12 @@ types::Function::ReturnValue sci_inv(types::typed_list &in, int _iRetCount, type
63 return types::Function::OK; 69 return types::Function::OK;
64 } 70 }
65 71
72 if (pDbl->getRows() != pDbl->getCols())
73 {
74 Scierror(20, _("%s: Argument %d: Square matrix expected. Please use pinv() otherwise.\n"), "inv", 1);
75 return types::Function::Error;
76 }
77
66 if (pDbl->isComplex()) 78 if (pDbl->isComplex())
67 { 79 {
68 /* c -> z */ 80 /* c -> z */