本文整理汇总了C++中SparseMatrix::LockedValueBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseMatrix::LockedValueBuffer方法的具体用法?C++ SparseMatrix::LockedValueBuffer怎么用?C++ SparseMatrix::LockedValueBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix::LockedValueBuffer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FrobeniusNorm
Base<Field> FrobeniusNorm( const SparseMatrix<Field>& A )
{
EL_DEBUG_CSE
typedef Base<Field> Real;
Real scale = 0;
Real scaledSquare = 1;
const Int numEntries = A.NumEntries();
const Field* valBuf = A.LockedValueBuffer();
for( Int k=0; k<numEntries; ++k )
UpdateScaledSquare( valBuf[k], scale, scaledSquare );
return scale*Sqrt(scaledSquare);
}
示例2: NumOutside
Int NumOutside( const SparseMatrix<Real>& A )
{
EL_DEBUG_CSE
const Int numEntries = A.NumEntries();
const Real* valBuf = A.LockedValueBuffer();
Int numNonPos = 0;
for( Int k=0; k<numEntries; ++k )
if( valBuf[k] <= Real(0) )
++numNonPos;
return numNonPos;
}
示例3: RowMaxNorms
void RowMaxNorms( const SparseMatrix<F>& A, Matrix<Base<F>>& norms )
{
DEBUG_CSE
typedef Base<F> Real;
const Int m = A.Height();
const F* valBuf = A.LockedValueBuffer();
const Int* offsetBuf = A.LockedOffsetBuffer();
norms.Resize( m, 1 );
for( Int i=0; i<m; ++i )
{
Real rowMax = 0;
const Int offset = offsetBuf[i];
const Int numConn = offsetBuf[i+1] - offset;
for( Int e=offset; e<offset+numConn; ++e )
rowMax = Max(rowMax,Abs(valBuf[e]));
norms(i) = rowMax;
}
}
示例4: RowTwoNorms
void RowTwoNorms( const SparseMatrix<F>& A, Matrix<Base<F>>& norms )
{
DEBUG_CSE
typedef Base<F> Real;
const Int m = A.Height();
const F* valBuf = A.LockedValueBuffer();
const Int* offsetBuf = A.LockedOffsetBuffer();
norms.Resize( m, 1 );
for( Int i=0; i<m; ++i )
{
Real scale = 0;
Real scaledSquare = 1;
const Int offset = offsetBuf[i];
const Int numConn = offsetBuf[i+1] - offset;
for( Int e=offset; e<offset+numConn; ++e )
UpdateScaledSquare( valBuf[e], scale, scaledSquare );
norms(i) = scale*Sqrt(scaledSquare);
}
}
示例5: Max
void GetMappedDiagonal
( const SparseMatrix<T>& A,
Matrix<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();
const Int iStart = Max(-offset,0);
const Int jStart = Max( offset,0);
const Int diagLength = El::DiagonalLength(m,n,offset);
d.Resize( diagLength, 1 );
Zero( d );
S* dBuf = d.Buffer();
for( Int k=0; k<diagLength; ++k )
{
const Int i = iStart + k;
const Int j = jStart + k;
const Int thisOff = A.RowOffset(i);
const Int nextOff = A.RowOffset(i+1);
auto it = std::lower_bound( colBuf+thisOff, colBuf+nextOff, j );
if( *it == j )
{
const Int e = it-colBuf;
dBuf[Min(i,j)] = func(valBuf[e]);
}
else
dBuf[Min(i,j)] = func(0);
}
}