gmatrix: Create and object of class 'gmatrix'

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/01gmatrix.R

Description

This function creates a gmatrix object from an input value.

Usage

1
2
gmatrix(data = NA, nrow = 1L, ncol = 1L, byrow = FALSE,
 dimnames = NULL, type = NULL, dup = TRUE)

Arguments

data

The input data. Must be a vector or gvector.

nrow

the desired number of rows

ncol

the desired number of rows.

byrow

logical. If FALSE (the default) the matrix is filled by columns, otherwise the matrix is filled by rows.

dimnames

A dimnames attribute for the matrix: NULL or a list of length 2 giving the row and column names respectively. An empty list is treated as NULL.

type

The type (i.e. "double", "single", "integer" or "logical")

dup

dup=FALSE will return the original data without duplicating it on the GPU. The dup=FALSE should only be used if the data in the input will not be used in it's original form again.

Details

This is implemented in a very similar fashion to the matrix function in R base.

Value

returns a gmatrix object.

Author(s)

Nathan Morrris

See Also

matrix

Examples

1
2
3
4
5
6
7
8
x=gmatrix(grnorm(100),10,10, type='d') #this makes an unneeded duplication
x=gmatrix(grnorm(100),10,10, dup=FALSE) #this avoids the duplication

#problematic code
x=grnorm(100)
y=as.gmatrix(x,10,10, dup=FALSE) #don't do this
y[1,1]=100 #this changes both y and x because both point to the same spot in GPU memory
x

njm18/gmatrix documentation built on May 23, 2019, 7:07 p.m.