Math.Rd
Applies the Math
group functions to spam
objects
# ceiling(x)
# floor(x)
# exp(x, base = exp(1))
# log(x, base = exp(1))
# sqrt(x)
# abs(x)
# cumprod(x)
# cumsum(x)
# cos(x)
# sin(x)
# tan(x)
# acosh(x)
spam object.
positive number. The base with respect to which logarithms
are computed. Defaults to e=exp(1)
.
If the option spam.structurebased=TRUE
, all functions operate on the vector x@entries
and return the
result thereof.
Conversely, if structurebased=FALSE
, the result is identical to
one with as.matrix(x)
input and an as.spam
purger.
It is important to note that the zero entries do not enter the
evaluation when structurebased=FALSE
. The operations are performed on the stored non-zero
elements. This may lead to differences if compared with the same
operation on a full matrix.
getGroupMembers("Math")
#> [1] "abs" "sign" "sqrt" "ceiling" "floor" "trunc"
#> [7] "cummax" "cummin" "cumprod" "cumsum" "exp" "expm1"
#> [13] "log" "log10" "log2" "log1p" "cos" "cosh"
#> [19] "sin" "sinh" "tan" "tanh" "acos" "acosh"
#> [25] "asin" "asinh" "atan" "atanh" "cospi" "sinpi"
#> [31] "tanpi" "gamma" "lgamma" "digamma" "trigamma"
mat <- matrix(c( 1,2,0,3,0,0,0,4,5),3)
smat <- as.spam( mat)
cos( mat)
#> [,1] [,2] [,3]
#> [1,] 0.5403023 -0.9899925 1.0000000
#> [2,] -0.4161468 1.0000000 -0.6536436
#> [3,] 1.0000000 1.0000000 0.2836622
cos( smat)
#> [,1] [,2] [,3]
#> [1,] 0.5403023 -0.9899925 0.0000000
#> [2,] -0.4161468 0.0000000 -0.6536436
#> [3,] 0.0000000 0.0000000 0.2836622
#> Class 'spam' (32-bit)
options(spam.structurebased=FALSE)
cos( smat)
#> [,1] [,2] [,3]
#> [1,] 0.5403023 -0.9899925 1.0000000
#> [2,] -0.4161468 1.0000000 -0.6536436
#> [3,] 1.0000000 1.0000000 0.2836622
#> Class 'spam' (32-bit)
sqrt( smat)
#> [,1] [,2] [,3]
#> [1,] 1.000000 1.732051 0.000000
#> [2,] 1.414214 0.000000 2.000000
#> [3,] 0.000000 0.000000 2.236068
#> Class 'spam' (32-bit)