Closed divjakm closed 2 months ago
This behavior is not a bug but the documentation is incomplete. It is by design that the zero value is controlled by the sparsity parameter. See the implementation in RandMatrix.h. In line 129-130 there is a loop that runs until a non zero is found. Only after the matrix has been filled with values, the zeros are added according to the defined sparsity. The behavior is inverted for sparsity values < 0.5 (then we initialize to zero and add non-zero values). I'll update the documentation to reflect this behavior.
I noticed that the DaphneDSL inbuilt function
rand
has a small bug: the documentation says that both min and max range limits are inclusive, but if value 0 is used as the min limit, it is never present in the output. Other min limits except 0 work as intended.For example:
Example code:
print (rand(5, 5, 0, 1, 1, -1));