type of gpu.matrix {GPUmatrix}R Documentation

Spicify type of 'GPUmatrix'

Description

dtype and dtype<- are functions that show or set the number of bits to use to store the number. The possible options are "float64" for float64 (default), "float32" for float32 and "int" for int64. float64 uses 64 bits, that means that float64's take up twice as much memory thatn float32, thus doing operations on them may be slower in some machine architectures. However, float64's can represent numbers much more accurately than 32 bit floats. They also allow much larger numbers to be stored.

to_dense is a function that transforms a sparse matrix to a dense matrix. On the other hand, to_sparse transforms a dense matrix to a sparse matrix.

Usage


## S4 method for signature 'gpu.matrix.torch'
to_dense(x)
## S4 method for signature 'gpu.matrix.tensorflow'
to_dense(x)
## S4 method for signature 'gpu.matrix.torch'
to_sparse(x)
## S4 method for signature 'gpu.matrix.tensorflow'
to_sparse(x)


## S4 method for signature 'gpu.matrix.torch'
dtype(x)
## S4 method for signature 'gpu.matrix.tensorflow'
dtype(x)
## S4 replacement method for signature 'gpu.matrix.torch'
dtype(x) <- value
## S4 replacement method for signature 'gpu.matrix.tensorflow'
dtype(x) <- value

Arguments

x

a gpu.matrix.

value

type of gpu.matrix object

Value

dtype and dtype <- show or set the number of bits to use to store the number.

to_dense returns a dense gpu.matrix-class object while the function to_sparse returns a sparse gpu.matrix-class object.

See Also

See also gpu.matrix.

Examples


## Not run: 

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

dtype(a) #bits used to store the numbers: it is float64 by default.

b <- a
dtype(b) <- "float32" #change to float32
b

b <- a
dtype(b) <- "int" #change to integer64 (int64)
b

#sparse or dense matrices
A <- gpu.matrix(data=c(1,1,1,0,0,1,0,1,0),3,3)
A #A is a dense gpu.matrix

A_sparse <- to_sparse(A) #transform A to a sparse matrix.
A_sparse #this matrix stores the where number different to 0 were placed.

to_dense(A_sparse) #transform A_sparse to a dense matrix and we obtain the orginal matrix A:
A


## End(Not run)




[Package GPUmatrix version 1.0.2 Index]