RobinHankin / spray

sparse arrays and fast multivariate polynomials
https://robinhankin.github.io/spray/
2 stars 2 forks source link

empty spray objects lose dimensionality #4

Closed RobinHankin closed 3 years ago

RobinHankin commented 5 years ago

If spray() is passed a zero-row index matrix, the return value does not remember the dimensionality of the input:

> dput(spray(matrix(0,1,5),0))
structure(list(index = NULL, value = NULL), class = "spray")

Here, I would like the output to include the fact that we are dealing with a 5-dimensional array; but the index matrix is NULL so this information is lost (note that the value is NULL too)

RobinHankin commented 3 years ago

But observe that the following works:

> a1 <- spray(matrix(0,1,5),0)
> a2 <- spray(t(1:5))
> a1+a2
               val
 1 2 3 4 5  =    1
>