RobinHankin / spray

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

subs() should take a drop argument #14

Closed RobinHankin closed 1 month ago

RobinHankin commented 4 years ago
> jj <- spray(diag(5),1:5)
> subs(jj,1:5,1:5)
     val
  =   55
> subs(jj,1:5,1:5,drop=TRUE)
Error in subs(jj, 1:5, 1:5, drop = TRUE) : unused argument (drop = TRUE)

The substitution gives a constant polynomial and one might wish to reduce this to a double. And passing subs() ought to do this, but doesn't.

RobinHankin commented 1 month ago

Functionality now in place as per 3597866:

library("spray")
#> 
#> Attaching package: 'spray'
#> The following objects are masked from 'package:base':
#> 
#>     pmax, pmin
(jj <- spray(diag(5),1:5))
#>                val
#>  0 0 0 0 1  =    5
#>  0 0 0 1 0  =    4
#>  0 0 1 0 0  =    3
#>  0 1 0 0 0  =    2
#>  1 0 0 0 0  =    1
subs(jj,1:5,1:5)
#> [1] 55
subs(jj,1:5,1:5,drop=TRUE)
#> [1] 55
subs(jj,1:5,1:5,drop=FALSE)
#>      val
#>   =   55