Matrix and arithmetic operations for big.matrix objects
Source:R/bigmatrix-operations.R
bigmatrix-operations.RdThese methods extend the base matrix multiplication operator
(%*%) and the group generic Arithmetic so
that big.matrix objects can interoperate with base
R matrices and numeric scalars using the high-performance routines provided
by bigalgebra.
Usage
# S4 method for class 'big.matrix,big.matrix'
x %*% y
# S4 method for class 'matrix,big.matrix'
x %*% y
# S4 method for class 'big.matrix,matrix'
x %*% y
# S4 method for class 'big.matrix,big.matrix'
Arith(e1, e2)
# S4 method for class 'big.matrix,matrix'
Arith(e1, e2)
# S4 method for class 'matrix,big.matrix'
Arith(e1, e2)
# S4 method for class 'numeric,big.matrix'
Arith(e1, e2)
# S4 method for class 'big.matrix,numeric'
Arith(e1, e2)Details
Matrix multiplications dispatch to bigalgebra::dgemm(), mixed
arithmetic on matrices relies on bigalgebra::daxpy(), and
scalar/matrix combinations use bigalgebra::dadd() when appropriate.
Examples
if (requireNamespace("bigmemory", quietly = TRUE) &&
requireNamespace("bigalgebra", quietly = TRUE)) {
x <- bigmemory::big.matrix(2, 2, init = 1)
y <- bigmemory::big.matrix(2, 2, init = 2)
x %*% y
x + y
x * 3
}
#> An object of class "big.matrix"
#> Slot "address":
#> <pointer: 0x11e792c00>
#>