Converters: Converters

02-ConvertersR Documentation

Converters

Description

Converters from R to MPCR objects and vice-versa.

Value

An MPCR or R numeric vector/matrix.

MPCR Converter

Convert R object to MPCR object.

MPCR converters


as.MPCR(data,nrow = 0,ncol = 0,precision,placement): Converts R object to MPCR object.

data

R matrix/vector.

nrow

Number of rows of the new MPCR matrix, default = zero which means a vector will be created.

ncol

Number of cols of the new MPCR matrix, default = zero which means a vector will be created.

precision

String indicates the precision of the new MPCR object (half, single, or double).

placement

String indicates whether the data should be allocated on CPU (default) or GPU ("CPU", "GPU")

R Converter

Convert an MPCR object to R object.

R vector converter


MPCR.ToNumericVector(x): Converts an MPCR object to a numeric R vector.

x

MPCR object.

R matrix converter


MPCR.ToNumericMatrix(x): Converts an MPCR object to a numeric R matrix.

x

MPCR object.

Examples

   # Example usage of the class and its methods
   library(MPCR)
   a <- matrix(1:36, 6, 6)
   MPCR_matrix <- as.MPCR(a,nrow=6,ncol=6,precision="single", placement="CPU")
   r_vector <- MPCR.ToNumericVector(MPCR_matrix)
   r_vector
   r_matrix <- MPCR.ToNumericMatrix(MPCR_matrix)
   r_matrix

MPCR documentation built on Aug. 23, 2026, 5:10 p.m.

Related to Converters in MPCR...