本文整理汇总了C++中DistMatrix::GlobalRow方法的典型用法代码示例。如果您正苦于以下问题:C++ DistMatrix::GlobalRow方法的具体用法?C++ DistMatrix::GlobalRow怎么用?C++ DistMatrix::GlobalRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistMatrix
的用法示例。
在下文中一共展示了DistMatrix::GlobalRow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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) );
}
}
}
}
示例2: 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) );
}
}
}
}
示例3: 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) );
}
}
}