RobinHankin / spray

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

different types of empty spray object #25

Closed RobinHankin closed 2 years ago

RobinHankin commented 2 years ago

Look:

> x1 <- subs(homog(3,3),1:3,2)
> x2 <- spray(matrix(0,1,3),7)
> x3 <- spray(matrix(0,1,3),0)
> x4 <- spray(matrix(0,0,2),1)
> x1
     val
  =   80
> x2
           val
 0 0 0  =    7
> x3
empty sparse array with  columns
> x4
empty sparse array with 2 columns
> 
> dput(x1)
structure(list(index = structure(integer(0), .Dim = 1:0), value = 80), class = "spray")
> dput(x2)
structure(list(index = structure(c(0L, 0L, 0L), .Dim = c(1L, 
3L)), value = 7), class = "spray")
> dput(x3)
structure(list(index = NULL, value = NULL), class = "spray")
> dput(x4)
structure(list(structure(numeric(0), .Dim = c(0L, 2L)), numeric(0)), class = "spray")
> 

The differences between x1, x2, x3, x4 are not really documented. There is a little bit at zero.Rd, and a very brief discussion in the vignette, but not much.

RobinHankin commented 2 years ago

Also constant() can return the NULL form:

> constant(homog(4))
empty sparse array with  columns
> dput(constant(homog(4)))
structure(list(index = NULL, value = NULL), class = "spray")
> 

This is causing problems in the weyl repo at https://github.com/RobinHankin/weyl/issues/5

RobinHankin commented 2 years ago

Also causing problems in the stokes package, issue #68

RobinHankin commented 2 years ago

Fixed in def2c2624ea7190679c50658d6aaffdc8b3079fd