Skip to contents

These 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)

Arguments

x, y

Matrix operands supplied either as big.matrix instances or base R matrices, depending on the method signature.

e1, e2

Numeric operands, which may be big.matrix objects, base R matrices, or numeric scalars depending on the method signature.

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>
#>