tcrossproduct using GPU or multi-core CPU

Share:

Description

Given matrices x and y as arguments, return a matrix cross-product. This is formally equivalent to (but usually slightly faster than) the call t(x) %*% y (tcrossprod) or x %*% t(y) (tcrossprod).

Usage

1
2
3
4
5
tcrossprod(x, y)
## S4 method for signature 'dgeMatrix'
tcrossprod(x, y)
## S4 method for signature 'dtrMatrix'
tcrossprod(x, y)

Arguments

x

dense matrix or vector represented as a single row matrix.

y

dense matrix or vector represented as single row matrix.

Details

For further details on classes and methods see the full Matrix package documentation.

Methods

tcrossprod

(signature(x = "dgeMatrix", y = "missing"): Calls CUBLAS function cublasDsyrk for GPU enabled systems and PLASMA_dsyrk for multi-core systems. Library settings also affect choice between GPU and CPU. If y = NULL, then it is taken to be the same matrix as x.

tcrossprod

(signature(x = "dgeMatrix", y = "dgeMatrix"): Calls MAGMA function magma_dgemm for GPU enabled systems and PLASMA_dgemm for multi-core systems. Library settings also affect choice between GPU and CPU.

tcrossprod

(signature(x = "dgeMatrix", y = "Matrix"): Calls MAGMA function magma_dgemm for GPU enabled systems and PLASMA_dgemm for multi-core systems. Library settings also affect choice between GPU and CPU.

tcrossprod

(signature(x = "dgeMatrix", y = "numeric"): Calls MAGMA function magma_dgemm for GPU enabled systems and PLASMA_dgemm for multi-core systems. Library settings also affect choice between GPU and CPU. y is coerced to a base::matrix.

tcrossprod

(signature(x = "dgeMatrix", y = "matrix"): Calls MAGMA function magma_dgemm for GPU enabled systems and PLASMA_dgemm for multi-core systems. Library settings also affect choice between GPU and CPU.

tcrossprod

(signature(x = "dtrMatrix", y = "dtrMatrix"): Calls CUBLAS function cublasDtrmm for GPU enabled systems and PLASMA_dtrmm for multi-core systems. Library settings also affect choice between GPU and CPU.

tcrossprod

(signature(x = "denseMatrix", y = "dtrMatrix"): y inherits from virtual class ddenseMatrix Calls MAGMA function magma_dgemm for GPU enabled systems and PLASMA_dgemm for multi-core systems. Library settings also affect choice between GPU and CPU.

tcrossprod

(signature(x = "matrix", y = "dtrMatrix"): Calls CUBLAS function cublasDtrmm for GPU enabled systems and PLASMA_dtrmm for multi-core systems. Library settings also affect choice between GPU and CPU.

References

Martin Maechler, Douglas Bates (Matrix package)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
m <- matrix(0, 400, 500)
set.seed(12)
m[runif(314, 0, length(m))] <- 1
mm <- as(m, "dgeMatrix")
object.size(m) / object.size(mm) # smaller by a factor of > 200

## tcrossprod() is very fast:
system.time(tCmm <- tcrossprod(mm))
system.time(cm <- crossprod(t(m)))
system.time(cm. <- tcrossprod(m)) 

stopifnot(cm == as(tCmm, "matrix"))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.