20 #ifndef GEOS_LINEARALGEBRA_UTILITIES_BLOCKVECTORVIEW_HPP_ 
   21 #define GEOS_LINEARALGEBRA_UTILITIES_BLOCKVECTORVIEW_HPP_ 
   36 template< 
typename VECTOR >
 
   97   void rand( 
unsigned const seed );
 
  166   void print( std::ostream & os = std::cout ) 
const;
 
  176     return *m_vectors[blockIndex];
 
  185     return *m_vectors[blockIndex];
 
  193     return block( blockIndex );
 
  201     return block( blockIndex );
 
  221     : m_vectors( nBlocks )
 
  242     m_vectors.resize( size );
 
  252     m_vectors( i ) = vec;
 
  261 template< 
typename VECTOR >
 
  267     block( i ).copy( src.
block( i ) );
 
  271 template< 
typename VECTOR >
 
  276     block( i ).scale( factor );
 
  280 template< 
typename VECTOR >
 
  289 template< 
typename VECTOR >
 
  294     block( i ).rand( seed );
 
  298 template< 
typename VECTOR >
 
  305     accum += block( i ).dot( src.
block( i ) );
 
  310 template< 
typename VECTOR >
 
  316     real64 const temp = block( i ).norm2();
 
  317     accum = accum + temp * temp;
 
  319   return std::sqrt( accum );
 
  322 template< 
typename VECTOR >
 
  328     result = std::fmax( result, block( i ).normInf() );
 
  333 template< 
typename VECTOR >
 
  340     block( i ).axpy( alpha, x.
block( i ) );
 
  344 template< 
typename VECTOR >
 
  352     block( i ).axpby( alpha, x.
block( i ), beta );
 
  356 template< 
typename VECTOR >
 
  359   return m_vectors.size();
 
  362 template< 
typename VECTOR >
 
  368     size += block( i ).globalSize();
 
  373 template< 
typename VECTOR >
 
  379     size += block( i ).localSize();
 
  384 template< 
typename VECTOR >
 
  387   for( 
localIndex i = 0; i < m_vectors.size(); i++ )
 
  389     os << 
"Block " << i << 
" of " << blockSize() << 
":" << std::endl;
 
  390     os << 
"=============" << std::endl;
 
  391     block( i ).print( os );
 
  401 template< 
typename VECTOR >
 
Abstract view of a block vector.
 
void rand(unsigned const seed)
Set vector elements to random entries.
 
VECTOR const  & block(localIndex const blockIndex) const
Get a reference to the vector corresponding to block blockRowIndex.
 
BlockVectorView & operator=(BlockVectorView &&rhs) noexcept=delete
Deleted move assignment.
 
BlockVectorView & operator=(BlockVectorView const &rhs)=delete
Deleted copy assignment.
 
VECTOR & operator()(localIndex const blockIndex)
Get a reference to the vector corresponding to block blockRowIndex.
 
void setPointer(localIndex i, VECTOR *vec)
Set pointer to a vector.
 
VECTOR Vector
Alias for sub-vector type.
 
VECTOR & block(localIndex const blockIndex)
Get a reference to the vector corresponding to block blockRowIndex.
 
localIndex localSize() const
Get local size.
 
void print(std::ostream &os=std::cout) const
Print the block vector.
 
void scale(real64 const factor)
Scale the block vector with factor.
 
globalIndex globalSize() const
Get global size.
 
real64 norm2() const
2-norm of the block vector.
 
void axpy(real64 const alpha, BlockVectorView const &x)
Update vector y as y = alpha*x + y.
 
virtual ~BlockVectorView()=default
Destructor.
 
void zero()
Set the vector to zero.
 
void copy(BlockVectorView const &src)
Update vector y as y = x.
 
real64 normInf() const
Inf-norm of the block vector.
 
void resize(localIndex const size)
Resize to a new number of blocks.
 
VECTOR const  & operator()(localIndex const blockIndex) const
Get a reference to the vector corresponding to block blockRowIndex.
 
BlockVectorView(localIndex const nBlocks)
Create a vector of nBlocks blocks.
 
BlockVectorView(BlockVectorView const &)=default
Copy constructor.
 
real64 dot(BlockVectorView const &x) const
Dot product.
 
BlockVectorView(BlockVectorView &&)=default
Move constructor.
 
void axpby(real64 const alpha, BlockVectorView const &x, real64 const beta)
Update vector y as y = alpha*x + beta*y.
 
localIndex blockSize() const
Get block size.
 
#define GEOS_LAI_ASSERT_EQ(lhs, rhs)
 
#define GEOS_LAI_ASSERT(expr)
 
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
 
double real64
64-bit floating point type.
 
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
 
std::ostream & operator<<(std::ostream &stream, mapType< K, V, SORTED > const &map)
Stream output operator for map types.
 
Array< T, 1 > array1d
Alias for 1D array.