| 02-MPCRTile | R Documentation |
MPCRTile is a data structure for tile matrices with mixed precision, where each tile possesses a specific precision level.
MPCRTile object (constructor - accessors - methods)
new creates a new instance of Tile-Matrix MPCRTile class.
new(MPCRTile,rows,cols,rows_per_tile,cols_per_tile,values,precisions)
rowsNumber of rows in the matrix.
colsNumber of cols in the matrix.
rows_per_tileNumber of rows in each tile.
cols_per_tileNumber of cols in each tile.
valuesR matrix or vector containing all the values that should be in the matrix.
precisionsR matrix or vector of strings, containing precision type of each tile.
The following accessors can be used to get the values of the slots:
SizeTotal number of elements inside the Matrix.
RowNumber of rows.
ColNumber of cols.
TileRowNumber of rows in each tile.
TileColNumber of cols in each tile.
TileSizeTotal number of elements in each tile.
The following methods are available for objects of class MPCRTile:
PrintTile(tile_row_idx,tile_col_idx): Prints all the values stored inside a specific tile plus meta-data about the tile.
tile_row_idxRow index of the tile.
tile_col_idxCol index of the tile.
ChangeTilePrecision(tile_row_idx,tile_col_idx,precision): Change the precision of specific tile, this function will need to copy all the values to cast them to the new precision.
tile_row_idxRow index of the tile.
tile_col_idxCol index of the tile.
precisionRequired new precision as a string.
FillSquareTriangle(value,upper.tri,precision): Fills upper or lower triangle
with a given value and precision, new tiles will be created,
replacing the old tiles. Note: The input must be a square matrix
valueA value used during matrix filling.
upper.triA flag to indicate what triangle to fill. if TRUE, the upper triangle will be filled, otherwise the lower triangle.
precisionThe precision of the tiles created during matrix filling, in case it's not a diagonal tile.
Sum(): Get the sum of all elements in all tiles in MPCRTile Matrix.
Prod(): Get the product of all elements in all tiles in MPCRTile Matrix.
library(MPCR)
# Example usage of the class and its methods
a <- matrix(1:36, 6, 6)
b <- c("double", "double", "single", "double",
"half", "double", "half", "double",
"single")
tile_mat <- new(MPCRTile, 6, 6, 2, 2, a, b)
tile_mat
sum <- tile_mat$Sum()
prod <- tile_mat$Prod()
tile_mat$PrintTile(1,1)
tile_mat$ChangeTilePrecision(1,1,"single")
n_rows <- tile_mat$Row
n_cols <- tile_mat$Col
total_size <- tile_mat$Size
rows_per_tile <- tile_mat$TileRow
cols_per_tile <- tile_mat$TileCol
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.