當前位置: 首頁>>代碼示例>>C++>>正文


C++ DistMatrix::SetLocalEntry方法代碼示例

本文整理匯總了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
}
開發者ID:ahmadia,項目名稱:elemental,代碼行數:32,代碼來源:OneTwoOne.hpp

示例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
}
開發者ID:ahmadia,項目名稱:elemental,代碼行數:29,代碼來源:Diagonal.hpp

示例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
}
開發者ID:ahmadia,項目名稱:elemental,代碼行數:31,代碼來源:Hilbert.hpp

示例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
}
開發者ID:ahmadia,項目名稱:elemental,代碼行數:46,代碼來源:CauchyLike.hpp

示例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];
開發者ID:ahmadia,項目名稱:elemental,代碼行數:67,代碼來源:PanelLU.hpp


注:本文中的DistMatrix::SetLocalEntry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。