本文整理匯總了C++中DistMatrix::Resize方法的典型用法代碼示例。如果您正苦於以下問題:C++ DistMatrix::Resize方法的具體用法?C++ DistMatrix::Resize怎麽用?C++ DistMatrix::Resize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DistMatrix
的用法示例。
在下文中一共展示了DistMatrix::Resize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: cse
inline void
Forsythe( DistMatrix<T,U,V>& J, Int n, T alpha, T lambda )
{
DEBUG_ONLY(CallStackEntry cse("Forsythe"))
J.Resize( n, n );
MakeForsythe( J, alpha, lambda );
}
示例2: cse
inline void
Identity( DistMatrix<T,U,V>& I, Int m, Int n )
{
DEBUG_ONLY(CallStackEntry cse("Identity"))
I.Resize( m, n );
MakeIdentity( I );
}
示例3: file
inline void
BinaryFlat
( DistMatrix<T,CIRC,CIRC>& A, Int height, Int width,
const std::string filename )
{
DEBUG_ONLY(CallStackEntry cse("read::Binary"))
std::ifstream file( filename.c_str(), std::ios::binary );
if( !file.is_open() )
RuntimeError("Could not open ",filename);
const Int numBytes = FileSize( file );
const Int numBytesExp = height*width*sizeof(T);
if( numBytes != numBytesExp )
RuntimeError
("Expected file to be ",numBytesExp," bytes but found ",numBytes);
A.Resize( height, width );
if( A.CrossRank() == A.Root() )
{
if( A.Height() == A.LDim() )
file.read( (char*)A.Buffer(), height*width*sizeof(T) );
else
for( Int j=0; j<width; ++j )
file.read( (char*)A.Buffer(0,j), height*sizeof(T) );
}
}
示例4: AssertSameGrids
void Scatter
( const DistMatrix<T,CIRC,CIRC>& A,
DistMatrix<T,STAR,STAR>& B )
{
DEBUG_CSE
AssertSameGrids( A, B );
const Int height = A.Height();
const Int width = A.Width();
B.Resize( height, width );
if( B.Participating() )
{
const Int pkgSize = mpi::Pad( height*width );
vector<T> buffer;
FastResize( buffer, pkgSize );
// Pack
if( A.Participating() )
util::InterleaveMatrix
( height, width,
A.LockedBuffer(), 1, A.LDim(),
buffer.data(), 1, height );
// Broadcast from the process that packed
mpi::Broadcast( buffer.data(), pkgSize, A.Root(), A.CrossComm() );
// Unpack
util::InterleaveMatrix
( height, width,
buffer.data(), 1, height,
B.Buffer(), 1, B.LDim() );
}
}
示例5: HessenbergSchur
void ConsistentlyComputeDecomposition
( DistMatrix<Field,MC,MR,BLOCK>& H,
DistMatrix<Complex<Base<Field>>,STAR,STAR>& w,
Matrix<Field>& Z,
const HessenbergSchurCtrl& ctrl=HessenbergSchurCtrl() )
{
EL_DEBUG_CSE
// Because double-precision floating-point computation is often
// non-deterministic due to extra-precision computation being frequent but
// not guaranteed, we must be careful to not allow this non-determinism to
// be amplified by the forward instability of Francis sweeps.
const Grid& grid = H.Grid();
const int owner = H.Owner(0,0);
DistMatrix<Field,CIRC,CIRC> H_CIRC_CIRC( grid, owner );
H_CIRC_CIRC = H;
w.Resize( H.Height(), 1 );
if( H_CIRC_CIRC.CrossRank() == H_CIRC_CIRC.Root() )
HessenbergSchur( H_CIRC_CIRC.Matrix(), w.Matrix(), Z, ctrl );
else
Z.Resize( H.Height(), H.Height() );
H = H_CIRC_CIRC;
El::Broadcast( w.Matrix(), H_CIRC_CIRC.CrossComm(), H_CIRC_CIRC.Root() );
El::Broadcast( Z, H_CIRC_CIRC.CrossComm(), H_CIRC_CIRC.Root() );
}
示例6: cse
inline void
Jordan( DistMatrix<T,U,V>& J, Int n, T lambda )
{
DEBUG_ONLY(CallStackEntry cse("Jordan"))
J.Resize( n, n );
MakeJordan( J, lambda );
}
示例7: 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 );
}
示例8: file
inline void
BinaryFlat
( DistMatrix<T,U,V>& A, Int height, Int width, const std::string filename )
{
DEBUG_ONLY(CallStackEntry cse("read::BinaryFlat"))
std::ifstream file( filename.c_str(), std::ios::binary );
if( !file.is_open() )
RuntimeError("Could not open ",filename);
const Int numBytes = FileSize( file );
const Int numBytesExp = height*width*sizeof(T);
if( numBytes != numBytesExp )
RuntimeError
("Expected file to be ",numBytesExp," bytes but found ",numBytes);
A.Resize( height, width );
if( U == A.UGath && V == A.VGath )
{
if( A.CrossRank() == A.Root() )
{
if( A.Height() == A.LDim() )
file.read( (char*)A.Buffer(), height*width*sizeof(T) );
else
for( Int j=0; j<width; ++j )
file.read( (char*)A.Buffer(0,j), height*sizeof(T) );
}
}
else if( U == A.UGath )
{
const Int localWidth = A.LocalWidth();
for( Int jLoc=0; jLoc<localWidth; ++jLoc )
{
const Int j = A.GlobalCol(jLoc);
const Int localIndex = j*height;
const std::streamoff pos = localIndex*sizeof(T);
file.seekg( pos );
file.read( (char*)A.Buffer(0,jLoc), height*sizeof(T) );
}
}
else
{
const Int localHeight = A.LocalHeight();
const Int localWidth = A.LocalWidth();
for( Int jLoc=0; jLoc<localWidth; ++jLoc )
{
const Int j = A.GlobalCol(jLoc);
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
const Int i = A.GlobalRow(iLoc);
const Int localIndex = i+j*height;
const std::streamoff pos = localIndex*sizeof(T);
file.seekg( pos );
file.read( (char*)A.Buffer(iLoc,jLoc), sizeof(T) );
}
}
}
}
示例9: AssertSameGrids
void AllGather
( const DistMatrix<T, U, V >& A,
DistMatrix<T,Collect<U>(),Collect<V>()>& B )
{
EL_DEBUG_CSE
AssertSameGrids( A, B );
const Int height = A.Height();
const Int width = A.Width();
B.SetGrid( A.Grid() );
B.Resize( height, width );
if( A.Participating() )
{
if( A.DistSize() == 1 )
{
Copy( A.LockedMatrix(), B.Matrix() );
}
else
{
const Int colStride = A.ColStride();
const Int rowStride = A.RowStride();
const Int distStride = colStride*rowStride;
const Int maxLocalHeight = MaxLength(height,colStride);
const Int maxLocalWidth = MaxLength(width,rowStride);
const Int portionSize = mpi::Pad( maxLocalHeight*maxLocalWidth );
vector<T> buf;
FastResize( buf, (distStride+1)*portionSize );
T* sendBuf = &buf[0];
T* recvBuf = &buf[portionSize];
// Pack
util::InterleaveMatrix
( A.LocalHeight(), A.LocalWidth(),
A.LockedBuffer(), 1, A.LDim(),
sendBuf, 1, A.LocalHeight() );
// Communicate
mpi::AllGather
( sendBuf, portionSize, recvBuf, portionSize, A.DistComm() );
// Unpack
util::StridedUnpack
( height, width,
A.ColAlign(), colStride,
A.RowAlign(), rowStride,
recvBuf, portionSize,
B.Buffer(), B.LDim() );
}
}
if( A.Grid().InGrid() && A.CrossComm() != mpi::COMM_SELF )
El::Broadcast( B, A.CrossComm(), A.Root() );
}
示例10: 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() );
}
示例11: cse
inline void
Lauchli( DistMatrix<T,U,V>& A, Int n, T mu )
{
DEBUG_ONLY(CallStackEntry cse("Lauchli"))
A.Resize( n+1, n );
auto ABlock = View( A, 0, 0, 1, n );
MakeOnes( ABlock );
std::vector<T> d(n,mu);
ABlock = View( A, 1, 0, n, n );
Diagonal( ABlock, d );
}
示例12: cse
void HermitianUniformSpectrum
( DistMatrix<F,U,V>& A, Int n, Base<F> lower, Base<F> upper )
{
DEBUG_ONLY(CallStackEntry cse("HermitianUniformSpectrum"))
A.Resize( n, n );
const Grid& grid = A.Grid();
typedef Base<F> Real;
const bool isComplex = IsComplex<F>::val;
const bool standardDist = ( U == MC && V == MR );
// Form d and D
std::vector<F> d( n );
if( grid.Rank() == 0 )
for( Int j=0; j<n; ++j )
d[j] = SampleUniform<Real>( lower, upper );
mpi::Broadcast( d.data(), n, 0, grid.Comm() );
DistMatrix<F> ABackup( grid );
ABackup.AlignWith( A );
Diagonal( ABackup, d );
// Apply a Haar matrix from both sides
DistMatrix<F> Q(grid);
DistMatrix<F,MD,STAR> t(grid);
DistMatrix<Real,MD,STAR> s(grid);
ImplicitHaar( Q, t, s, n );
// Copy the result into the correct distribution
qr::ApplyQ( LEFT, NORMAL, Q, t, s, ABackup );
qr::ApplyQ( RIGHT, ADJOINT, Q, t, s, ABackup );
A = ABackup;
// Force the diagonal to be real-valued
if( isComplex )
{
const Int localHeight = A.LocalHeight();
const Int localWidth = A.LocalWidth();
for( Int jLoc=0; jLoc<localWidth; ++jLoc )
{
const Int j = A.GlobalCol(jLoc);
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
const Int i = A.GlobalRow(iLoc);
if( i == j )
A.SetLocalImagPart( iLoc, jLoc, Real(0) );
}
}
}
}
示例13: 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
}
示例14: AssertSameGrids
void Filter
( const DistMatrix<T,Collect<U>(),Collect<V>()>& A,
DistMatrix<T, U, V >& B )
{
DEBUG_CSE
AssertSameGrids( A, B );
B.Resize( A.Height(), A.Width() );
if( !B.Participating() )
return;
const Int colShift = B.ColShift();
const Int rowShift = B.RowShift();
util::InterleaveMatrix
( B.LocalHeight(), B.LocalWidth(),
A.LockedBuffer(colShift,rowShift), B.ColStride(), B.RowStride()*A.LDim(),
B.Buffer(), 1, B.LDim() );
}
示例15: cse
inline void
Lehmer( DistMatrix<F,U,V>& L, Int n )
{
DEBUG_ONLY(CallStackEntry cse("Lehmer"))
L.Resize( n, n );
const Int localHeight = L.LocalHeight();
const Int localWidth = L.LocalWidth();
for( Int jLoc=0; jLoc<localWidth; ++jLoc )
{
const Int j = L.GlobalCol(jLoc);
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
const Int i = L.GlobalRow(iLoc);
if( i < j )
L.SetLocal( iLoc, jLoc, F(i+1)/F(j+1) );
else
L.SetLocal( iLoc, jLoc, F(j+1)/F(i+1) );
}
}
}