* [#16144](http://bugzilla.scilab.org/show_bug.cgi?id=16144): Addition of sparse matrices gave incorrect results.
* [#16152](http://bugzilla.scilab.org/show_bug.cgi?id=16152): For sparse or boolean sparse matrix `s`, `s([])` returned `[]` instead of `sparse([])`.
* [#16158](http://bugzilla.scilab.org/show_bug.cgi?id=16158): When a multicolumn array of rationals was displayed wide column per column, columns #2:$ were replaced with its column #2.
+* [#16160](http://bugzilla.scilab.org/show_bug.cgi?id=16160): `ppol` changed values of third input variable.
* [#16164](http://bugzilla.scilab.org/show_bug.cgi?id=16164): Help pages in elementary_functions/signal_processing were mislocated.
* [#16174](http://bugzilla.scilab.org/show_bug.cgi?id=16174): `libraryinfo` yielded 0x0 matrix of strings for libs without macro
* [#16200](http://bugzilla.scilab.org/show_bug.cgi?id=16200): Concatenation of transposed cells crashed Scilab.
* [#16272](http://bugzilla.scilab.org/show_bug.cgi?id=16272): `spzeros(0,n)` and `spzeros(n,0)` were different from `sparse(0,0)`.
* [#16275](http://bugzilla.scilab.org/show_bug.cgi?id=16275): `fsolve(x0, fun, tol)` no longer took `tol` into account.
* [#16293](http://bugzilla.scilab.org/show_bug.cgi?id=16293): Some demos run in step-by-step console mode(4) did not focus user's attention to the console to proceed.
-
int iSizeP = 0;
int iColB = 0;
- bool isDeletable = false;
-
if (in.size() != 3)
{
Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "ppol", 3);
return types::Function::Error;
}
- pDblB = in[1]->clone()->getAs<types::Double>();
+ pDblB = in[1]->getAs<types::Double>();
if (pDblB->isComplex())
{
return types::Function::Error;
}
- pDblA = in[0]->clone()->getAs<types::Double>();
+ pDblA = in[0]->getAs<types::Double>();
if (pDblA->isComplex())
{
}
/*** perform operations ***/
+
+ pDblA = pDblA->clone();
+ pDblB = pDblB->clone();
+ pDblP = pDblP->clone();
+ pDblP->setComplex(true);
+
types::Double* pDblOut = new types::Double(iColB, iSizeP);
double* pdblG = pDblOut->get();
int* piW = new int[iSizeP];
double* pdblPReal = pDblP->get();
- double* pdblPImg = NULL;
- if (pDblP->isComplex())
- {
- pdblPImg = pDblP->getImg();
- }
- else
- {
- pdblPImg = new double[iSizeP];
- memset(pdblPImg, 0x00, iSizeP * sizeof(double));
- isDeletable = true;
- }
+ double* pdblPImg = pDblP->getImg();
int idc = 0;
int inc = 0;
delete[] pdblZ;
delete[] pdblW;
delete[] piW;
- if (isDeletable)
- {
- delete[] pdblPImg;
- }
- delete pDblA;
- delete pDblB;
+ pDblA->killMe();
+ pDblB->killMe();
+ pDblP->killMe();
pDblOut->killMe();
return types::Function::Error;
}
C2F(polmc)( &iSizeP, &iColB, &iSizeP, &iColB, pDblA->get(), pDblB->get(), pdblG, pdblPReal, pdblPImg,
pdblZ, &inc, piW, &iErr, pdblW, pdblW + iColB, pdblW1, pdblW2, pdblW3, pdblW4, pdblW5);
- if (iErr)
- {
- Scierror(999, _("%s: Uncontrollable system.\n"), "ppol");
- delete[] pdblZ;
- delete[] pdblW;
- delete[] piW;
- if (isDeletable)
- {
- delete[] pdblPImg;
- }
- delete pDblA;
- delete pDblB;
- pDblOut->killMe();
- return types::Function::Error;
- }
-
// free memory
delete[] pdblZ;
delete[] pdblW;
delete[] piW;
- if (isDeletable)
+ pDblA->killMe();
+ pDblB->killMe();
+ pDblP->killMe();
+
+ if (iErr)
{
- delete[] pdblPImg;
+ Scierror(999, _("%s: Uncontrollable system.\n"), "ppol");
+ pDblOut->killMe();
+ return types::Function::Error;
}
- delete pDblA;
- delete pDblB;
- /*** retrun output arguments ***/
+ /*** return output arguments ***/
out.push_back(pDblOut);
return types::Function::OK;
}
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - 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 16160 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/16160
+//
+// <-- Short Description -->
+// ppol changes values of third input variable
+
+
+A=rand(6,6);
+B=rand(6,1);
+p=[1+%i*0.5 1-%i*0.5 3 -1+%i*0.5 -1-%i*0.5 5];
+K=ppol(A,B,p);
+assert_checkequal(p,[1+%i*0.5 1-%i*0.5 3 -1+%i*0.5 -1-%i*0.5 5]);
\ No newline at end of file