本文整理汇总了C++中Matrix2D::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix2D::GetData方法的具体用法?C++ Matrix2D::GetData怎么用?C++ Matrix2D::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix2D
的用法示例。
在下文中一共展示了Matrix2D::GetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
Initialize<T>::operator()( Matrix2D<T>& mtx )
{
srand48( seed );
int nTileRows = mtx.GetNumRows() - 2 * haloWidth;
if( (rowPeriod != -1) && (rowPeriod < nTileRows) )
{
nTileRows = rowPeriod;
}
int nTileCols = mtx.GetNumColumns() - 2 * haloWidth;
if( (colPeriod != -1) && (colPeriod < nTileCols) )
{
nTileCols = colPeriod;
}
// initialize first tile
for( unsigned int i = 0; i < nTileRows; i++ )
{
for( unsigned int j = 0; j < nTileCols; j++ )
{
#ifndef READY
mtx.GetData()[i+haloWidth][j+haloWidth] = i * j;
#else
mtx.GetData()[i+haloWidth][j+haloWidth] = (T)drand48();
#endif // READY
}
}
// initialize any remaining tiles
// first we fill along rows a tile at a time,
// then fill out along columns a row at a time
if( colPeriod != -1 )
{
int nTiles = (mtx.GetNumColumns() - 2*haloWidth) / colPeriod;
if( (mtx.GetNumColumns() - 2*haloWidth) % colPeriod != 0 )
{
nTiles += 1;
}
for( unsigned int t = 1; t < nTiles; t++ )
{
for( unsigned int i = 0; i < nTileRows; i++ )
{
memcpy( &(mtx.GetData()[haloWidth + i][haloWidth + t*nTileCols]),
&(mtx.GetData()[haloWidth + i][haloWidth]),
nTileCols * sizeof(T) );
}
}
}
if( rowPeriod != -1 )
{
int nTiles = (mtx.GetNumRows() - 2*haloWidth) / rowPeriod;
if( (mtx.GetNumRows() - 2*haloWidth) % rowPeriod != 0 )
{
nTiles += 1;
}
for( unsigned int t = 1; t < nTiles; t++ )
{
for( unsigned int i = 0; i < nTileRows; i++ )
{
memcpy( &(mtx.GetData()[haloWidth + t*nTileRows + i][haloWidth]),
&(mtx.GetData()[haloWidth + i][haloWidth]),
(mtx.GetNumColumns() - 2*haloWidth) * sizeof(T) );
}
}
}
// initialize halo
for( unsigned int i = 0; i < mtx.GetNumRows(); i++ )
{
for( unsigned int j = 0; j < mtx.GetNumColumns(); j++ )
{
bool inHalo = false;
if( (i < haloWidth) || (i > mtx.GetNumRows() - 1 - haloWidth) )
{
inHalo = true;
}
else if( (j < haloWidth) || (j > mtx.GetNumColumns() - 1 - haloWidth) )
{
inHalo = true;
}
if( inHalo )
{
mtx.GetData()[i][j] = haloVal;
}
}
}
}