* [#15451](http://bugzilla.scilab.org/show_bug.cgi?id=15451): The code was not adapted to use `lucene 4.10` in Debian.
* [#15523](http://bugzilla.scilab.org/show_bug.cgi?id=15523): `%ODEOPTIONS(1)=2` didn't work with solvers 'rk' and 'rkf'
* [#15577](http://bugzilla.scilab.org/show_bug.cgi?id=15577): `edit` did not accept a line number as text, as with `edit linspace 21`.
+* [#15580](http://bugzilla.scilab.org/show_bug.cgi?id=15580): `det(sparse([],[]))` yielded an error.
* [#15668](http://bugzilla.scilab.org/show_bug.cgi?id=15668): `save(filename)` saved all predefined Scilab constants %e %pi etc.. (regression)
* [#15715](http://bugzilla.scilab.org/show_bug.cgi?id=15715): `%nan` indices crashed Scilab.
* [#15742](http://bugzilla.scilab.org/show_bug.cgi?id=15742): The `compatibility_functions` module should be merged in the `m2sci` one.
*/
/*--------------------------------------------------------------------------*/
-#include "linear_algebra_gw.hxx"
-#include "function.hxx"
#include "double.hxx"
+#include "function.hxx"
+#include "linear_algebra_gw.hxx"
#include "overload.hxx"
extern "C"
{
-#include "localization.h"
#include "Scierror.h"
#include "det.h"
#include "doublecomplex.h"
+#include "localization.h"
}
/*--------------------------------------------------------------------------*/
-types::Function::ReturnValue sci_det(types::typed_list &in, int _iRetCount, types::typed_list &out)
+types::Function::ReturnValue sci_det(types::typed_list& in, int _iRetCount, types::typed_list& out)
{
- types::Double* pDbl = NULL;
- types::Double* pDblMantissa = NULL;
- types::Double* pDblExponent = NULL;
- double* pData = NULL;
+ types::Double* pDbl = NULL;
+ types::Double* pDblE = NULL;
+ types::Double* pDblMantissa = NULL;
+ types::Double* pDblExponent = NULL;
+ double* pData = NULL;
if (in.size() != 1)
{
if (pDbl->isComplex())
{
- pData = (double *)oGetDoubleComplexFromPointer(pDbl->getReal(), pDbl->getImg(), pDbl->getSize());
+ pData = (double*)oGetDoubleComplexFromPointer(pDbl->getReal(), pDbl->getImg(), pDbl->getSize());
if (!pData)
{
Scierror(999, _("%s: Cannot allocate more memory.\n"), "det");
return types::Function::Error;
}
- if ((pDbl->getRows() == -1)) // manage eye case
+ if (pDbl->isEmpty())
+ {
+ out.push_back(new types::Double(1));
+ return types::Function::OK;
+ }
+
+ if (pDbl->getRows() == -1) // manage eye case
{
Scierror(271, _("%s: Size varying argument a*eye(), (arg %d) not allowed here.\n"), "det", 1);
return types::Function::Error;
{
Scierror(999, _("%s: LAPACK error n°%d.\n"), "det", iRet);
pDblMantissa->killMe();
- if( pDblExponent )
+ if (pDblExponent)
{
pDblExponent->killMe();
}
return types::Function::OK;
}
/*--------------------------------------------------------------------------*/
-
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+//
+// <-- Non-regression test for bug 15580 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/15580
+//
+// <-- Short Description -->
+// [det([]) was wrong and ] det(sparse([],[]) yielded an error
+
+esp = sparse([],[]);
+assert_checkequal(det(esp),1);
+[e,m]= det(esp);
+assert_checkequal([e m], [0 1]);
+
+assert_checkequal(det([]), 1);
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
-//
// Copyright (C) 2012 - 2016 - Scilab Enterprises
//
// This file is hereby licensed under the terms of the GNU GPL v2.0,
// For more information, see the COPYING file which you should have received
// along with this program.
-function [res1, res2]=%sp_det(A)
- [lhs, rhs]=argn(0);
+function [res1, res2] = %sp_det(A)
+ [lhs, rhs] = argn(0);
+ if length(A)==0 then
+ [res1, res2] = (1,1);
+ if lhs>1
+ res1 = 0
+ end
+ return
+ end
hand = umf_lufact(A); //umfpack is used for complex sparse matrix
[L,U,P,Q,r] = umf_luget(hand);
- res1=prod(r)*prod(diag(U));
- res2=res1;
+ res1 = prod(r)*prod(diag(U));
+ res2 = res1;
if (lhs == 2) then
- res1=0;
+ res1 = 0;
while abs(res2) >= 10
if abs(res2) < 1 then
break;