getOptimBlockSize

C++ Function Reference

1 Signature

size_t BigDataStatMeth::getOptimBlockSize(size_t fullSize, size_t blockSize, size_t iDesp, size_t currentSize)

2 Description

Optimizes block size for edge cases.

3 Parameters

  • fullSize (size_t): Total size of dimension
  • blockSize (size_t): Current block size
  • iDesp (size_t): Current displacement
  • currentSize (size_t): Current size being processed

4 Returns

size_t Optimized block size

5 Details

fullSizeTotal size of dimension blockSizeCurrent block size iDespCurrent displacement currentSizeCurrent size being processed size_t Optimized block size Optimization strategy:Handles last block to avoid single element operationsAdjusts for matrix boundariesPrevents overflowOptimizes for performance

6 Caller Graph

Function dependencies

7 Source Code

File: inst/include/Utilities/Utilities.hppLines 299-317

inline size_t getOptimBlockSize( size_t fullSize, size_t blockSize, size_t iDesp, size_t currentSize ) 
    {
        
        try
        {
            if( iDesp + blockSize == fullSize - 1) {
                currentSize = blockSize + 1;
            } else if( iDesp + blockSize > fullSize ) { 
                currentSize = fullSize - iDesp; 
            } else {
                currentSize = blockSize;
            }
            
        } catch(std::exception& ex) {
            Rcpp::Rcout<< "c++ exception getOptimBlockSize: "<<ex.what()<< " \n";
        }
        
        return(currentSize);
    }

8 Usage Example

#include "BigDataStatMeth.hpp"

// Example usage
auto result = getOptimBlockSize(...);