19 #ifndef GEOSX_LINEARALGEBRA_UTILITIES_BLOCKVECTORVIEW_HPP_ 20 #define GEOSX_LINEARALGEBRA_UTILITIES_BLOCKVECTORVIEW_HPP_ 34 template<
typename VECTOR >
95 void rand(
unsigned const seed = 1984 );
164 void print( std::ostream & os = std::cout )
const;
174 return *m_vectors[blockIndex];
183 return *m_vectors[blockIndex];
191 return block( blockIndex );
199 return block( blockIndex );
219 : m_vectors( nBlocks )
240 m_vectors.resize( size );
250 m_vectors( i ) = vec;
259 template<
typename VECTOR >
265 block( i ).copy( src.block( i ) );
269 template<
typename VECTOR >
274 block( i ).scale( factor );
278 template<
typename VECTOR >
287 template<
typename VECTOR >
292 block( i ).rand( seed );
296 template<
typename VECTOR >
303 accum +=
block( i ).dot( src.block( i ) );
308 template<
typename VECTOR >
315 accum = accum + temp * temp;
320 template<
typename VECTOR >
331 template<
typename VECTOR >
338 block( i ).axpy( alpha, x.block( i ) );
342 template<
typename VECTOR >
350 block( i ).axpby( alpha, x.block( i ), beta );
354 template<
typename VECTOR >
357 return m_vectors.size();
360 template<
typename VECTOR >
366 size +=
block( i ).globalSize();
371 template<
typename VECTOR >
377 size +=
block( i ).localSize();
382 template<
typename VECTOR >
385 for(
localIndex i = 0; i < m_vectors.size(); i++ )
387 os <<
"Block " << i <<
" of " <<
blockSize() <<
":" << std::endl;
388 os <<
"=============" << std::endl;
389 block( i ).print( os );
399 template<
typename VECTOR >
localIndex localSize() const
Get local size.
globalIndex globalSize() const
Get global size.
void zero()
Set the vector to zero.
void print(std::ostream &os=std::cout) const
Print the block vector.
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
BlockVectorView & operator=(BlockVectorView const &rhs)=delete
Deleted copy assignment.
void setPointer(localIndex i, VECTOR *vec)
Set pointer to a vector.
void resize(localIndex const size)
Resize to a new number of blocks.
void copy(BlockVectorView const &src)
Update vector y as y = x.
std::ostream & operator<<(std::ostream &stream, mapBase< K, V, SORTED > const &map)
Stream output operator for map types.
float sqrt(float const x)
real64 dot(BlockVectorView const &x) const
Dot product.
double real64
64-bit floating point type.
localIndex blockSize() const
Get block size.
real64 norm2() const
2-norm of the block vector.
void rand(unsigned const seed=1984)
Set vector elements to random entries.
virtual ~BlockVectorView()=default
Destructor.
void scale(real64 const factor)
Scale the block vector with factor.
VECTOR const & operator()(localIndex const blockIndex) const
Get a reference to the vector corresponding to block blockRowIndex.
void axpy(real64 const alpha, BlockVectorView const &x)
Update vector y as y = alpha*x + y.
#define GEOSX_LAI_ASSERT_EQ(lhs, rhs)
VECTOR & block(localIndex const blockIndex)
Get a reference to the vector corresponding to block blockRowIndex.
void axpby(real64 const alpha, BlockVectorView const &x, real64 const beta)
Update vector y as y = alpha*x + beta*y.
Vector Vector
Alias for sub-vector type.
real64 normInf() const
Inf-norm of the block vector.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
VECTOR const & block(localIndex const blockIndex) const
Get a reference to the vector corresponding to block blockRowIndex.
VECTOR & operator()(localIndex const blockIndex)
Get a reference to the vector corresponding to block blockRowIndex.
#define GEOSX_LAI_ASSERT(expr)
Abstract view of a block vector.
BlockVectorView(localIndex const nBlocks)
Create a vector of nBlocks blocks.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...