| 01-MPCR | R Documentation |
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)).
MPCR object (constructor - accessors - methods)
new Creates a new instance of zero values of the MPCR class.
new(MPCR,size, "precision")
sizeThe total number of values for which memory needs to be allocated.
precisionString to indicate the precision of MPCR object ("half","single", or "double").
The following accessors can be used to get the values of the slots:
IsMatrixBoolean to indicate whether the MPCR object is a vector or matrix.
SizeTotal number of elements inside the object, (row*col) in the case of matrix, and number of elements in the case of vector.
RowNumber of rows.
ColNumber of cols.
The following methods are available for objects of class MPCR:
PrintValues(): Prints all the values stored in the matrix or vector, along with metadata about the object.
ToMatrix(row,col): Changes the object representation to match the new dimensions, no memory overhead.
ToVector(): Changes the MPCR matrix to vector, no memory overhead.
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.