本文整理汇总了C++中DistMultiVec::Resize方法的典型用法代码示例。如果您正苦于以下问题:C++ DistMultiVec::Resize方法的具体用法?C++ DistMultiVec::Resize怎么用?C++ DistMultiVec::Resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistMultiVec
的用法示例。
在下文中一共展示了DistMultiVec::Resize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RowMaxNorms
void RowMaxNorms( const DistMultiVec<F>& A, DistMultiVec<Base<F>>& norms )
{
DEBUG_CSE
norms.SetComm( A.Comm() );
norms.Resize( A.Height(), 1 );
RowMaxNorms( A.LockedMatrix(), norms.Matrix() );
}
示例2: EntrywiseMap
void EntrywiseMap
( const DistMultiVec<S>& A,
DistMultiVec<T>& B,
function<T(S)> func )
{
DEBUG_CSE
B.SetComm( A.Comm() );
B.Resize( A.Height(), A.Width() );
EntrywiseMap( A.LockedMatrix(), B.Matrix(), func );
}
示例3: Sqrt
void NesterovTodd
( const DistMultiVec<Real>& s,
const DistMultiVec<Real>& z,
DistMultiVec<Real>& w )
{
DEBUG_CSE
w.SetComm( s.Comm() );
w.Resize( s.Height(), 1 );
const Real* sBuf = s.LockedMatrix().LockedBuffer();
const Real* zBuf = z.LockedMatrix().LockedBuffer();
Real* wBuf = w.Matrix().Buffer();
const Int localHeight = w.LocalHeight();
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
wBuf[iLoc] = Sqrt(sBuf[iLoc]/zBuf[iLoc]);
}
示例4: RowTwoNorms
void RowTwoNorms( const DistSparseMatrix<F>& A, DistMultiVec<Base<F>>& norms )
{
DEBUG_CSE
typedef Base<F> Real;
const Int localHeight = A.LocalHeight();
const F* valBuf = A.LockedValueBuffer();
const Int* offsetBuf = A.LockedOffsetBuffer();
norms.SetComm( A.Comm() );
norms.Resize( A.Height(), 1 );
auto& normLoc = norms.Matrix();
for( Int iLoc=0; iLoc<localHeight; ++iLoc )
{
Real scale = 0;
Real scaledSquare = 1;
const Int offset = offsetBuf[iLoc];
const Int numConn = offsetBuf[iLoc+1] - offset;
for( Int e=offset; e<offset+numConn; ++e )
UpdateScaledSquare( valBuf[e], scale, scaledSquare );
normLoc(iLoc) = scale*Sqrt(scaledSquare);
}
}
示例5: LogicError
void GetMappedDiagonal
( const DistSparseMatrix<T>& A,
DistMultiVec<S>& d,
function<S(const T&)> func,
Int offset )
{
EL_DEBUG_CSE
const Int m = A.Height();
const Int n = A.Width();
const T* valBuf = A.LockedValueBuffer();
const Int* colBuf = A.LockedTargetBuffer();
if( m != n )
LogicError("DistSparseMatrix GetMappedDiagonal assumes square matrix");
if( offset != 0 )
LogicError("DistSparseMatrix GetMappedDiagonal assumes offset=0");
d.SetGrid( A.Grid() );
d.Resize( El::DiagonalLength(m,n,offset), 1 );
Fill( d, S(1) );
S* dBuf = d.Matrix().Buffer();
const Int dLocalHeight = d.LocalHeight();
for( Int iLoc=0; iLoc<dLocalHeight; ++iLoc )
{
const Int i = d.GlobalRow(iLoc);
const Int thisOff = A.RowOffset(iLoc);
const Int nextOff = A.RowOffset(iLoc+1);
auto it = std::lower_bound( colBuf+thisOff, colBuf+nextOff, i );
if( *it == i )
{
const Int e = it-colBuf;
dBuf[iLoc] = func(valBuf[e]);
}
else
dBuf[iLoc] = func(0);
}
}
示例6: Ones
void Ones( DistMultiVec<T>& A, Int m, Int n )
{
EL_DEBUG_CSE
A.Resize( m, n );
Fill( A, T(1) );
}
示例7: Zeros
void Zeros( DistMultiVec<T>& A, Int m, Int n )
{
DEBUG_ONLY(CSE cse("Zeros"))
A.Resize( m, n );
Zero( A );
}
示例8: Ones
void Ones( DistMultiVec<T>& A, Int m, Int n )
{
DEBUG_ONLY(CSE cse("Ones"))
A.Resize( m, n );
Fill( A, T(1) );
}