Learn R Programming

GPUmatrix (version 1.0.2)

round: rounding of numers

Description

It mimics the base function 'round' to operate on gpu.matrix-class objects. This function rounds the values in its first argument to the specified number of decimal places (default 0).

Usage

# S4 method for gpu.matrix.tensorflow,ANY
round(x)
# S4 method for gpu.matrix.torch,missing
round(x,digits)
# S4 method for gpu.matrix.torch,numeric
round(x,digits)
# S4 method for gpu.matrix.tensorflow,missing
round(x,digits)
# S4 method for gpu.matrix.tensorflow,numeric
round(x,digits)

Value

The function will return a gpu.matrix-class object with the rounded values.

Arguments

x

a gpu.matrix.

digits

integer indicating the number of decimal places (round) or significant digits (signif) to be used.

Details

The function round internally calls the corresponding function of the library torch or tensorflow (depending on the type of input gpu.matrix-class).

The behaveour of the function mimics the 'base' function round. Note that for rounding off a 5, the function will consider "go to the even digit". Therefore, round(2.5) = 2 and round(3.5) = 4. For more details see round, and torch_round.

If the input gpu.matrix-class object is stored on the GPU, then the operations will be performed on the GPU. See gpu.matrix.

See Also

round, and torch_round.

Examples

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

a <- gpu.matrix(rnorm(9),3,3)
round(a,digits = 3) #round to the third digit


}
# }

Run the code above in your browser using DataLab