Get or set the constant term of a spray object
constant.Rd
The constant term of a spray object is the coefficient corresponding to an index of all zeros. These functions get or set the constant of a spray object.
Value
In function constant()
, return the coefficient, or a constant
multivariate polynomial, depending on the value of drop
.
Note
The behaviour of the drop
argument (sort of) matches that of the
spray extractor method. Function drop()
returns the elements of
the coefficients.
Function constant()
ensures that zero spray objects retain the
argument's arity.
It might have been better to call is.constant()
is.scalar()
, for consistency with the stokes
and
clifford
packages. But this is not clear.
Examples
(S <- spray(partitions::blockparts(rep(2,3),3,TRUE)))
#> val
#> 0 1 2 = 1
#> 1 0 2 = 1
#> 0 0 2 = 1
#> 0 2 1 = 1
#> 2 0 0 = 1
#> 0 2 0 = 1
#> 0 0 1 = 1
#> 0 0 0 = 1
#> 1 1 0 = 1
#> 2 1 0 = 1
#> 1 2 0 = 1
#> 1 0 1 = 1
#> 0 1 0 = 1
#> 2 0 1 = 1
#> 0 1 1 = 1
#> 1 0 0 = 1
#> 1 1 1 = 1
constant(S)
#> val
#> 0 0 0 = 1
constant(S) <- 33
S
#> val
#> 1 1 0 = 1
#> 0 0 0 = 33
#> 0 1 0 = 1
#> 2 0 1 = 1
#> 1 1 1 = 1
#> 1 0 0 = 1
#> 0 1 2 = 1
#> 2 0 0 = 1
#> 0 1 1 = 1
#> 1 0 2 = 1
#> 0 0 2 = 1
#> 2 1 0 = 1
#> 0 2 1 = 1
#> 1 2 0 = 1
#> 1 0 1 = 1
#> 0 2 0 = 1
#> 0 0 1 = 1
drop(constant(S,drop=FALSE))
#> [1] 33