本文整理匯總了C++中DistMatrix::AlignWith方法的典型用法代碼示例。如果您正苦於以下問題:C++ DistMatrix::AlignWith方法的具體用法?C++ DistMatrix::AlignWith怎麽用?C++ DistMatrix::AlignWith使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DistMatrix
的用法示例。
在下文中一共展示了DistMatrix::AlignWith方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: logic_error
/*
* Distributes A in such a way that
* Layer 0 <- A(:, 0:(n/h - 1))
* Layer 1 <- A(:, (n/h):(2n/h - 1))
* .
* .
* .
* Layer h-1 <- A(:, ((h-1)n/h):n)
*/
void DistributeCols
( const mpi::Comm& depthComm,
const DistMatrix<double,MC,MR>& A,
DistMatrix<double,MC,MR>& B )
{
const Grid& meshGrid = A.Grid();
const int meshSize = meshGrid.Size();
const int depthSize = mpi::CommSize( depthComm );
const int depthRank = mpi::CommRank( depthComm );
const int sendCount = A.LocalHeight()*A.LocalWidth();
const int recvCount = sendCount / depthSize;
// For now, we will make B as large as A...
// TODO: NOT DO THIS
if( A.LocalHeight() != A.LocalLDim() )
throw std::logic_error("Local height did not match local ldim");
B.Empty();
B.AlignWith( A );
Zeros( A.Height(), A.Width(), B );
// Scatter
const int localColOffset = (A.LocalWidth()/depthSize)*depthRank;
mpi::Scatter
( A.LockedLocalBuffer(), recvCount,
B.LocalBuffer(0,localColOffset), recvCount, 0, depthComm );
}
示例2: RowMaxNorms
void RowMaxNorms
( const DistMatrix<F,U,V>& A, DistMatrix<Base<F>,U,STAR>& norms )
{
DEBUG_CSE
norms.AlignWith( A );
norms.Resize( A.Height(), 1 );
RowMaxNorms( A.LockedMatrix(), norms.Matrix() );
AllReduce( norms, A.RowComm(), mpi::MAX );
}
示例3: Zero
void RowTwoNorms
( const DistMatrix<F,U,V>& A, DistMatrix<Base<F>,U,STAR>& norms )
{
DEBUG_CSE
norms.AlignWith( A );
norms.Resize( A.Height(), 1 );
if( A.Width() == 0 )
{
Zero( norms );
return;
}
RowTwoNormsHelper( A.LockedMatrix(), norms.Matrix(), A.RowComm() );
}
示例4: entry
inline void HermitianSVD
( UpperOrLower uplo, DistMatrix<F>& A,
DistMatrix<BASE(F),VR,STAR>& s, DistMatrix<F>& U, DistMatrix<F>& V )
{
#ifndef RELEASE
CallStackEntry entry("HermitianSVD");
#endif
#ifdef HAVE_PMRRR
typedef BASE(F) R;
// Grab an eigenvalue decomposition of A
HermitianEig( uplo, A, s, V );
// Redistribute the singular values into an [MR,* ] distribution
const Grid& grid = A.Grid();
DistMatrix<R,MR,STAR> s_MR_STAR( grid );
s_MR_STAR.AlignWith( V.DistData() );
s_MR_STAR = s;
// Set the singular values to the absolute value of the eigenvalues
const Int numLocalVals = s.LocalHeight();
for( Int iLoc=0; iLoc<numLocalVals; ++iLoc )
{
const R sigma = s.GetLocal(iLoc,0);
s.SetLocal(iLoc,0,Abs(sigma));
}
// Copy V into U (flipping the sign as necessary)
U.AlignWith( V );
U.ResizeTo( V.Height(), V.Width() );
const Int localHeight = V.LocalHeight();
const Int localWidth = V.LocalWidth();
for( Int jLoc=0; jLoc<localWidth; ++jLoc )
{
const R sigma = s_MR_STAR.GetLocal( jLoc, 0 );
F* UCol = U.Buffer( 0, jLoc );
const F* VCol = V.LockedBuffer( 0, jLoc );
if( sigma >= 0 )
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
UCol[iLoc] = VCol[iLoc];
else
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
UCol[iLoc] = -VCol[iLoc];
}
#else
U = A;
MakeHermitian( uplo, U );
SVD( U, s, V );
#endif // ifdef HAVE_PMRRR
}
示例5: PushCallStack
inline void HermitianSVD
( UpperOrLower uplo,
DistMatrix<F>& A, DistMatrix<typename Base<F>::type,VR,STAR>& s,
DistMatrix<F>& U, DistMatrix<F>& V )
{
#ifndef RELEASE
PushCallStack("HermitianSVD");
#endif
typedef typename Base<F>::type R;
// Grab an eigenvalue decomposition of A
HermitianEig( uplo, A, s, V );
// Redistribute the singular values into an [MR,* ] distribution
const Grid& grid = A.Grid();
DistMatrix<R,MR,STAR> s_MR_STAR( grid );
s_MR_STAR.AlignWith( V );
s_MR_STAR = s;
// Set the singular values to the absolute value of the eigenvalues
const int numLocalVals = s.LocalHeight();
for( int iLocal=0; iLocal<numLocalVals; ++iLocal )
{
const R sigma = s.GetLocal(iLocal,0);
s.SetLocal(iLocal,0,Abs(sigma));
}
// Copy V into U (flipping the sign as necessary)
U.AlignWith( V );
U.ResizeTo( V.Height(), V.Width() );
const int localHeight = V.LocalHeight();
const int localWidth = V.LocalWidth();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const R sigma = s_MR_STAR.GetLocal( jLocal, 0 );
F* UCol = U.LocalBuffer( 0, jLocal );
const F* VCol = V.LockedLocalBuffer( 0, jLocal );
if( sigma >= 0 )
for( int iLocal=0; iLocal<localHeight; ++iLocal )
UCol[iLocal] = VCol[iLocal];
else
for( int iLocal=0; iLocal<localHeight; ++iLocal )
UCol[iLocal] = -VCol[iLocal];
}
#ifndef RELEASE
PopCallStack();
#endif
}
示例6: Zeros
// Create a new set of distributed matrices, so that,
// if depthRank == 0, B = A,
// otherwise, B = 0.
void CopyOrReset
( const DistMatrix<double,MC,MR>& A,
DistMatrix<double,MC,MR>& B )
{
const int rank = mpi::CommRank( mpi::COMM_WORLD );
const Grid& meshGrid = A.Grid();
const int meshSize = meshGrid.Size();
const int depthRank = rank / meshSize;
//Layer 0
if( depthRank == 0 )
B = A;
else
{
B.AlignWith( A );
Zeros( A.Height(), A.Width(), B );
}
}
示例7: AssertScaLAPACKSupport
void ScaLAPACKHelper
( DistMatrix<F,MC,MR,BLOCK>& A,
DistMatrix<F,MR,STAR,BLOCK>& householderScalars )
{
EL_DEBUG_CSE
AssertScaLAPACKSupport();
#ifdef EL_HAVE_SCALAPACK
const Int m = A.Height();
const Int n = A.Width();
const Int minDim = Min(m,n);
householderScalars.AlignWith( A );
householderScalars.Resize( minDim, 1 );
auto descA = FillDesc( A );
scalapack::QR
( m, n, A.Buffer(), descA.data(), householderScalars.Buffer() );
#endif
}
示例8: AssertScaLAPACKSupport
void QR
( DistMatrix<F,MC,MR,BLOCK>& A,
DistMatrix<F,MR,STAR,BLOCK>& phase )
{
DEBUG_CSE
AssertScaLAPACKSupport();
#ifdef EL_HAVE_SCALAPACK
const Int m = A.Height();
const Int n = A.Width();
const Int minDim = Min(m,n);
phase.AlignWith( A );
phase.Resize( minDim, 1 );
const int bHandle = blacs::Handle( A );
const int context = blacs::GridInit( bHandle, A );
auto descA = FillDesc( A, context );
scalapack::QR( m, n, A.Buffer(), descA.data(), phase.Buffer() );
blacs::FreeGrid( context );
blacs::FreeHandle( bHandle );
#endif
}
示例9: logic_error
inline void
Var3( Orientation orientation, DistMatrix<F>& A, DistMatrix<F,MC,STAR>& d )
{
#ifndef RELEASE
PushCallStack("ldl::Var3");
if( orientation == NORMAL )
throw std::logic_error("Can only perform LDL^T and LDL^H");
if( A.Height() != A.Width() )
throw std::logic_error("A must be square");
if( A.Grid() != d.Grid() )
throw std::logic_error("A and d must use the same grid");
if( d.Viewing() && (d.Height() != A.Height() || d.Width() != 1) )
throw std::logic_error
("d must be a column vector of the same height as A");
if( d.Viewing() && d.ColAlignment() != A.ColAlignment() )
throw std::logic_error("d must be aligned with A");
#endif
const Grid& g = A.Grid();
if( !d.Viewing() )
{
d.AlignWith( A );
d.ResizeTo( A.Height(), 1 );
}
// Matrix views
DistMatrix<F>
ATL(g), ATR(g), A00(g), A01(g), A02(g),
ABL(g), ABR(g), A10(g), A11(g), A12(g),
A20(g), A21(g), A22(g);
DistMatrix<F,MC,STAR>
dT(g), d0(g),
dB(g), d1(g),
d2(g);
// Temporary matrices
DistMatrix<F,STAR,STAR> A11_STAR_STAR(g);
DistMatrix<F,STAR,STAR> d1_STAR_STAR(g);
DistMatrix<F,VC, STAR> A21_VC_STAR(g);
DistMatrix<F,VR, STAR> A21_VR_STAR(g);
DistMatrix<F,STAR,MC > S21Trans_STAR_MC(g);
DistMatrix<F,STAR,MR > A21AdjOrTrans_STAR_MR(g);
const bool conjugate = ( orientation == ADJOINT );
// Start the algorithm
PartitionDownDiagonal
( A, ATL, ATR,
ABL, ABR, 0 );
PartitionDown
( d, dT,
dB, 0 );
while( ABR.Height() > 0 )
{
RepartitionDownDiagonal
( ATL, /**/ ATR, A00, /**/ A01, A02,
/*************/ /******************/
/**/ A10, /**/ A11, A12,
ABL, /**/ ABR, A20, /**/ A21, A22 );
RepartitionDown
( dT, d0,
/**/ /**/
d1,
dB, d2 );
A21_VC_STAR.AlignWith( A22 );
A21_VR_STAR.AlignWith( A22 );
S21Trans_STAR_MC.AlignWith( A22 );
A21AdjOrTrans_STAR_MR.AlignWith( A22 );
//--------------------------------------------------------------------//
A11_STAR_STAR = A11;
LocalLDL( orientation, A11_STAR_STAR, d1_STAR_STAR );
A11 = A11_STAR_STAR;
d1 = d1_STAR_STAR;
A21_VC_STAR = A21;
LocalTrsm
( RIGHT, LOWER, orientation, UNIT,
F(1), A11_STAR_STAR, A21_VC_STAR );
S21Trans_STAR_MC.TransposeFrom( A21_VC_STAR );
DiagonalSolve( RIGHT, NORMAL, d1_STAR_STAR, A21_VC_STAR );
A21_VR_STAR = A21_VC_STAR;
A21AdjOrTrans_STAR_MR.TransposeFrom( A21_VR_STAR, conjugate );
LocalTrrk
( LOWER, TRANSPOSE,
F(-1), S21Trans_STAR_MC, A21AdjOrTrans_STAR_MR, F(1), A22 );
A21 = A21_VC_STAR;
//--------------------------------------------------------------------//
A21_VC_STAR.FreeAlignments();
A21_VR_STAR.FreeAlignments();
S21Trans_STAR_MC.FreeAlignments();
A21AdjOrTrans_STAR_MR.FreeAlignments();
SlidePartitionDown
( dT, d0,
d1,
/**/ /**/
dB, d2 );
//.........這裏部分代碼省略.........