Using RealType (int, long, float, double, ...) when dividing
In ChunkedEllpack_imlp.h on lines 177 - 186:
/****
* Compute the chunk size
*/
IndexType maxChunkInSlice( 0 );
for( IndexType i = sliceBegin; i < sliceEnd; i++ )
maxChunkInSlice = max( maxChunkInSlice,
ceil( ( RealType ) rowLengths[ i ] /
( RealType ) this->rowToChunkMapping[ i ] ) );
TNL_ASSERT( maxChunkInSlice > 0,
std::cerr << " maxChunkInSlice = " << maxChunkInSlice << std::endl );
Casting to RealType is used in the ceil function and then the variables are divided.
In the case of RealType being int, this will cause integer division, and could possibly return 0, even though ceil() is type double.
Should the variables be cast to Double instead to avoid this?