gmatrix (version 0.3)

gmm: Multiply two matrices with the output matrix allready allocated.

Description

In effect this function sets C <- A %*% B. This makes it possible to avoid repeated allocation and deallocation steps which are very computationaly costly.

Usage

gmm(A, B, C, trA=FALSE, trB=FALSE, accum=FALSE)

Arguments

A, B
Matrices to multiply together.
C
Matrices where output will be saved.
trA, trB
Should A or B be transposed.
accum
if accum is set to TRUE, the multiplied matrix will be added to C (i.e. C<-C+A %*% B).

Value

Returns C invisibly.

Details

This function takes advantage of the fact that gmatrix objects are stored as pointers making it posible modify the input to a function. Thus the area of memory on the GPU pointed to by the C object is modified to contain A %*% B.

Examples

Run this code
A=gmatrix(rnorm(10), 2, 5)
B=gmatrix(rnorm(10), 5, 2)
C=gmatrix(0,2,2)
gmm(A,B,C)
gmm(B,A,C,TRUE,TRUE)

Run the code above in your browser using DataLab