Learn R Programming

gmatrix (version 0.3)

as.gmatrix, as.gvector: Methods for coercing an object to a GPU class

Description

The as.gmatrix and as.gvector methods may be used to coerce an object to a given GPU class (i.e. gmatrix or gvector).

Arguments

x, data
object to be coerced
type
The type to convert the object to. There are three different ways to specify this. One may use the "double", "single", "integer" or "logical" notation. Alternatively the short form "d", "s", "i" or "s" notation may be used. Finally the internal integer representation of 0L, 1L, 2L or 3L may be used.
dup
This may be set to 'FALSE' to avoid duplicating x in the event that it is on the GPU allready and the original type is the same as the type argument.
nrow,ncol,byrow,dimnames
these attributes should generally only be set by a direct call to gmatrix

Value

An object of type gmatrix or gvector

Details

The as.gmatrix and as.gvector methods may be used to move an R object to the current GPU device and returns an object of class gmatrix or gvector respectively. The methods have the following arguments:

as.gmatrix(data = NA, nrow = 1L, ncol = 1L, byrow = FALSE, dimnames = NULL, type = NULL, dup = TRUE) as.gvector(x, type=NULL, dup=TRUE)

The dup argument is used only when the input argument (data) is all ready on the GPU. dup=FALSE will return the original data without duplicating it on the GPU.

See Also

g, gmatrix and gvector

Examples

Run this code
A=matrix(1:10,2,5)
B=as.gmatrix(A)

Run the code above in your browser using DataLab