本文整理汇总了C++中DistMatrix::ResizeTo方法的典型用法代码示例。如果您正苦于以下问题:C++ DistMatrix::ResizeTo方法的具体用法?C++ DistMatrix::ResizeTo怎么用?C++ DistMatrix::ResizeTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistMatrix
的用法示例。
在下文中一共展示了DistMatrix::ResizeTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: entry
inline void
LU( DistMatrix<F>& A, DistMatrix<Int,VC,STAR>& p, DistMatrix<Int,VC,STAR>& q )
{
#ifndef RELEASE
CallStackEntry entry("LU");
#endif
p.ResizeTo( Min(A.Height(),A.Width()), 1 );
q.ResizeTo( Min(A.Height(),A.Width()), 1 );
lu::Full( A, p, q );
}
示例2: entry
inline void
Wilkinson( DistMatrix<T,U,V>& A, int k )
{
#ifndef RELEASE
CallStackEntry entry("Wilkinson");
#endif
const int n = 2*k+1;
A.ResizeTo( n, n );
MakeZeros( A );
const int localHeight = A.LocalHeight();
const int localWidth = A.LocalWidth();
const int colShift = A.ColShift();
const int rowShift = A.RowShift();
const int colStride = A.ColStride();
const int rowStride = A.RowStride();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const int j = rowShift + jLocal*rowStride;
for( int iLocal=0; iLocal<localHeight; ++iLocal )
{
const int i = colShift + iLocal*colStride;
if( i == j )
{
if( j <= k )
A.SetLocal( iLocal, jLocal, T(k-j) );
else
A.SetLocal( iLocal, jLocal, T(j-k) );
}
else if( i == j-1 || i == j+1 )
A.SetLocal( iLocal, jLocal, T(1) );
}
}
}
示例3: entry
inline void
Redheffer( DistMatrix<T,U,V>& R, Int n )
{
#ifndef RELEASE
CallStackEntry entry("Redheffer");
#endif
R.ResizeTo( n, n );
const Int localHeight = R.LocalHeight();
const Int localWidth = R.LocalWidth();
const Int colShift = R.ColShift();
const Int rowShift = R.RowShift();
const Int colStride = R.ColStride();
const Int rowStride = R.RowStride();
for( Int jLoc=0; jLoc<localWidth; ++jLoc )
{
const Int j = rowShift + jLoc*rowStride;
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
const Int i = colShift + iLoc*colStride;
if( j==0 || ((j+1)%(i+1))==0 )
R.SetLocal( iLoc, jLoc, T(1) );
else
R.SetLocal( iLoc, jLoc, T(0) );
}
}
}
示例4: entry
inline void
Hanowa( DistMatrix<T,U,V>& A, int n, T mu )
{
#ifndef RELEASE
CallStackEntry entry("Hanowa");
#endif
if( n % 2 != 0 )
throw std::logic_error("n must be an even integer");
A.ResizeTo( n, n );
const int m = n/2;
std::vector<T> d(m);
DistMatrix<T,U,V> ABlock( A.Grid() );
for( int j=0; j<m; ++j )
d[j] = mu;
View( ABlock, A, 0, 0, m, m );
Diagonal( ABlock, d );
View( ABlock, A, m, m, m, m );
Diagonal( ABlock, d );
for( int j=0; j<m; ++j )
d[j] = -(j+1);
View( ABlock, A, 0, m, m, m );
Diagonal( ABlock, d );
for( int j=0; j<m; ++j )
d[j] = j+1;
View( ABlock, A, m, 0, m, m );
Diagonal( ABlock, d );
}
示例5: PushCallStack
inline void
Diagonal( const std::vector<T>& d, DistMatrix<T,U,V>& D )
{
#ifndef RELEASE
PushCallStack("Diagonal");
#endif
const int n = d.size();
D.ResizeTo( n, n );
MakeZeros( D );
const int localWidth = D.LocalWidth();
const int colShift = D.ColShift();
const int rowShift = D.RowShift();
const int colStride = D.ColStride();
const int rowStride = D.RowStride();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const int j = rowShift + jLocal*rowStride;
if( (j-colShift+colStride) % colStride == 0 )
{
const int iLocal = (j-colShift) / colStride;
D.SetLocal( iLocal, jLocal, d[j] );
}
}
#ifndef RELEASE
PopCallStack();
#endif
}
示例6: entry
inline void
Riemann( DistMatrix<T,U,V>& R, int n )
{
#ifndef RELEASE
CallStackEntry entry("Riemann");
#endif
R.ResizeTo( n, n );
const int localHeight = R.LocalHeight();
const int localWidth = R.LocalWidth();
const int colShift = R.ColShift();
const int rowShift = R.RowShift();
const int colStride = R.ColStride();
const int rowStride = R.RowStride();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const int j = rowShift + jLocal*rowStride;
for( int iLocal=0; iLocal<localHeight; ++iLocal )
{
const int i = colShift + iLocal*colStride;
if( ((j+2)%(i+2))==0 )
R.SetLocal( iLocal, jLocal, T(i+1) );
else
R.SetLocal( iLocal, jLocal, T(-1) );
}
}
}
示例7: logic_error
inline void
Hankel( int m, int n, const std::vector<T>& a, DistMatrix<T,U,V>& A )
{
#ifndef RELEASE
PushCallStack("Hankel");
#endif
const int length = m+n-1;
if( a.size() != (unsigned)length )
throw std::logic_error("a was the wrong size");
A.ResizeTo( m, n );
const int localHeight = A.LocalHeight();
const int localWidth = A.LocalWidth();
const int colShift = A.ColShift();
const int rowShift = A.RowShift();
const int colStride = A.ColStride();
const int rowStride = A.RowStride();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const int j = rowShift + jLocal*rowStride;
for( int iLocal=0; iLocal<localHeight; ++iLocal )
{
const int i = colShift + iLocal*colStride;
A.SetLocal( iLocal, jLocal, a[i+j] );
}
}
#ifndef RELEASE
PopCallStack();
#endif
}
示例8: entry
inline void
Pei( DistMatrix<T,U,V>& P, Int n, T alpha )
{
#ifndef RELEASE
CallStackEntry entry("MakeIdentity");
#endif
P.ResizeTo( n, n );
const Int localHeight = P.LocalHeight();
const Int localWidth = P.LocalWidth();
const Int colShift = P.ColShift();
const Int rowShift = P.RowShift();
const Int colStride = P.ColStride();
const Int rowStride = P.RowStride();
for( Int jLoc=0; jLoc<localWidth; ++jLoc )
{
const Int j = rowShift + jLoc*rowStride;
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
const Int i = colShift + iLoc*colStride;
P.SetLocal( iLoc, jLoc, T(1) );
if( i == j )
P.UpdateLocal( iLoc, jLoc, alpha );
}
}
}
示例9: entry
inline void
Hankel( DistMatrix<T,U,V>& A, Int m, Int n, const std::vector<T>& a )
{
#ifndef RELEASE
CallStackEntry entry("Hankel");
#endif
const Int length = m+n-1;
if( a.size() != (Unsigned)length )
LogicError("a was the wrong size");
A.ResizeTo( m, n );
const Int localHeight = A.LocalHeight();
const Int localWidth = A.LocalWidth();
const Int colShift = A.ColShift();
const Int rowShift = A.RowShift();
const Int colStride = A.ColStride();
const Int rowStride = A.RowStride();
for( Int jLoc=0; jLoc<localWidth; ++jLoc )
{
const Int j = rowShift + jLoc*rowStride;
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
const Int i = colShift + iLoc*colStride;
A.SetLocal( iLoc, jLoc, a[i+j] );
}
}
}
示例10: logic_error
// Broadcast a matrix from the root grid to the others
void DepthBroadcast
( const mpi::Comm& depthComm,
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;
const int localSize = A.LocalHeight()*A.LocalWidth();
if( A.LocalHeight() != A.LocalLDim() )
throw std::logic_error("Leading dimension did not match local height");
B.Empty();
B.AlignWith( A );
B.ResizeTo( A.Height(), A.Width() );
// Have the root pack the broadcast data
if( depthRank == 0 )
MemCopy( B.LocalBuffer(), A.LockedLocalBuffer(), localSize );
// Broadcast from the root
mpi::Broadcast( B.LocalBuffer(), localSize, 0, depthComm );
}
示例11: entry
inline void
Ones( DistMatrix<T,U,V>& A, int m, int n )
{
#ifndef RELEASE
CallStackEntry entry("Ones");
#endif
A.ResizeTo( m, n );
MakeOnes( A );
}
示例12: entry
inline void
Hilbert( DistMatrix<F,U,V>& A, Int n )
{
#ifndef RELEASE
CallStackEntry entry("Hilbert");
#endif
A.ResizeTo( n, n );
MakeHilbert( A );
}
示例13: entry
inline void
GKS( DistMatrix<F,U,V>& A, Int n )
{
#ifndef RELEASE
CallStackEntry entry("GKS");
#endif
A.ResizeTo( n, n );
MakeGKS( A );
}
示例14: entry
inline void
Legendre( DistMatrix<F,U,V>& A, Int n )
{
#ifndef RELEASE
CallStackEntry entry("Legendre");
#endif
A.ResizeTo( n, n );
MakeLegendre( A );
}
示例15: entry
inline void
DiscreteFourier( DistMatrix<Complex<R>,U,V>& A, int n )
{
#ifndef RELEASE
CallStackEntry entry("DiscreteFourier");
#endif
A.ResizeTo( n, n );
MakeDiscreteFourier( A );
}