Learn R Programming

GPUmatrix (version 1.0.2)

dim_and_names: Number of rows and columns and its corresponding names

Description

These functions mimic the 'base' functions rownames, colnames, dimnames, dim, length, ncol, nrow to operate on gpu.matrix-class objects.

The "dim family functions" set or get the dimension of a gpu.matrix-class object.

The "rownames and colnames family functions" set or get the corresponding names of rows and columns of a gpu.matrix-class object.

Usage

# S4 method for gpu.matrix.tensorflow
rownames(x)
# S4 method for gpu.matrix.torch
rownames(x)
# S4 method for gpu.matrix.tensorflow
colnames(x)
# S4 method for gpu.matrix.torch
colnames(x)
# S4 method for gpu.matrix.tensorflow
dim(x)
# S4 method for gpu.matrix.torch
dim(x)
# S4 method for gpu.matrix.tensorflow
dimnames(x)
# S4 method for gpu.matrix.torch
dimnames(x)
# S4 method for gpu.matrix.tensorflow
length(x)
# S4 method for gpu.matrix.torch
length(x)
# S4 method for gpu.matrix.tensorflow
ncol(x)
# S4 method for gpu.matrix.torch
ncol(x)
# S4 method for gpu.matrix.tensorflow
nrow(x)
# S4 method for gpu.matrix.torch
nrow(x)

# S4 method for gpu.matrix.tensorflow,vector dim(x) <- value # S4 method for gpu.matrix.torch,vector dim(x) <- value # S4 method for gpu.matrix.tensorflow,vector dimnames(x) <- value # S4 method for gpu.matrix.torch,vector dimnames(x) <- value

Value

rownames returns the names of the rows of a gpu.matrix-class object. colnames returns the names of the columns of a gpu.matrix-class object.

dim returns the number of rows and columns of a gpu.matrix-class object and

dim <- sets the number of rows and columns of a gpu.matrix-class object.

dimnames returns the names of the rows and columns of a gpu.matrix-class object and

dimnames <- sets the names of the rows and columns of a gpu.matrix-class object.

length returns the length (ncol*nrow) of a gpu.matrix-class object.

ncol returns the number of columns of a gpu.matrix-class object.

nrow returns the number of rows of a gpu.matrix-class object.

Arguments

x

a gpu.matrix.

value

For dim a numeric vector of length 2 with the number of rows and number of columns. For dimnames a character or numeric vector of length 2 with the names of the rows and names of the columns.

See Also

For more information: rownames, colnames, dim, dim<-, dimnames, dimnames<-, length, ncol, nrow.

Examples

Run this code
# \donttest{
if (FALSE) {

a <- gpu.matrix(rnorm(9))

dim(a) <- c(3,3) #sets the number of rows and columns.
dim(a) #shows the number of rows and the number of columns
ncol(a) #shows the number of columns
nrow(a) #shows the number of rows
length(a) #shows the lenght of the matrix (nrow*ncol)


dimnames(a) <- list(c("r1","r2","r3"),c("c1","c2","c3")) #sets rows and column names
dimnames(a) #shows both the row and the col names

#these functions are equivalent to the following:
rownames(a) <- c("r1","r2","r3") #adds rownames to a.
colnames(a) <- c("c1","c2","c3") #adds colnames to a.
rownames(a) #shows rownames.
colnames(a) #shows colnames.

}
# }

Run the code above in your browser using DataLab