Ops.spray | R Documentation |
Allows arithmetic operators to be used for spray calculations, such as addition, multiplication, division, integer powers, etc. Objects of class spray are interpreted as sparse multivariate polynomials.
## S3 method for class 'spray'
Ops(e1, e2 = NULL)
spray_negative(S)
spray_times_spray(S1,S2)
spray_times_scalar(S,x)
spray_plus_spray(S1,S2)
spray_plus_scalar(S,x)
spray_power_scalar(S,n)
spray_power_scalar_stla(S,n)
spray_eq_spray(S1,S2)
spray_eq_numeric(S1,x)
e1 , e2 , S , S1 , S2 |
Objects of class spray, here interpreted as sparse multivariate polynomials |
x |
Real valued scalar |
n |
Non-negative integer |
The function Ops.spray()
passes unary and binary arithmetic
operators (“+
”, “-
”, “*
”,
“/
”,“==
”, and “^
”) to the
appropriate specialist function.
The most interesting operators are “*
” and
“+
” which execute multivariate polynomial multiplication
and addition respectively.
Testing for equality uses spray_eq_spray()
. Note that
spray_eq_spray(S1,S2)
is algebraically equivalent to
is.zero(S1-S2)
, but faster (FALSE
is returned as soon as
a mismatch is found).
Function spray_power_scalar()
is the functional representation
for powers: spray_power_scalar(X,n)
is the same as X^n
.
Function spray_power_scalar_stla()
is an experimental
replacement for spray_power_scalar()
that may offer speed
advantages.
The functions all return spray objects except “==
”, which
returns a logical.
Robin K. S. Hankin
ooom
M <- matrix(sample(0:3,21,replace=TRUE),ncol=3)
a <- spray(M,sample(7))
b <- homog(3,4)
# arithmetic operators mostly work as expected:
a + 2*b
a - a*b^2/4
a+b
S1 <- spray(partitions::compositions(4,3))
S2 <- spray(diag(3)) # S2 = x+y+z
stopifnot( (S1+S2)^3 == S1^3 + 3*S1^2*S2 + 3*S1*S2^2 + S2^3 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.