本文整理汇总了C++中DistSparseMatrix::LockedOffsetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ DistSparseMatrix::LockedOffsetBuffer方法的具体用法?C++ DistSparseMatrix::LockedOffsetBuffer怎么用?C++ DistSparseMatrix::LockedOffsetBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistSparseMatrix
的用法示例。
在下文中一共展示了DistSparseMatrix::LockedOffsetBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RowMaxNorms
void RowMaxNorms( const DistSparseMatrix<F>& A, DistMultiVec<Base<F>>& norms )
{
DEBUG_CSE
typedef Base<F> Real;
const Int localHeight = A.LocalHeight();
const F* valBuf = A.LockedValueBuffer();
const Int* offsetBuf = A.LockedOffsetBuffer();
norms.SetComm( A.Comm() );
norms.Resize( A.Height(), 1 );
auto& normsLoc = norms.Matrix();
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
Real rowMax = 0;
const Int offset = offsetBuf[iLoc];
const Int numConn = offsetBuf[iLoc+1] - offset;
for( Int e=offset; e<offset+numConn; ++e )
rowMax = Max(rowMax,Abs(valBuf[e]));
normsLoc(iLoc) = rowMax;
}
}
示例2: RowTwoNorms
void RowTwoNorms( const DistSparseMatrix<F>& A, DistMultiVec<Base<F>>& norms )
{
DEBUG_CSE
typedef Base<F> Real;
const Int localHeight = A.LocalHeight();
const F* valBuf = A.LockedValueBuffer();
const Int* offsetBuf = A.LockedOffsetBuffer();
norms.SetComm( A.Comm() );
norms.Resize( A.Height(), 1 );
auto& normLoc = norms.Matrix();
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
Real scale = 0;
Real scaledSquare = 1;
const Int offset = offsetBuf[iLoc];
const Int numConn = offsetBuf[iLoc+1] - offset;
for( Int e=offset; e<offset+numConn; ++e )
UpdateScaledSquare( valBuf[e], scale, scaledSquare );
normLoc(iLoc) = scale*Sqrt(scaledSquare);
}
}