MPCR: MPCR S4 Class

01-MPCRR Documentation

MPCR S4 Class

Description

MPCR is a multi-precision vector/matrix, that enables the creation of vector/matrix with three different precisions (16-bit (half), 32-bit(single), and 64-bit(double)).

Value

MPCR object (constructor - accessors - methods)

Constructor

new Creates a new instance of zero values of the MPCR class. new(MPCR,size, "precision")

size

The total number of values for which memory needs to be allocated.

precision

String to indicate the precision of MPCR object ("half","single", or "double").

Accessors

The following accessors can be used to get the values of the slots:

IsMatrix

Boolean to indicate whether the MPCR object is a vector or matrix.

Size

Total number of elements inside the object, (row*col) in the case of matrix, and number of elements in the case of vector.

Row

Number of rows.

Col

Number of cols.

Methods

The following methods are available for objects of class MPCR:

PrintValues

PrintValues(): Prints all the values stored in the matrix or vector, along with metadata about the object.

ToMatrix

ToMatrix(row,col): Changes the object representation to match the new dimensions, no memory overhead.

ToVector

ToVector(): Changes the MPCR matrix to vector, no memory overhead.

Examples

  
    # Example usage of the class and its methods
    library(MPCR)
    MPCR_object <- new(MPCR,50,"single")

    MPCR_object$ToMatrix(5,10)
    MPCR_object$Row       #5
    MPCR_object$Col       #10
    MPCR_object$Size      #50
    MPCR_object$IsMatrix  #TRUE

    MPCR_object$PrintValues()
    MPCR_object$ToVector()

    MPCR_object
  

MPCR documentation built on April 13, 2025, 5:08 p.m.

Related to MPCR in MPCR...