SparseArray-Math-methods | R Documentation |
SparseArray derivatives support a subset of operations
from the Math
and Math2
groups.
See ?S4groupGeneric
in the methods package
for more information about the Math
and Math2
group generics.
IMPORTANT NOTES:
Only operations from these groups that preserve sparsity are
supported. For example, sqrt()
, trunc()
,
log1p()
, and sin()
are supported, but cumsum()
,
log()
, cos()
, or gamma()
are not.
Only SVT_SparseArray objects are supported at the moment. Support for COO_SparseArray objects might be added in the future.
Math
and Math2
operations only support
SVT_SparseArray objects of type()
"double"
at the moment.
A SparseArray derivative of the same dimensions as the input object.
S4groupGeneric
in the methods package.
SparseArray objects.
Ordinary array objects in base R.
m <- matrix(0, nrow=15, ncol=6)
m[c(2, 6, 12:17, 22:33, 55, 59:62, 90)] <-
c(runif(22)*1e4, Inf, -Inf, NA, NaN)
svt <- SparseArray(m)
svt2 <- trunc(sqrt(svt))
svt2
## Sanity check:
m2 <- suppressWarnings(trunc(sqrt(m)))
stopifnot(identical(as.matrix(svt2), m2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.