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(); } }
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(); }
void Helmholtz( DistSparseMatrix<F>& H, Int n, F shift ) { DEBUG_CSE typedef Base<F> Real; Zeros( H, n, n ); const Real hInv = n+1; const Real hInvSquared = hInv*hInv; const F mainTerm = 2*hInvSquared - shift; const Int localHeight = H.LocalHeight(); H.Reserve( 3*localHeight ); for( Int iLoc=0; iLoc<localHeight; ++iLoc ) { const Int i = H.GlobalRow(iLoc); H.QueueUpdate( i, i, mainTerm ); if( i != 0 ) H.QueueUpdate( i, i-1, -hInvSquared ); if( i != n-1 ) H.QueueUpdate( i, i+1, -hInvSquared ); } H.ProcessQueues(); }
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(); }