本文整理汇总了C++中DistMatrix::SetLocalEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ DistMatrix::SetLocalEntry方法的具体用法?C++ DistMatrix::SetLocalEntry怎么用?C++ DistMatrix::SetLocalEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistMatrix
的用法示例。
在下文中一共展示了DistMatrix::SetLocalEntry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logic_error
inline void
MakeOneTwoOne( DistMatrix<T,U,V>& A )
{
#ifndef RELEASE
PushCallStack("MakeOnes");
#endif
if( A.Height() != A.Width() )
throw std::logic_error("Cannot make a non-square matrix 1-2-1");
MakeZeros( A );
const int localHeight = A.LocalHeight();
const int localWidth = A.LocalWidth();
const int colShift = A.ColShift();
const int rowShift = A.RowShift();
const int colStride = A.ColStride();
const int rowStride = A.RowStride();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const int j = rowShift + jLocal*rowStride;
for( int iLocal=0; iLocal<localHeight; ++iLocal )
{
const int i = colShift + iLocal*colStride;
if( i == j )
A.SetLocalEntry( iLocal, jLocal, (T)2 );
else if( i == j-1 || i == j+1 )
A.SetLocalEntry( iLocal, jLocal, (T)1 );
}
}
#ifndef RELEASE
PopCallStack();
#endif
}
示例2: PushCallStack
inline void
Diagonal( const std::vector<T>& d, DistMatrix<T,U,V>& D )
{
#ifndef RELEASE
PushCallStack("Diagonal");
#endif
const int n = d.size();
D.ResizeTo( n, n );
MakeZeros( D );
const int localHeight = D.LocalHeight();
const int localWidth = D.LocalWidth();
const int colShift = D.ColShift();
const int rowShift = D.RowShift();
const int colStride = D.ColStride();
const int rowStride = D.RowStride();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const int j = rowShift + jLocal*rowStride;
if( (j-colShift+colStride) % colStride == 0 )
{
const int iLocal = (j-colShift) / colStride;
D.SetLocalEntry( iLocal, jLocal, d[j] );
}
}
#ifndef RELEASE
PopCallStack();
#endif
}
示例3: logic_error
inline void
MakeHilbert( DistMatrix<F,U,V>& A )
{
#ifndef RELEASE
PushCallStack("MakeHilbert");
#endif
const int m = A.Height();
const int n = A.Width();
if( m != n )
throw std::logic_error("Cannot make a non-square matrix Hilbert");
const F one = static_cast<F>(1);
const int localHeight = A.LocalHeight();
const int localWidth = A.LocalWidth();
const int colShift = A.ColShift();
const int rowShift = A.RowShift();
const int colStride = A.ColStride();
const int rowStride = A.RowStride();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const int j = rowShift + jLocal*rowStride;
for( int iLocal=0; iLocal<localHeight; ++iLocal )
{
const int i = colShift + iLocal*colStride;
A.SetLocalEntry( iLocal, jLocal, one/(i+j+1) );
}
}
#ifndef RELEASE
PopCallStack();
#endif
}
示例4: logic_error
inline void
CauchyLike
( const std::vector<F>& r, const std::vector<F>& s,
const std::vector<F>& x, const std::vector<F>& y,
DistMatrix<F,U,V>& A )
{
#ifndef RELEASE
PushCallStack("CauchyLike");
#endif
const int m = r.size();
const int n = s.size();
if( x.size() != (unsigned)m )
throw std::logic_error("x vector was the wrong length");
if( y.size() != (unsigned)n )
throw std::logic_error("y vector was the wrong length");
A.ResizeTo( m, n );
const int localHeight = A.LocalHeight();
const int localWidth = A.LocalWidth();
const int colShift = A.ColShift();
const int rowShift = A.RowShift();
const int colStride = A.ColStride();
const int rowStride = A.RowStride();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const int j = rowShift + jLocal*rowStride;
for( int iLocal=0; iLocal<localHeight; ++iLocal )
{
const int i = colShift + iLocal*colStride;
#ifndef RELEASE
// TODO: Use tolerance instead?
if( x[i] == y[j] )
{
std::ostringstream msg;
msg << "x[" << i << "] = y[" << j << "] (" << x[i]
<< ") is not allowed for Cauchy-like matrices";
throw std::logic_error( msg.str().c_str() );
}
#endif
A.SetLocalEntry( iLocal, jLocal, r[i]*s[j]/(x[i]-y[j]) );
}
}
#ifndef RELEASE
PopCallStack();
#endif
}
示例5: logic_error
//.........这里部分代码省略.........
pivotIndex = A.Height() + colShift + i*r;
}
}
// Fill the send buffer with:
// [ pivotValue | pivotRow | pivotIndex ]
if( pivotIndex < A.Height() )
{
sendBufFloat[0] = A.GetLocalEntry(pivotIndex,a10.Width());
const int ALDim = A.LocalLDim();
const F* ABuffer = A.LocalBuffer(pivotIndex,0);
for( int j=0; j<width; ++j )
sendBufFloat[j+1] = ABuffer[j*ALDim];
}
else
{
const int localIndex = ((pivotIndex-A.Height())-colShift)/r;
sendBufFloat[0] = b1.GetLocalEntry(localIndex,0);
const int BLDim = B.LocalLDim();
const F* BBuffer = B.LocalBuffer(localIndex,0);
for( int j=0; j<width; ++j )
sendBufFloat[j+1] = BBuffer[j*BLDim];
}
*sendBufInt = pivotIndex;
// Communicate to establish the pivot information
mpi::AllReduce
( &sendData[0], &recvData[0], numBytes, PivotOp<F>(), g.ColComm() );
// Update the pivot vector
const int maxIndex = *recvBufInt;
p.SetLocalEntry(a01.Height(),0,maxIndex+pivotOffset);
// Copy the current row into the pivot row
if( maxIndex < A.Height() )
{
const int ALDim = A.LocalLDim();
F* ASetBuffer = A.LocalBuffer(maxIndex,0);
const F* AGetBuffer = A.LocalBuffer(A00.Height(),0);
for( int j=0; j<width; ++j )
ASetBuffer[j*ALDim] = AGetBuffer[j*ALDim];
}
else
{
const int ownerRank = (colAlignment+(maxIndex-A.Height())) % r;
if( g.Row() == ownerRank )
{
const int localIndex = ((maxIndex-A.Height())-colShift) / r;
const int ALDim = A.LocalLDim();
const int BLDim = B.LocalLDim();
F* BBuffer = B.LocalBuffer(localIndex,0);
const F* ABuffer = A.LocalBuffer(A00.Height(),0);
for( int j=0; j<width; ++j )
BBuffer[j*BLDim] = ABuffer[j*ALDim];
}
}
// Copy the pivot row into the current row
{
F* ABuffer = A.LocalBuffer(A00.Height(),0);
const int ALDim = A.LocalLDim();
for( int j=0; j<width; ++j )
ABuffer[j*ALDim] = recvBufFloat[j+1];