本文整理汇总了C++中DistSparseMatrix::LocalHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ DistSparseMatrix::LocalHeight方法的具体用法?C++ DistSparseMatrix::LocalHeight怎么用?C++ DistSparseMatrix::LocalHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistSparseMatrix
的用法示例。
在下文中一共展示了DistSparseMatrix::LocalHeight方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Helmholtz
void Helmholtz( DistSparseMatrix<F>& H, Int nx, Int ny, F shift )
{
DEBUG_CSE
typedef Base<F> Real;
const Int n = nx*ny;
Zeros( H, n, n );
const Real hxInv = nx+1;
const Real hyInv = ny+1;
const Real hxInvSquared = hxInv*hxInv;
const Real hyInvSquared = hyInv*hyInv;
const F mainTerm = 2*(hxInvSquared+hyInvSquared) - shift;
const Int localHeight = H.LocalHeight();
H.Reserve( 5*localHeight );
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
const Int i = H.GlobalRow(iLoc);
const Int x = i % nx;
const Int y = i/nx;
H.QueueUpdate( i, i, mainTerm );
if( x != 0 )
H.QueueUpdate( i, i-1, -hxInvSquared );
if( x != nx-1 )
H.QueueUpdate( i, i+1, -hxInvSquared );
if( y != 0 )
H.QueueUpdate( i, i-nx, -hyInvSquared );
if( y != ny-1 )
H.QueueUpdate( i, i+nx, -hyInvSquared );
}
H.ProcessQueues();
}
示例2: T
void ShiftDiagonal
( DistSparseMatrix<T>& A, S alphaPre, Int offset, bool existingDiag )
{
EL_DEBUG_CSE
const Int mLocal = A.LocalHeight();
const Int n = A.Width();
const T alpha = T(alphaPre);
if( existingDiag )
{
T* valBuf = A.ValueBuffer();
for( Int iLoc=0; iLoc<mLocal; ++iLoc )
{
const Int i = A.GlobalRow(iLoc);
const Int e = A.Offset( iLoc, i+offset );
valBuf[e] += alpha;
}
}
else
{
A.Reserve( mLocal );
for( Int iLoc=0; iLoc<mLocal; ++iLoc )
{
const Int i = A.GlobalRow(iLoc);
if( i+offset >= 0 && i+offset < n )
A.QueueLocalUpdate( iLoc, i+offset, alpha );
}
A.ProcessLocalQueues();
}
}
示例3: Fill
void Fill( DistSparseMatrix<T>& A, T alpha )
{
EL_DEBUG_CSE
const Int m = A.Height();
const Int n = A.Width();
A.Resize( m, n );
Zero( A );
if( alpha != T(0) )
{
const Int localHeight = A.LocalHeight();
A.Reserve( localHeight*n );
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
for( Int j=0; j<n; ++j )
A.QueueLocalUpdate( iLoc, j, alpha );
A.ProcessLocalQueues();
}
}
示例4: 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;
}
}
示例5: 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);
}
}
示例6: JordanCholesky
void JordanCholesky( DistSparseMatrix<T>& A, Int n )
{
DEBUG_ONLY(CSE cse("JordanCholesky"))
Zeros( A, n, n );
const Int localHeight = A.LocalHeight();
A.Reserve( 3*localHeight );
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
const Int i = A.GlobalRow(iLoc);
if( i == 0 )
A.QueueUpdate( i, i, T(1) );
else
A.QueueUpdate( i, i, T(5) );
if( i > 0 )
A.QueueUpdate( i, i-1, T(2) );
if( i < n-1 )
A.QueueUpdate( i, i+1, T(2) );
}
A.ProcessQueues();
}