getMatrixBlockSize
C++ Function Reference
1 Signature
std::vector< hsize_t > BigDataStatMeth::getMatrixBlockSize(int nrows, int ncols)2 Description
Calculates optimal block size for matrix operations.
3 Parameters
nrows(int): Number of rowsncols(int): Number of columns
4 Returns
std::vector
5 Details
nrowsNumber of rows ncolsNumber of columns std::vector
6 Caller Graph
7 Source Code
NoteImplementation
File: inst/include/Utilities/Utilities.hpp • Lines 338-379
inline std::vector<hsize_t> getMatrixBlockSize( int nrows, int ncols )
{
size_t maxRows = nrows,
maxCols = ncols;
std::vector<hsize_t> blockSize = {0, 0};
try
{
// Calculem el mínim de files
if( nrows < ncols ) {
if( maxRows < MAXBLOCKSIZE ){
maxRows = nrows;
} else{
maxRows = MAXBLOCKSIZE;
}
maxCols = std::floor( MAXELEMSINBLOCK / maxRows );
if( maxCols> (unsigned)ncols || maxCols + 1 == (unsigned)ncols) {
maxCols = ncols;
}
} else {
if( maxCols < MAXBLOCKSIZE ){
maxCols = ncols;
} else{
maxCols = MAXBLOCKSIZE;
}
maxRows = std::floor( MAXELEMSINBLOCK / maxCols );
if( maxRows> (unsigned)nrows || maxRows + 1 == (unsigned)nrows) {
maxRows = nrows;
}
}
blockSize[0] = maxRows;
blockSize[1] = maxCols;
} catch(std::exception& ex) {
Rcpp::Rcout<< "c++ exception getMatrixBlockSize: "<<ex.what()<< " \n";
}
return(blockSize);
}8 Usage Example
#include "BigDataStatMeth.hpp"
// Example usage
auto result = getMatrixBlockSize(...);