Create a sparse with null size should return an empty matrix. 30/11430/2
Cedric Delamarre [Tue, 30 Apr 2013 13:34:28 +0000 (15:34 +0200)]
s=sprand(0,0,0.01);
assert_checkequal ( s , [] );
sp=sparse([],[],[5 9]) // should be an empty sparse of size [5 9]

Change-Id: I9e16f7c5fb53b965c9cd867715881ddbb52e8b72

scilab/modules/sparse/sci_gateway/cpp/sci_sparse.cpp

index 16870d5..d7b2a58 100644 (file)
@@ -187,6 +187,12 @@ Function::ReturnValue sci_sparse(typed_list &in, int _piRetCount, typed_list &ou
                 Scierror(999, _("%s: Wrong size for input argument #%d: A matrix of size %d x %d expected.\n"), "sparse", 3, 1, 2);
                 return Function::Error;
             }
+
+            if (pDims->get(0) * pDims->get(1) == 0)
+            {
+                out.push_back(types::Double::Empty());
+                return types::Function::OK;
+            }
         }
 
         types::GenericType* pGT1 = in[0]->getAs<types::GenericType>();