BUG DESCRIPTION:----------------In dense encoding, min and max accept to input a list of arrays mixed with scalars, as in--> m = grand(3, 4, "uin", 0, 10) m = 2. 4. 9. 4. 4. 1. 2. 6. 2. 3. 5. 8.--> min(m, 5) // <<<< here ans = 2. 4. 5. 4. 4. 1. 2. 5. 2. 3. 5. 5.This is not the case with sparse vectors. This limitation is not documented:--> min(sparse([1 2 3]),5)at line 119 of function %sp_min ( SCI\modules\elementary_functions\macros\%sp_min.sci line 131 )in builtin min %sp_min: Wrong type for input argument #2: A sparse matrix expected.Discussion: If the scalar is strictly negative and min() is used and applied to all elements including all implicit zeros, the resulting matrix will no longer have any zero elements and will most often become giant.If such an operation is required, the user can convert the input in dense format before applying min().The same will occur with max() and any strictly positive scalar mixed with some sparse matrices in input.This is why we propose to implement this feature for sparse but just applying min() (or max()) to non-zero elements.ERROR LOG:----------See aboveHOW TO REPRODUCE THE BUG:-------------------------min(sparse([1 2 3]),5)
Designs
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related or that one is blocking others.
Learn more.
only positions of zeros in the first array must be ignored ?
then, how to build and update the matrix of indices? Should it be updated for all elements when a next array is met, but only for non-zero positions when a scalar input is met?... Finally, it will turn hard to interpret and used.
So, i am not sure that implementing this is so relevant.
At least, this limitation deserves being documented.
Or the implementation could accept only positive scalars for min(), and only negative one for max().
This looks the right and most (and likely only) useful way. Hence, for instance, setting all negative values to 0 will be done with
max(Sparse,0)
Then, returned indices will be always relevant.