本文整理匯總了C++中DistMatrix::Grid方法的典型用法代碼示例。如果您正苦於以下問題:C++ DistMatrix::Grid方法的具體用法?C++ DistMatrix::Grid怎麽用?C++ DistMatrix::Grid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DistMatrix
的用法示例。
在下文中一共展示了DistMatrix::Grid方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: logic_error
inline void
internal::LocalTrmmAccumulateLUN
( Orientation orientation, UnitOrNonUnit diag, T alpha,
const DistMatrix<T,MC, MR >& U,
const DistMatrix<T,STAR,MR >& XAdjOrTrans_STAR_MR,
DistMatrix<T,MC, STAR>& Z_MC_STAR )
{
#ifndef RELEASE
PushCallStack("internal::LocalTrmmAccumulateLUN");
if( U.Grid() != XAdjOrTrans_STAR_MR.Grid() ||
XAdjOrTrans_STAR_MR.Grid() != Z_MC_STAR.Grid() )
throw std::logic_error
("{U,X,Z} must be distributed over the same grid");
if( U.Height() != U.Width() ||
U.Height() != XAdjOrTrans_STAR_MR.Width() ||
U.Height() != Z_MC_STAR.Height() ||
XAdjOrTrans_STAR_MR.Height() != Z_MC_STAR.Width() )
{
std::ostringstream msg;
msg << "Nonconformal LocalTrmmAccumulateLUN: \n"
<< " U ~ " << U.Height() << " x " << U.Width() << "\n"
<< " X^H/T[* ,MR] ~ " << XAdjOrTrans_STAR_MR.Height() << " x "
<< XAdjOrTrans_STAR_MR.Width() << "\n"
<< " Z[MC,* ] ~ " << Z_MC_STAR.Height() << " x "
<< Z_MC_STAR.Width() << "\n";
throw std::logic_error( msg.str().c_str() );
}
if( XAdjOrTrans_STAR_MR.RowAlignment() != U.RowAlignment() ||
Z_MC_STAR.ColAlignment() != U.ColAlignment() )
throw std::logic_error("Partial matrix distributions are misaligned");
#endif
const Grid& g = U.Grid();
// Matrix views
DistMatrix<T,MC,MR>
UTL(g), UTR(g), U00(g), U01(g), U02(g),
UBL(g), UBR(g), U10(g), U11(g), U12(g),
U20(g), U21(g), U22(g);
DistMatrix<T,MC,MR> D11(g);
DistMatrix<T,STAR,MR>
XLAdjOrTrans_STAR_MR(g), XRAdjOrTrans_STAR_MR(g),
X0AdjOrTrans_STAR_MR(g), X1AdjOrTrans_STAR_MR(g),
X2AdjOrTrans_STAR_MR(g);
DistMatrix<T,MC,STAR>
ZT_MC_STAR(g), Z0_MC_STAR(g),
ZB_MC_STAR(g), Z1_MC_STAR(g),
Z2_MC_STAR(g);
const int ratio = std::max( g.Height(), g.Width() );
PushBlocksizeStack( ratio*Blocksize() );
LockedPartitionDownDiagonal
( U, UTL, UTR,
UBL, UBR, 0 );
LockedPartitionRight
( XAdjOrTrans_STAR_MR, XLAdjOrTrans_STAR_MR, XRAdjOrTrans_STAR_MR, 0 );
PartitionDown
( Z_MC_STAR, ZT_MC_STAR,
ZB_MC_STAR, 0 );
while( UTL.Height() < U.Height() )
{
LockedRepartitionDownDiagonal
( UTL, /**/ UTR, U00, /**/ U01, U02,
/*************/ /******************/
/**/ U10, /**/ U11, U12,
UBL, /**/ UBR, U20, /**/ U21, U22 );
LockedRepartitionRight
( XLAdjOrTrans_STAR_MR, /**/ XRAdjOrTrans_STAR_MR,
X0AdjOrTrans_STAR_MR, /**/ X1AdjOrTrans_STAR_MR, X2AdjOrTrans_STAR_MR
);
RepartitionDown
( ZT_MC_STAR, Z0_MC_STAR,
/**********/ /**********/
Z1_MC_STAR,
ZB_MC_STAR, Z2_MC_STAR );
D11.AlignWith( U11 );
//--------------------------------------------------------------------//
D11 = U11;
MakeTrapezoidal( LEFT, UPPER, 0, D11 );
if( diag == UNIT )
SetDiagonalToOne( D11 );
internal::LocalGemm
( NORMAL, orientation, alpha, D11, X1AdjOrTrans_STAR_MR,
(T)1, Z1_MC_STAR );
internal::LocalGemm
( NORMAL, orientation, alpha, U01, X1AdjOrTrans_STAR_MR,
(T)1, Z0_MC_STAR );
//--------------------------------------------------------------------//
D11.FreeAlignments();
SlideLockedPartitionDownDiagonal
( UTL, /**/ UTR, U00, U01, /**/ U02,
/**/ U10, U11, /**/ U12,
//.........這裏部分代碼省略.........
示例2: PushCallStack
inline void
LU( DistMatrix<F>& A )
{
#ifndef RELEASE
PushCallStack("LU");
#endif
const Grid& g = A.Grid();
// 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);
// Temporary distributions
DistMatrix<F,STAR,STAR> A11_STAR_STAR(g);
DistMatrix<F,MC, STAR> A21_MC_STAR(g);
DistMatrix<F,STAR,VR > A12_STAR_VR(g);
DistMatrix<F,STAR,MR > A12_STAR_MR(g);
// Start the algorithm
PartitionDownDiagonal
( A, ATL, ATR,
ABL, ABR, 0 );
while( ATL.Height() < A.Height() && ATL.Width() < A.Width() )
{
RepartitionDownDiagonal
( ATL, /**/ ATR, A00, /**/ A01, A02,
/*************/ /******************/
/**/ A10, /**/ A11, A12,
ABL, /**/ ABR, A20, /**/ A21, A22 );
A12_STAR_VR.AlignWith( A22 );
A12_STAR_MR.AlignWith( A22 );
A21_MC_STAR.AlignWith( A22 );
A11_STAR_STAR.ResizeTo( A11.Height(), A11.Width() );
//--------------------------------------------------------------------//
A11_STAR_STAR = A11;
internal::LocalLU( A11_STAR_STAR );
A11 = A11_STAR_STAR;
A21_MC_STAR = A21;
internal::LocalTrsm
( RIGHT, UPPER, NORMAL, NON_UNIT, F(1), A11_STAR_STAR, A21_MC_STAR );
A21 = A21_MC_STAR;
// Perhaps we should give up perfectly distributing this operation since
// it's total contribution is only O(n^2)
A12_STAR_VR = A12;
internal::LocalTrsm
( LEFT, LOWER, NORMAL, UNIT, F(1), A11_STAR_STAR, A12_STAR_VR );
A12_STAR_MR = A12_STAR_VR;
internal::LocalGemm
( NORMAL, NORMAL, F(-1), A21_MC_STAR, A12_STAR_MR, F(1), A22 );
A12 = A12_STAR_MR;
//--------------------------------------------------------------------//
A12_STAR_VR.FreeAlignments();
A12_STAR_MR.FreeAlignments();
A21_MC_STAR.FreeAlignments();
SlidePartitionDownDiagonal
( ATL, /**/ ATR, A00, A01, /**/ A02,
/**/ A10, A11, /**/ A12,
/*************/ /******************/
ABL, /**/ ABR, A20, A21, /**/ A22 );
}
#ifndef RELEASE
PopCallStack();
#endif
}
示例3: PushCallStack
inline void
internal::SymmRUA
( T alpha, const DistMatrix<T,MC,MR>& A,
const DistMatrix<T,MC,MR>& B,
T beta, DistMatrix<T,MC,MR>& C )
{
#ifndef RELEASE
PushCallStack("internal::SymmRUA");
if( A.Grid() != B.Grid() || B.Grid() != C.Grid() )
throw std::logic_error
("{A,B,C} must be distributed over the same grid");
#endif
const Grid& g = A.Grid();
DistMatrix<T,MC,MR>
BT(g), B0(g),
BB(g), B1(g),
B2(g);
DistMatrix<T,MC,MR>
CT(g), C0(g),
CB(g), C1(g),
C2(g);
DistMatrix<T,MR, STAR> B1Trans_MR_STAR(g);
DistMatrix<T,VC, STAR> B1Trans_VC_STAR(g);
DistMatrix<T,STAR,MC > B1_STAR_MC(g);
DistMatrix<T,MC, STAR> Z1Trans_MC_STAR(g);
DistMatrix<T,MR, STAR> Z1Trans_MR_STAR(g);
DistMatrix<T,MC, MR > Z1Trans(g);
DistMatrix<T,MR, MC > Z1Trans_MR_MC(g);
Matrix<T> Z1Local;
Scal( beta, C );
LockedPartitionDown
( B, BT,
BB, 0 );
PartitionDown
( C, CT,
CB, 0 );
while( CT.Height() < C.Height() )
{
LockedRepartitionDown
( BT, B0,
/**/ /**/
B1,
BB, B2 );
RepartitionDown
( CT, C0,
/**/ /**/
C1,
CB, C2 );
B1Trans_MR_STAR.AlignWith( A );
B1Trans_VC_STAR.AlignWith( A );
B1_STAR_MC.AlignWith( A );
Z1Trans_MC_STAR.AlignWith( A );
Z1Trans_MR_STAR.AlignWith( A );
Z1Trans_MR_MC.AlignWith( C1 );
Z1Trans_MC_STAR.ResizeTo( C1.Width(), C1.Height() );
Z1Trans_MR_STAR.ResizeTo( C1.Width(), C1.Height() );
//--------------------------------------------------------------------//
B1Trans_MR_STAR.TransposeFrom( B1 );
B1Trans_VC_STAR = B1Trans_MR_STAR;
B1_STAR_MC.TransposeFrom( B1Trans_VC_STAR );
Zero( Z1Trans_MC_STAR );
Zero( Z1Trans_MR_STAR );
internal::LocalSymmetricAccumulateRU
( TRANSPOSE, alpha, A, B1_STAR_MC, B1Trans_MR_STAR,
Z1Trans_MC_STAR, Z1Trans_MR_STAR );
Z1Trans.SumScatterFrom( Z1Trans_MC_STAR );
Z1Trans_MR_MC = Z1Trans;
Z1Trans_MR_MC.SumScatterUpdate( (T)1, Z1Trans_MR_STAR );
Transpose( Z1Trans_MR_MC.LockedLocalMatrix(), Z1Local );
Axpy( (T)1, Z1Local, C1.LocalMatrix() );
//--------------------------------------------------------------------//
B1Trans_MR_STAR.FreeAlignments();
B1Trans_VC_STAR.FreeAlignments();
B1_STAR_MC.FreeAlignments();
Z1Trans_MC_STAR.FreeAlignments();
Z1Trans_MR_STAR.FreeAlignments();
Z1Trans_MR_MC.FreeAlignments();
SlideLockedPartitionDown
( BT, B0,
B1,
/**/ /**/
BB, B2 );
SlidePartitionDown
( CT, C0,
C1,
/**/ /**/
CB, C2 );
}
#ifndef RELEASE
PopCallStack();
//.........這裏部分代碼省略.........
示例4: Initialize
int
main( int argc, char* argv[] )
{
Initialize( argc, argv );
mpi::Comm comm = mpi::COMM_WORLD;
const int commRank = mpi::CommRank( comm );
try
{
const int m = Input("--height","height of matrix",20);
const int n = Input("--width","width of matrix",100);
const int maxSteps = Input("--maxSteps","max # of steps of QR",10);
const double tol = Input("--tol","tolerance for ID",-1.);
const bool print = Input("--print","print matrices?",false);
ProcessInput();
PrintInputReport();
DistMatrix<C> A;
Uniform( A, m, n );
const Real frobA = FrobeniusNorm( A );
if( print )
A.Print("A");
const Grid& g = A.Grid();
DistMatrix<int,VR,STAR> pR(g), pC(g);
DistMatrix<C> Z(g);
Skeleton( A, pR, pC, Z, maxSteps, tol );
const int numSteps = pR.Height();
if( print )
{
pR.Print("pR");
pC.Print("pC");
Z.Print("Z");
}
// Form the matrices of A's (hopefully) dominant rows and columns
DistMatrix<C> AR( A );
ApplyRowPivots( AR, pR );
AR.ResizeTo( numSteps, A.Width() );
DistMatrix<C> AC( A );
ApplyColumnPivots( AC, pC );
AC.ResizeTo( A.Height(), numSteps );
if( print )
{
AC.Print("AC");
AR.Print("AR");
}
// Check || A - AC Z AR ||_F / || A ||_F
DistMatrix<C> B(g);
Gemm( NORMAL, NORMAL, C(1), Z, AR, B );
Gemm( NORMAL, NORMAL, C(-1), AC, B, C(1), A );
const Real frobError = FrobeniusNorm( A );
if( print )
A.Print("A - AC Z AR");
if( commRank == 0 )
{
std::cout << "|| A ||_F = " << frobA << "\n\n"
<< "|| A - AC Z AR ||_F / || A ||_F = "
<< frobError/frobA << "\n" << std::endl;
}
}
catch( ArgException& e )
{
// There is nothing to do
}
catch( exception& e )
{
ostringstream os;
os << "Process " << commRank << " caught exception with message: "
<< e.what() << endl;
cerr << os.str();
#ifndef RELEASE
DumpCallStack();
#endif
}
Finalize();
return 0;
}
示例5: logic_error
inline void
Inverse( DistMatrix<F>& A )
{
#ifndef RELEASE
PushCallStack("Inverse");
if( A.Height() != A.Width() )
throw std::logic_error("Cannot invert non-square matrices");
#endif
const Grid& g = A.Grid();
DistMatrix<int,VC,STAR> p( g );
LU( A, p );
TriangularInverse( UPPER, NON_UNIT, A );
// Solve inv(A) L = inv(U) for inv(A)
DistMatrix<F> ATL(g), ATR(g),
ABL(g), ABR(g);
DistMatrix<F> A00(g), A01(g), A02(g),
A10(g), A11(g), A12(g),
A20(g), A21(g), A22(g);
DistMatrix<F> A1(g), A2(g);
DistMatrix<F,VC, STAR> A1_VC_STAR(g);
DistMatrix<F,STAR,STAR> L11_STAR_STAR(g);
DistMatrix<F,VR, STAR> L21_VR_STAR(g);
DistMatrix<F,STAR,MR > L21Trans_STAR_MR(g);
DistMatrix<F,MC, STAR> Z1(g);
PartitionUpDiagonal
( A, ATL, ATR,
ABL, ABR, 0 );
while( ABR.Height() < A.Height() )
{
RepartitionUpDiagonal
( ATL, /**/ ATR, A00, A01, /**/ A02,
/**/ A10, A11, /**/ A12,
/*************/ /******************/
ABL, /**/ ABR, A20, A21, /**/ A22 );
View( A1, A, 0, A00.Width(), A.Height(), A01.Width() );
View( A2, A, 0, A00.Width()+A01.Width(), A.Height(), A02.Width() );
L21_VR_STAR.AlignWith( A2 );
L21Trans_STAR_MR.AlignWith( A2 );
Z1.AlignWith( A01 );
Z1.ResizeTo( A.Height(), A01.Width() );
//--------------------------------------------------------------------//
// Copy out L1
L11_STAR_STAR = A11;
L21_VR_STAR = A21;
L21Trans_STAR_MR.TransposeFrom( L21_VR_STAR );
// Zero the strictly lower triangular portion of A1
MakeTrapezoidal( LEFT, UPPER, 0, A11 );
Zero( A21 );
// Perform the lazy update of A1
internal::LocalGemm
( NORMAL, TRANSPOSE,
F(-1), A2, L21Trans_STAR_MR, F(0), Z1 );
A1.SumScatterUpdate( F(1), Z1 );
// Solve against this diagonal block of L11
A1_VC_STAR = A1;
internal::LocalTrsm
( RIGHT, LOWER, NORMAL, UNIT, F(1), L11_STAR_STAR, A1_VC_STAR );
A1 = A1_VC_STAR;
//--------------------------------------------------------------------//
Z1.FreeAlignments();
L21Trans_STAR_MR.FreeAlignments();
L21_VR_STAR.FreeAlignments();
SlidePartitionUpDiagonal
( ATL, /**/ ATR, A00, /**/ A01, A02,
/*************/ /*******************/
/**/ A10, /**/ A11, A12,
ABL, /**/ ABR, A20, /**/ A21, A22 );
}
// inv(A) := inv(A) P
ApplyInverseColumnPivots( A, p );
#ifndef RELEASE
PopCallStack();
#endif
}
示例6: logic_error
inline void
LocalSymvRowAccumulateU
( T alpha,
const DistMatrix<T>& A,
const DistMatrix<T,STAR,MC>& x_STAR_MC,
const DistMatrix<T,STAR,MR>& x_STAR_MR,
DistMatrix<T,STAR,MC>& z_STAR_MC,
DistMatrix<T,STAR,MR>& z_STAR_MR )
{
#ifndef RELEASE
PushCallStack("internal::LocalSymvRowAccumulateU");
if( A.Grid() != x_STAR_MC.Grid() ||
x_STAR_MC.Grid() != x_STAR_MR.Grid() ||
x_STAR_MR.Grid() != z_STAR_MC.Grid() ||
z_STAR_MC.Grid() != z_STAR_MR.Grid() )
throw std::logic_error
("{A,x,z} must be distributed over the same grid");
if( x_STAR_MC.Height() != 1 || x_STAR_MR.Height() != 1 ||
z_STAR_MC.Height() != 1 || z_STAR_MR.Height() != 1 )
throw std::logic_error("Expected x and z to be row vectors");
if( A.Height() != A.Width() ||
A.Height() != x_STAR_MC.Width() ||
A.Height() != x_STAR_MR.Width() ||
A.Height() != z_STAR_MC.Width() ||
A.Height() != z_STAR_MR.Width() )
{
std::ostringstream msg;
msg << "Nonconformal LocalSymvRowAccumulateU: \n"
<< " A ~ " << A.Height() << " x " << A.Width() << "\n"
<< " x[* ,MC] ~ " << x_STAR_MC.Height() << " x "
<< x_STAR_MC.Width() << "\n"
<< " x[* ,MR] ~ " << x_STAR_MR.Height() << " x "
<< x_STAR_MR.Width() << "\n"
<< " z[* ,MC] ~ " << z_STAR_MC.Height() << " x "
<< z_STAR_MC.Width() << "\n"
<< " z[* ,MR] ~ " << z_STAR_MR.Height() << " x "
<< z_STAR_MR.Width() << "\n";
throw std::logic_error( msg.str() );
}
if( x_STAR_MC.RowAlignment() != A.ColAlignment() ||
x_STAR_MR.RowAlignment() != A.RowAlignment() ||
z_STAR_MC.RowAlignment() != A.ColAlignment() ||
z_STAR_MR.RowAlignment() != A.RowAlignment() )
throw std::logic_error("Partial matrix distributions are misaligned");
#endif
const Grid& g = A.Grid();
// Matrix views
DistMatrix<T> A11(g), A12(g);
DistMatrix<T> D11(g);
DistMatrix<T,STAR,MC> x1_STAR_MC(g);
DistMatrix<T,STAR,MR>
xL_STAR_MR(g), xR_STAR_MR(g),
x0_STAR_MR(g), x1_STAR_MR(g), x2_STAR_MR(g);
DistMatrix<T,STAR,MC> z1_STAR_MC(g);
DistMatrix<T,STAR,MR> z1_STAR_MR(g), z2_STAR_MR(g);
// We want our local gemvs to be of width blocksize, so we will
// temporarily change to max(r,c) times the current blocksize
const int ratio = std::max( g.Height(), g.Width() );
PushBlocksizeStack( ratio*LocalSymvBlocksize<T>() );
LockedPartitionRight( x_STAR_MR, xL_STAR_MR, xR_STAR_MR, 0 );
while( xL_STAR_MR.Width() < x_STAR_MR.Width() )
{
LockedRepartitionRight
( xL_STAR_MR, /**/ xR_STAR_MR,
x0_STAR_MR, /**/ x1_STAR_MR, x2_STAR_MR );
const int n0 = x0_STAR_MR.Width();
const int n1 = x1_STAR_MR.Width();
const int n2 = x2_STAR_MR.Width();
LockedView( A11, A, n0, n0, n1, n1 );
LockedView( A12, A, n0, n0+n1, n1, n2 );
LockedView( x1_STAR_MC, x_STAR_MC, 0, n0, 1, n1 );
View( z1_STAR_MC, z_STAR_MC, 0, n0, 1, n1 );
View( z1_STAR_MR, z_STAR_MR, 0, n0, 1, n1 );
View( z2_STAR_MR, z_STAR_MR, 0, n0+n1, 1, n2 );
D11.AlignWith( A11 );
//--------------------------------------------------------------------//
// TODO: These diagonal block updates can be greatly improved
D11 = A11;
MakeTrapezoidal( LEFT, UPPER, 0, D11 );
Gemv
( NORMAL,
alpha, D11.LockedLocalMatrix(),
x1_STAR_MR.LockedLocalMatrix(),
T(1), z1_STAR_MC.LocalMatrix() );
MakeTrapezoidal( LEFT, UPPER, 1, D11 );
Gemv
( TRANSPOSE,
alpha, D11.LockedLocalMatrix(),
x1_STAR_MC.LockedLocalMatrix(),
T(1), z1_STAR_MR.LocalMatrix() );
Gemv
( NORMAL,
alpha, A12.LockedLocalMatrix(),
//.........這裏部分代碼省略.........
示例7: entry
inline void
TrtrsmLLN
( UnitOrNonUnit diag, F alpha, const DistMatrix<F>& L, DistMatrix<F>& X,
bool checkIfSingular )
{
#ifndef RELEASE
CallStackEntry entry("internal::TrtrsmLLN");
#endif
const Grid& g = L.Grid();
// Matrix views
DistMatrix<F>
LTL(g), LTR(g), L00(g), L01(g), L02(g),
LBL(g), LBR(g), L10(g), L11(g), L12(g),
L20(g), L21(g), L22(g);
DistMatrix<F>
XTL(g), XTR(g), X00(g), X01(g), X02(g),
XBL(g), XBR(g), X10(g), X11(g), X12(g),
X20(g), X21(g), X22(g);
// Temporary distributions
DistMatrix<F,STAR,STAR> L11_STAR_STAR(g);
DistMatrix<F,MC, STAR> L21_MC_STAR(g);
DistMatrix<F,STAR,MR > X10_STAR_MR(g);
DistMatrix<F,STAR,VR > X10_STAR_VR(g);
DistMatrix<F,STAR,MR > X11_STAR_MR(g);
DistMatrix<F,STAR,STAR> X11_STAR_STAR(g);
// Start the algorithm
ScaleTrapezoid( alpha, LOWER, X );
LockedPartitionDownDiagonal
( L, LTL, LTR,
LBL, LBR, 0 );
PartitionDownDiagonal
( X, XTL, XTR,
XBL, XBR, 0 );
while( XBR.Height() > 0 )
{
LockedRepartitionDownDiagonal
( LTL, /**/ LTR, L00, /**/ L01, L02,
/*************/ /******************/
/**/ L10, /**/ L11, L12,
LBL, /**/ LBR, L20, /**/ L21, L22 );
RepartitionDownDiagonal
( XTL, /**/ XTR, X00, /**/ X01, X02,
/*************/ /******************/
/**/ X10, /**/ X11, X12,
XBL, /**/ XBR, X20, /**/ X21, X22 );
L21_MC_STAR.AlignWith( X20 );
X10_STAR_MR.AlignWith( X20 );
X11_STAR_MR.AlignWith( X21 );
//--------------------------------------------------------------------//
L11_STAR_STAR = L11;
X11_STAR_STAR = X11;
X10_STAR_VR = X10;
LocalTrsm
( LEFT, LOWER, NORMAL, diag, F(1), L11_STAR_STAR, X10_STAR_VR,
checkIfSingular );
LocalTrtrsm
( LEFT, LOWER, NORMAL, diag, F(1), L11_STAR_STAR, X11_STAR_STAR,
checkIfSingular );
X11 = X11_STAR_STAR;
X11_STAR_MR = X11_STAR_STAR;
MakeTriangular( LOWER, X11_STAR_MR );
X10_STAR_MR = X10_STAR_VR;
X10 = X10_STAR_MR;
L21_MC_STAR = L21;
LocalGemm
( NORMAL, NORMAL, F(-1), L21_MC_STAR, X10_STAR_MR, F(1), X20 );
LocalGemm
( NORMAL, NORMAL, F(-1), L21_MC_STAR, X11_STAR_MR, F(1), X21 );
//--------------------------------------------------------------------//
SlideLockedPartitionDownDiagonal
( LTL, /**/ LTR, L00, L01, /**/ L02,
/**/ L10, L11, /**/ L12,
/*************/ /******************/
LBL, /**/ LBR, L20, L21, /**/ L22 );
SlidePartitionDownDiagonal
( XTL, /**/ XTR, X00, X01, /**/ X02,
/**/ X10, X11, /**/ X12,
/*************/ /******************/
XBL, /**/ XBR, X20, X21, /**/ X22 );
}
}
示例8: d
void TestCorrectness
( bool print,
UpperOrLower uplo,
const DistMatrix<Complex<R> >& A,
const DistMatrix<Complex<R>,STAR,STAR>& t,
DistMatrix<Complex<R> >& AOrig )
{
typedef Complex<R> C;
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<R,MD,STAR> d(g);
DistMatrix<R,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<R,STAR,STAR> e_STAR_STAR(g);
DistMatrix<R,MD,STAR> eOpposite(g);
e_STAR_STAR = e;
eOpposite.AlignWithDiagonal( A, -subdiagonal );
eOpposite = e_STAR_STAR;
// Zero B and then fill its tridiagonal
DistMatrix<C> B(g);
B.AlignWith( A );
Zeros( m, m, B );
B.SetRealPartOfDiagonal( d );
B.SetRealPartOfDiagonal( e, subdiagonal );
B.SetRealPartOfDiagonal( eOpposite, -subdiagonal );
// Reverse the accumulated Householder transforms, ignoring symmetry
if( uplo == LOWER )
{
ApplyPackedReflectors
( LEFT, LOWER, VERTICAL, BACKWARD,
UNCONJUGATED, subdiagonal, A, t, B );
ApplyPackedReflectors
( RIGHT, LOWER, VERTICAL, BACKWARD,
CONJUGATED, subdiagonal, A, t, B );
}
else
{
ApplyPackedReflectors
( LEFT, UPPER, VERTICAL, FORWARD,
UNCONJUGATED, subdiagonal, A, t, B );
ApplyPackedReflectors
( RIGHT, UPPER, VERTICAL, FORWARD,
CONJUGATED, subdiagonal, A, t, B );
}
// Compare the appropriate triangle of AOrig and B
MakeTriangular( uplo, AOrig );
MakeTriangular( uplo, B );
Axpy( C(-1), AOrig, B );
const R infNormOfAOrig = HermitianNorm( uplo, AOrig, INFINITY_NORM );
const R frobNormOfAOrig = HermitianNorm( uplo, AOrig, FROBENIUS_NORM );
const R infNormOfError = HermitianNorm( uplo, B, INFINITY_NORM );
const R frobNormOfError = HermitianNorm( uplo, B, FROBENIUS_NORM );
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;
}
}
示例9: logic_error
inline void
HermitianTridiagL
( DistMatrix<Complex<R> >& A,
DistMatrix<Complex<R>,STAR,STAR>& t )
{
#ifndef RELEASE
PushCallStack("internal::HermitianTridiagL");
if( A.Grid() != t.Grid() )
throw std::logic_error("{A,t} must be distributed over the same grid");
if( A.Height() != A.Width() )
throw std::logic_error("A must be square");
if( t.Viewing() )
throw std::logic_error("t must not be a view");
#endif
typedef Complex<R> C;
const Grid& g = A.Grid();
DistMatrix<C,MD,STAR> tDiag(g);
tDiag.AlignWithDiagonal( A, -1 );
tDiag.ResizeTo( A.Height()-1, 1 );
// Matrix views
DistMatrix<C>
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<C,MD,STAR> tT(g), t0(g),
tB(g), t1(g),
t2(g);
// Temporary distributions
DistMatrix<C> WPan(g);
DistMatrix<C,STAR,STAR> t1_STAR_STAR(g);
DistMatrix<C,STAR,STAR> A11_STAR_STAR(g);
DistMatrix<C,MC, STAR> APan_MC_STAR(g), A11_MC_STAR(g),
A21_MC_STAR(g);
DistMatrix<C,MR, STAR> APan_MR_STAR(g), A11_MR_STAR(g),
A21_MR_STAR(g);
DistMatrix<C,MC, STAR> WPan_MC_STAR(g), W11_MC_STAR(g),
W21_MC_STAR(g);
DistMatrix<C,MR, STAR> WPan_MR_STAR(g), W11_MR_STAR(g),
W21_MR_STAR(g);
PartitionDownDiagonal
( A, ATL, ATR,
ABL, ABR, 0 );
PartitionDown
( tDiag, tT,
tB, 0 );
while( ATL.Height() < A.Height() )
{
RepartitionDownDiagonal
( ATL, /**/ ATR, A00, /**/ A01, A02,
/*************/ /******************/
/**/ A10, /**/ A11, A12,
ABL, /**/ ABR, A20, /**/ A21, A22 );
RepartitionDown
( tT, t0,
/**/ /**/
t1,
tB, t2 );
if( A22.Height() > 0 )
{
WPan.AlignWith( A11 );
APan_MC_STAR.AlignWith( A11 );
WPan_MC_STAR.AlignWith( A11 );
APan_MR_STAR.AlignWith( A11 );
WPan_MR_STAR.AlignWith( A11 );
//----------------------------------------------------------------//
WPan.ResizeTo( ABR.Height(), A11.Width() );
APan_MC_STAR.ResizeTo( ABR.Height(), A11.Width() );
WPan_MC_STAR.ResizeTo( ABR.Height(), A11.Width() );
APan_MR_STAR.ResizeTo( ABR.Height(), A11.Width() );
WPan_MR_STAR.ResizeTo( ABR.Height(), A11.Width() );
HermitianPanelTridiagL
( ABR, WPan, t1,
APan_MC_STAR, APan_MR_STAR, WPan_MC_STAR, WPan_MR_STAR );
PartitionDown
( APan_MC_STAR, A11_MC_STAR,
A21_MC_STAR, A11.Height() );
PartitionDown
( APan_MR_STAR, A11_MR_STAR,
A21_MR_STAR, A11.Height() );
PartitionDown
( WPan_MC_STAR, W11_MC_STAR,
W21_MC_STAR, A11.Height() );
PartitionDown
( WPan_MR_STAR, W11_MR_STAR,
W21_MR_STAR, A11.Height() );
LocalTrr2k
( LOWER, ADJOINT, ADJOINT,
C(-1), A21_MC_STAR, W21_MR_STAR,
W21_MC_STAR, A21_MR_STAR,
C(1), A22 );
//----------------------------------------------------------------//
//.........這裏部分代碼省略.........
示例10: logic_error
inline void
internal::HegstLUVar2( DistMatrix<F,MC,MR>& A, const DistMatrix<F,MC,MR>& U )
{
#ifndef RELEASE
PushCallStack("internal::HegstLUVar2");
if( A.Height() != A.Width() )
throw std::logic_error("A must be square");
if( U.Height() != U.Width() )
throw std::logic_error("Triangular matrices must be square");
if( A.Height() != U.Height() )
throw std::logic_error("A and U must be the same size");
#endif
const Grid& g = A.Grid();
// Matrix views
DistMatrix<F,MC,MR>
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,MR>
UTL(g), UTR(g), U00(g), U01(g), U02(g),
UBL(g), UBR(g), U10(g), U11(g), U12(g),
U20(g), U21(g), U22(g);
// Temporary distributions
DistMatrix<F,VC, STAR> A01_VC_STAR(g);
DistMatrix<F,STAR,STAR> A11_STAR_STAR(g);
DistMatrix<F,STAR,VR > A12_STAR_VR(g);
DistMatrix<F,STAR,STAR> U11_STAR_STAR(g);
DistMatrix<F,STAR,MC > U12_STAR_MC(g);
DistMatrix<F,STAR,VR > U12_STAR_VR(g);
DistMatrix<F,MR, STAR> U12Adj_MR_STAR(g);
DistMatrix<F,VC, STAR> U12Adj_VC_STAR(g);
DistMatrix<F,MC, STAR> X01_MC_STAR(g);
DistMatrix<F,STAR,STAR> X11_STAR_STAR(g);
DistMatrix<F,MC, MR > Y12(g);
DistMatrix<F,MC, MR > Z12Adj(g);
DistMatrix<F,MR, MC > Z12Adj_MR_MC(g);
DistMatrix<F,MC, STAR> Z12Adj_MC_STAR(g);
DistMatrix<F,MR, STAR> Z12Adj_MR_STAR(g);
PartitionDownDiagonal
( A, ATL, ATR,
ABL, ABR, 0 );
LockedPartitionDownDiagonal
( U, UTL, UTR,
UBL, UBR, 0 );
while( ATL.Height() < A.Height() )
{
RepartitionDownDiagonal
( ATL, /**/ ATR, A00, /**/ A01, A02,
/*************/ /******************/
/**/ A10, /**/ A11, A12,
ABL, /**/ ABR, A20, /**/ A21, A22 );
LockedRepartitionDownDiagonal
( UTL, /**/ UTR, U00, /**/ U01, U02,
/*************/ /******************/
/**/ U10, /**/ U11, U12,
UBL, /**/ UBR, U20, /**/ U21, U22 );
A12_STAR_VR.AlignWith( A12 );
U12_STAR_MC.AlignWith( A22 );
U12_STAR_VR.AlignWith( A12 );
U12Adj_MR_STAR.AlignWith( A22 );
U12Adj_VC_STAR.AlignWith( A22 );
X01_MC_STAR.AlignWith( A01 );
Y12.AlignWith( A12 );
Z12Adj.AlignWith( A12 );
Z12Adj_MR_MC.AlignWith( A12 );
Z12Adj_MC_STAR.AlignWith( A22 );
Z12Adj_MR_STAR.AlignWith( A22 );
//--------------------------------------------------------------------//
// A01 := A01 U11'
U11_STAR_STAR = U11;
A01_VC_STAR = A01;
internal::LocalTrmm
( RIGHT, UPPER, ADJOINT, NON_UNIT, (F)1, U11_STAR_STAR, A01_VC_STAR );
A01 = A01_VC_STAR;
// A01 := A01 + A02 U12'
U12Adj_MR_STAR.AdjointFrom( U12 );
X01_MC_STAR.ResizeTo( A01.Height(), A01.Width() );
internal::LocalGemm
( NORMAL, NORMAL,
(F)1, A02, U12Adj_MR_STAR, (F)0, X01_MC_STAR );
A01.SumScatterUpdate( (F)1, X01_MC_STAR );
// Y12 := U12 A22
U12Adj_VC_STAR = U12Adj_MR_STAR;
U12_STAR_MC.AdjointFrom( U12Adj_VC_STAR );
Z12Adj_MC_STAR.ResizeTo( A12.Width(), A12.Height() );
Z12Adj_MR_STAR.ResizeTo( A12.Width(), A12.Height() );
Zero( Z12Adj_MC_STAR );
Zero( Z12Adj_MR_STAR );
internal::LocalSymmetricAccumulateRU
( ADJOINT,
(F)1, A22, U12_STAR_MC, U12Adj_MR_STAR,
Z12Adj_MC_STAR, Z12Adj_MR_STAR );
//.........這裏部分代碼省略.........
示例11: BASE
void TestCorrectness
( const DistMatrix<F>& A,
const DistMatrix<F,MD,STAR>& t,
DistMatrix<F>& AOrig )
{
typedef BASE(F) Real;
const Grid& g = A.Grid();
const Int m = A.Height();
const Int n = A.Width();
const Int minDim = std::min(m,n);
if( g.Rank() == 0 )
cout << " Testing orthogonality of Q..." << endl;
// Form Z := Q Q^H as an approximation to identity
DistMatrix<F> Z(g);
Identity( Z, m, n );
rq::ApplyQ( RIGHT, NORMAL, A, t, Z );
rq::ApplyQ( RIGHT, ADJOINT, A, t, Z );
DistMatrix<F> ZUpper(g);
View( ZUpper, Z, 0, 0, minDim, minDim );
// Form Identity
DistMatrix<F> X(g);
Identity( X, minDim, minDim );
// Form X := I - Q Q^H
Axpy( F(-1), ZUpper, X );
Real oneNormOfError = OneNorm( X );
Real infNormOfError = InfinityNorm( X );
Real frobNormOfError = FrobeniusNorm( X );
if( g.Rank() == 0 )
{
cout << " ||Q^H Q - I||_1 = " << oneNormOfError << "\n"
<< " ||Q^H Q - I||_oo = " << infNormOfError << "\n"
<< " ||Q^H Q - I||_F = " << frobNormOfError << endl;
}
if( g.Rank() == 0 )
cout << " Testing if A = RQ..." << endl;
// Form RQ
DistMatrix<F> U( A );
MakeTrapezoidal( UPPER, U, 0, RIGHT );
rq::ApplyQ( RIGHT, NORMAL, A, t, U );
// Form R Q - A
Axpy( F(-1), AOrig, U );
const Real oneNormOfA = OneNorm( AOrig );
const Real infNormOfA = InfinityNorm( AOrig );
const Real frobNormOfA = FrobeniusNorm( AOrig );
oneNormOfError = OneNorm( U );
infNormOfError = InfinityNorm( U );
frobNormOfError = FrobeniusNorm( U );
if( g.Rank() == 0 )
{
cout << " ||A||_1 = " << oneNormOfA << "\n"
<< " ||A||_oo = " << infNormOfA << "\n"
<< " ||A||_F = " << frobNormOfA << "\n"
<< " ||A - RQ||_1 = " << oneNormOfError << "\n"
<< " ||A - RQ||_oo = " << infNormOfError << "\n"
<< " ||A - RQ||_F = " << frobNormOfError << endl;
}
}
示例12: entry
void Trr2kNNTN
( UpperOrLower uplo,
Orientation orientationOfC,
T alpha, const DistMatrix<T>& A, const DistMatrix<T>& B,
const DistMatrix<T>& C, const DistMatrix<T>& D,
T beta, DistMatrix<T>& E )
{
#ifndef RELEASE
CallStackEntry entry("internal::Trr2kNNTN");
if( E.Height() != E.Width() || A.Width() != C.Height() ||
A.Height() != E.Height() || C.Width() != E.Height() ||
B.Width() != E.Width() || D.Width() != E.Width() ||
A.Width() != B.Height() || C.Height() != D.Height() )
throw std::logic_error("Nonconformal Trr2kNNTN");
#endif
const Grid& g = E.Grid();
DistMatrix<T> AL(g), AR(g),
A0(g), A1(g), A2(g);
DistMatrix<T> BT(g), B0(g),
BB(g), B1(g),
B2(g);
DistMatrix<T> CT(g), C0(g),
CB(g), C1(g),
C2(g);
DistMatrix<T> DT(g), D0(g),
DB(g), D1(g),
D2(g);
DistMatrix<T,MC, STAR> A1_MC_STAR(g);
DistMatrix<T,MR, STAR> B1Trans_MR_STAR(g);
DistMatrix<T,STAR,MC > C1_STAR_MC(g);
DistMatrix<T,MR, STAR> D1Trans_MR_STAR(g);
A1_MC_STAR.AlignWith( E );
B1Trans_MR_STAR.AlignWith( E );
C1_STAR_MC.AlignWith( E );
D1Trans_MR_STAR.AlignWith( E );
LockedPartitionRight( A, AL, AR, 0 );
LockedPartitionDown
( B, BT,
BB, 0 );
LockedPartitionDown
( C, CT,
CB, 0 );
LockedPartitionDown
( D, DT,
DB, 0 );
while( AL.Width() < A.Width() )
{
LockedRepartitionRight
( AL, /**/ AR,
A0, /**/ A1, A2 );
LockedRepartitionDown
( BT, B0,
/**/ /**/
B1,
BB, B2 );
LockedRepartitionDown
( CT, C0,
/**/ /**/
C1,
CB, C2 );
LockedRepartitionDown
( DT, D0,
/**/ /**/
D1,
DB, D2 );
//--------------------------------------------------------------------//
A1_MC_STAR = A1;
C1_STAR_MC = C1;
B1Trans_MR_STAR.TransposeFrom( B1 );
D1Trans_MR_STAR.TransposeFrom( D1 );
LocalTrr2k
( uplo, TRANSPOSE, orientationOfC, TRANSPOSE,
alpha, A1_MC_STAR, B1Trans_MR_STAR,
C1_STAR_MC, D1Trans_MR_STAR,
beta, E );
//--------------------------------------------------------------------//
SlideLockedPartitionDown
( DT, D0,
D1,
/**/ /**/
DB, D2 );
SlideLockedPartitionDown
( CT, C0,
C1,
/**/ /**/
CB, C2 );
SlideLockedPartitionDown
( BT, B0,
B1,
/**/ /**/
BB, B2 );
SlideLockedPartitionRight
( AL, /**/ AR,
//.........這裏部分代碼省略.........
示例13: logic_error
inline void
TwoSidedTrsmUVar1
( UnitOrNonUnit diag, DistMatrix<F>& A, const DistMatrix<F>& U )
{
#ifndef RELEASE
PushCallStack("internal::TwoSidedTrsmUVar1");
if( A.Height() != A.Width() )
throw std::logic_error("A must be square");
if( U.Height() != U.Width() )
throw std::logic_error("Triangular matrices must be square");
if( A.Height() != U.Height() )
throw std::logic_error("A and U must be the same size");
#endif
const Grid& g = A.Grid();
// 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>
UTL(g), UTR(g), U00(g), U01(g), U02(g),
UBL(g), UBR(g), U10(g), U11(g), U12(g),
U20(g), U21(g), U22(g);
// Temporary distributions
DistMatrix<F,STAR,STAR> A11_STAR_STAR(g);
DistMatrix<F,VC, STAR> A01_VC_STAR(g);
DistMatrix<F,STAR,STAR> U11_STAR_STAR(g);
DistMatrix<F,MC, STAR> U01_MC_STAR(g);
DistMatrix<F,VC, STAR> U01_VC_STAR(g);
DistMatrix<F,VR, STAR> U01_VR_STAR(g);
DistMatrix<F,STAR,MR > U01Adj_STAR_MR(g);
DistMatrix<F,STAR,STAR> X11_STAR_STAR(g);
DistMatrix<F,MR, MC > Z01_MR_MC(g);
DistMatrix<F,MC, STAR> Z01_MC_STAR(g);
DistMatrix<F,MR, STAR> Z01_MR_STAR(g);
DistMatrix<F> Y01(g);
PartitionDownDiagonal
( A, ATL, ATR,
ABL, ABR, 0 );
LockedPartitionDownDiagonal
( U, UTL, UTR,
UBL, UBR, 0 );
while( ATL.Height() < A.Height() )
{
RepartitionDownDiagonal
( ATL, /**/ ATR, A00, /**/ A01, A02,
/*************/ /******************/
/**/ A10, /**/ A11, A12,
ABL, /**/ ABR, A20, /**/ A21, A22 );
LockedRepartitionDownDiagonal
( UTL, /**/ UTR, U00, /**/ U01, U02,
/*************/ /******************/
/**/ U10, /**/ U11, U12,
UBL, /**/ UBR, U20, /**/ U21, U22 );
A01_VC_STAR.AlignWith( A01 );
U01_MC_STAR.AlignWith( A00 );
U01_VR_STAR.AlignWith( A00 );
U01_VC_STAR.AlignWith( A00 );
U01Adj_STAR_MR.AlignWith( A00 );
Y01.AlignWith( A01 );
Z01_MR_MC.AlignWith( A01 );
Z01_MC_STAR.AlignWith( A00 );
Z01_MR_STAR.AlignWith( A00 );
//--------------------------------------------------------------------//
// Y01 := A00 U01
U01_MC_STAR = U01;
U01_VR_STAR = U01_MC_STAR;
U01Adj_STAR_MR.AdjointFrom( U01_VR_STAR );
Z01_MC_STAR.ResizeTo( A01.Height(), A01.Width() );
Z01_MR_STAR.ResizeTo( A01.Height(), A01.Width() );
Zero( Z01_MC_STAR );
Zero( Z01_MR_STAR );
LocalSymmetricAccumulateLU
( ADJOINT,
F(1), A00, U01_MC_STAR, U01Adj_STAR_MR, Z01_MC_STAR, Z01_MR_STAR );
Z01_MR_MC.SumScatterFrom( Z01_MR_STAR );
Y01 = Z01_MR_MC;
Y01.SumScatterUpdate( F(1), Z01_MC_STAR );
// A01 := inv(U00)' A01
//
// This is the bottleneck because A01 only has blocksize columns
Trsm( LEFT, UPPER, ADJOINT, diag, F(1), U00, A01 );
// A01 := A01 - 1/2 Y01
Axpy( F(-1)/F(2), Y01, A01 );
// A11 := A11 - (U01' A01 + A01' U01)
A01_VC_STAR = A01;
U01_VC_STAR = U01_MC_STAR;
X11_STAR_STAR.ResizeTo( A11.Height(), A11.Width() );
Her2k
( UPPER, ADJOINT,
F(-1), A01_VC_STAR.LocalMatrix(), U01_VC_STAR.LocalMatrix(),
F(0), X11_STAR_STAR.LocalMatrix() );
//.........這裏部分代碼省略.........
示例14: InPlaceRedist
void InPlaceRedist( DistMatrix<F>& Z, Int rowAlign, const Base<F>* readBuffer )
{
typedef Base<F> Real;
const Grid& g = Z.Grid();
const Int height = Z.Height();
const Int width = Z.Width();
const Int r = g.Height();
const Int c = g.Width();
const Int p = r * c;
const Int row = g.Row();
const Int col = g.Col();
const Int rowShift = Z.RowShift();
const Int colAlign = Z.ColAlign();
const Int localWidth = Length(width,g.VRRank(),rowAlign,p);
const Int maxHeight = MaxLength(height,r);
const Int maxWidth = MaxLength(width,p);
const Int portionSize = mpi::Pad( maxHeight*maxWidth );
// Allocate our send/recv buffers
vector<Real> buffer(2*r*portionSize);
Real* sendBuffer = &buffer[0];
Real* recvBuffer = &buffer[r*portionSize];
// Pack
EL_OUTER_PARALLEL_FOR
for( Int k=0; k<r; ++k )
{
Real* data = &sendBuffer[k*portionSize];
const Int thisColShift = Shift(k,colAlign,r);
const Int thisLocalHeight = Length(height,thisColShift,r);
EL_INNER_PARALLEL_FOR_COLLAPSE2
for( Int j=0; j<localWidth; ++j )
for( Int i=0; i<thisLocalHeight; ++i )
data[i+j*thisLocalHeight] =
readBuffer[thisColShift+i*r+j*height];
}
// Communicate
mpi::AllToAll
( sendBuffer, portionSize,
recvBuffer, portionSize, g.ColComm() );
// Unpack
const Int localHeight = Length(height,row,colAlign,r);
EL_OUTER_PARALLEL_FOR
for( Int k=0; k<r; ++k )
{
const Real* data = &recvBuffer[k*portionSize];
const Int thisRank = col+k*c;
const Int thisRowShift = Shift(thisRank,rowAlign,p);
const Int thisRowOffset = (thisRowShift-rowShift) / c;
const Int thisLocalWidth = Length(width,thisRowShift,p);
EL_INNER_PARALLEL_FOR
for( Int j=0; j<thisLocalWidth; ++j )
{
const Real* dataCol = &(data[j*localHeight]);
Real* thisCol = (Real*)Z.Buffer(0,thisRowOffset+j*r);
if( IsComplex<F>::value )
{
for( Int i=0; i<localHeight; ++i )
{
thisCol[2*i] = dataCol[i];
thisCol[2*i+1] = 0;
}
}
else
{
MemCopy( thisCol, dataCol, localHeight );
}
}
}
}
示例15: logic_error
inline void
Syr2kLT
( T alpha, const DistMatrix<T>& A, const DistMatrix<T>& B,
T beta, DistMatrix<T>& C )
{
#ifndef RELEASE
PushCallStack("internal::Syr2kLT");
if( A.Grid() != B.Grid() || B.Grid() != C.Grid() )
throw std::logic_error
("{A,B,C} must be distributed over the same grid");
if( A.Width() != C.Height() ||
A.Width() != C.Width() ||
B.Width() != C.Height() ||
B.Width() != C.Width() ||
A.Height() != B.Height() )
{
std::ostringstream msg;
msg << "Nonconformal Syr2kLT:\n"
<< " A ~ " << A.Height() << " x " << A.Width() << "\n"
<< " B ~ " << B.Height() << " x " << B.Width() << "\n"
<< " C ~ " << C.Height() << " x " << C.Width() << "\n";
throw std::logic_error( msg.str().c_str() );
}
#endif
const Grid& g = A.Grid();
// Matrix views
DistMatrix<T> AT(g), A0(g),
AB(g), A1(g),
A2(g);
DistMatrix<T> BT(g), B0(g),
BB(g), B1(g),
B2(g);
// Temporary distributions
DistMatrix<T,MR, STAR> A1Trans_MR_STAR(g);
DistMatrix<T,MR, STAR> B1Trans_MR_STAR(g);
DistMatrix<T,STAR,VR > A1_STAR_VR(g);
DistMatrix<T,STAR,VR > B1_STAR_VR(g);
DistMatrix<T,STAR,MC > A1_STAR_MC(g);
DistMatrix<T,STAR,MC > B1_STAR_MC(g);
A1Trans_MR_STAR.AlignWith( C );
B1Trans_MR_STAR.AlignWith( C );
A1_STAR_MC.AlignWith( C );
B1_STAR_MC.AlignWith( C );
// Start the algorithm
ScaleTrapezoid( beta, LEFT, LOWER, 0, C );
LockedPartitionDown
( A, AT,
AB, 0 );
LockedPartitionDown
( B, BT,
BB, 0 );
while( AB.Height() > 0 )
{
LockedRepartitionDown
( AT, A0,
/**/ /**/
A1,
AB, A2 );
LockedRepartitionDown
( BT, B0,
/**/ /**/
B1,
BB, B2 );
//--------------------------------------------------------------------//
A1Trans_MR_STAR.TransposeFrom( A1 );
A1_STAR_VR.TransposeFrom( A1Trans_MR_STAR );
A1_STAR_MC = A1_STAR_VR;
B1Trans_MR_STAR.TransposeFrom( B1 );
B1_STAR_VR.TransposeFrom( B1Trans_MR_STAR );
B1_STAR_MC = B1_STAR_VR;
LocalTrr2k
( LOWER, TRANSPOSE, TRANSPOSE, TRANSPOSE, TRANSPOSE,
alpha, A1_STAR_MC, B1Trans_MR_STAR,
B1_STAR_MC, A1Trans_MR_STAR,
T(1), C );
//--------------------------------------------------------------------//
SlideLockedPartitionDown
( AT, A0,
A1,
/**/ /**/
AB, A2 );
SlideLockedPartitionDown
( BT, B0,
B1,
/**/ /**/
BB, B2 );
}
#ifndef RELEASE
PopCallStack();
#endif
//.........這裏部分代碼省略.........