本文整理匯總了C++中DistMatrix::DistData方法的典型用法代碼示例。如果您正苦於以下問題:C++ DistMatrix::DistData方法的具體用法?C++ DistMatrix::DistData怎麽用?C++ DistMatrix::DistData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DistMatrix
的用法示例。
在下文中一共展示了DistMatrix::DistData方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: 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
}
示例2: BASE
void TestCorrectness
( bool print,
UpperOrLower uplo,
const DistMatrix<F>& A,
const DistMatrix<F,STAR,STAR>& t,
DistMatrix<F>& AOrig )
{
typedef BASE(F) Real;
const Grid& g = A.Grid();
const Int m = AOrig.Height();
Int subdiagonal = ( uplo==LOWER ? -1 : +1 );
if( g.Rank() == 0 )
cout << "Testing error..." << endl;
// Grab the diagonal and subdiagonal of the symmetric tridiagonal matrix
DistMatrix<Real,MD,STAR> d(g);
DistMatrix<Real,MD,STAR> e(g);
A.GetRealPartOfDiagonal( d );
A.GetRealPartOfDiagonal( e, subdiagonal );
// Grab a full copy of e so that we may fill the opposite subdiagonal
DistMatrix<Real,STAR,STAR> e_STAR_STAR(g);
DistMatrix<Real,MD,STAR> eOpposite(g);
e_STAR_STAR = e;
eOpposite.AlignWithDiagonal( A.DistData(), -subdiagonal );
eOpposite = e_STAR_STAR;
// Zero B and then fill its tridiagonal
DistMatrix<F> B(g);
B.AlignWith( A );
Zeros( B, m, m );
B.SetRealPartOfDiagonal( d );
B.SetRealPartOfDiagonal( e, subdiagonal );
B.SetRealPartOfDiagonal( eOpposite, -subdiagonal );
if( print )
Print( B, "Tridiagonal" );
// Reverse the accumulated Householder transforms, ignoring symmetry
hermitian_tridiag::ApplyQ( LEFT, uplo, NORMAL, A, t, B );
hermitian_tridiag::ApplyQ( RIGHT, uplo, ADJOINT, A, t, B );
if( print )
Print( B, "Rotated tridiagonal" );
// Compare the appropriate triangle of AOrig and B
MakeTriangular( uplo, AOrig );
MakeTriangular( uplo, B );
Axpy( F(-1), AOrig, B );
if( print )
Print( B, "Error in rotated tridiagonal" );
const Real infNormOfAOrig = HermitianInfinityNorm( uplo, AOrig );
const Real frobNormOfAOrig = HermitianFrobeniusNorm( uplo, AOrig );
const Real infNormOfError = HermitianInfinityNorm( uplo, B );
const Real frobNormOfError = HermitianFrobeniusNorm( uplo, B );
if( g.Rank() == 0 )
{
cout << " ||AOrig||_1 = ||AOrig||_oo = " << infNormOfAOrig << "\n"
<< " ||AOrig||_F = " << frobNormOfAOrig << "\n"
<< " ||AOrig - Q^H A Q||_oo = " << infNormOfError << "\n"
<< " ||AOrig - Q^H A Q||_F = " << frobNormOfError << endl;
}
}