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; } }
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); } }