Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
oomph::VectorMatrix< VALUE_TYPE > Class Template Reference

#include <vector_matrix.h>

Public Member Functions

 VectorMatrix ()
 Default constructor - constructs an empty matrix. More...
 
 VectorMatrix (const unsigned &n, const unsigned &m, const VALUE_TYPE &val)
 Constructor - constructs an n by m matrix with value val. More...
 
 VectorMatrix (const unsigned &n, const unsigned &m)
 Constructor - constructs an n by m matrix, the value is defined by the default initialisation of VALUE_TYPE. More...
 
virtual ~VectorMatrix ()
 Default virtual destructor. More...
 
const unsigned nrow () const
 returns the number of rows. This is the outer Vector size. More...
 
const unsigned ncol () const
 return the number of columns. This is the size of the first inner vectors, or returns 0 if the outer vector is of size 0 (this->nrow() is 0). More...
 
Vector< VALUE_TYPE > & operator[] (const size_t i)
 [] access function to the i-th inner vector. More...
 
const Vector< VALUE_TYPE > & operator[] (const size_t i) const
 [] access function to the i-th inner vector const version More...
 
void clear ()
 Clears the outer vector. Calling Vector::clear() will invoke the destructor of all the inner Vectors. More...
 
void resize (const size_t &n, const size_t &m, VALUE_TYPE val=VALUE_TYPE())
 Resize the existing VectorMatrix. WARNING: This invokes the resize function in std::vector, as such, only new values are assigned, old values as kept. e.g. if vec = [2,2,2], then vec.resize(5,3) gives vec = [2, 2, 2, 3, 3]. More...
 
void assign (const size_t &n, const size_t &m, const VALUE_TYPE &val)
 Any elements held in the container before the call are destroyed and replaced by newly constructed elements (no assignments of elements take place). This causes an automatic reallocation of the allocated storage space if -and only if- the new vector size surpasses the current vector capacity. This invokes std::assign on both the outer vector and the inner vectors. More...
 

Protected Member Functions

void build_vectors (const unsigned &n, const unsigned &m)
 Builds an n by m VectorMatrix with default VALUE_TYPE. More...
 
void build_vectors_and_value (const unsigned &n, const unsigned &m, const VALUE_TYPE &val)
 Build an m by n VectorMatrix with VALUE_TYPE val. More...
 

Protected Attributes

Vector< Vector< VALUE_TYPE > > Vector_matrix
 

Detailed Description

template<class VALUE_TYPE>
class oomph::VectorMatrix< VALUE_TYPE >

VectorMatrix is a generalised, STL-map-based, matrix based on a Vector of Vectors.

Example of usage:

// Assume we have a Vector of pointers to objects:
VectorMatrix<int> vector_matrix(4,5,-1);
// This is a 4 by 5 matrix with all entries set to -1.
std::cout << vector_matrix[3][3] << " "
// << vector_matrix.nrow() << " "
// << vector_matrix.col() << std::endl;
// Output:
// -1 4 5
vector_matrix[3][3] = 42;
std::cout << vector_matrix[3][3] << " "
<< vector_matrix.nrow() << " "
<< vector_matrix.col() << std::endl;
// Output:
// 42 4 5

Definition at line 82 of file vector_matrix.h.

Constructor & Destructor Documentation

template<class VALUE_TYPE>
oomph::VectorMatrix< VALUE_TYPE >::VectorMatrix ( )
inline

Default constructor - constructs an empty matrix.

Definition at line 88 of file vector_matrix.h.

References oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix.

template<class VALUE_TYPE>
oomph::VectorMatrix< VALUE_TYPE >::VectorMatrix ( const unsigned &  n,
const unsigned &  m,
const VALUE_TYPE &  val 
)
inline

Constructor - constructs an n by m matrix with value val.

Definition at line 94 of file vector_matrix.h.

References oomph::VectorMatrix< VALUE_TYPE >::build_vectors_and_value().

template<class VALUE_TYPE>
oomph::VectorMatrix< VALUE_TYPE >::VectorMatrix ( const unsigned &  n,
const unsigned &  m 
)
inline

Constructor - constructs an n by m matrix, the value is defined by the default initialisation of VALUE_TYPE.

Definition at line 101 of file vector_matrix.h.

References oomph::VectorMatrix< VALUE_TYPE >::build_vectors().

template<class VALUE_TYPE>
virtual oomph::VectorMatrix< VALUE_TYPE >::~VectorMatrix ( )
inlinevirtual

Default virtual destructor.

Definition at line 107 of file vector_matrix.h.

References oomph::VectorMatrix< VALUE_TYPE >::clear().

Member Function Documentation

template<class VALUE_TYPE>
void oomph::VectorMatrix< VALUE_TYPE >::assign ( const size_t &  n,
const size_t &  m,
const VALUE_TYPE &  val 
)
inline

Any elements held in the container before the call are destroyed and replaced by newly constructed elements (no assignments of elements take place). This causes an automatic reallocation of the allocated storage space if -and only if- the new vector size surpasses the current vector capacity. This invokes std::assign on both the outer vector and the inner vectors.

Definition at line 235 of file vector_matrix.h.

References oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix.

template<class VALUE_TYPE>
void oomph::VectorMatrix< VALUE_TYPE >::build_vectors ( const unsigned &  n,
const unsigned &  m 
)
inlineprotected

Builds an n by m VectorMatrix with default VALUE_TYPE.

Definition at line 245 of file vector_matrix.h.

References oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix.

Referenced by oomph::VectorMatrix< VALUE_TYPE >::VectorMatrix().

template<class VALUE_TYPE>
void oomph::VectorMatrix< VALUE_TYPE >::build_vectors_and_value ( const unsigned &  n,
const unsigned &  m,
const VALUE_TYPE &  val 
)
inlineprotected

Build an m by n VectorMatrix with VALUE_TYPE val.

Definition at line 251 of file vector_matrix.h.

References oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix.

Referenced by oomph::VectorMatrix< VALUE_TYPE >::VectorMatrix().

template<class VALUE_TYPE>
void oomph::VectorMatrix< VALUE_TYPE >::clear ( )
inline

Clears the outer vector. Calling Vector::clear() will invoke the destructor of all the inner Vectors.

Definition at line 209 of file vector_matrix.h.

References oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix.

Referenced by oomph::VectorMatrix< VALUE_TYPE >::~VectorMatrix().

template<class VALUE_TYPE>
const unsigned oomph::VectorMatrix< VALUE_TYPE >::ncol ( ) const
inline

return the number of columns. This is the size of the first inner vectors, or returns 0 if the outer vector is of size 0 (this->nrow() is 0).

Definition at line 153 of file vector_matrix.h.

References oomph::VectorMatrix< VALUE_TYPE >::nrow(), and oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix.

Referenced by oomph::BlockPreconditioner< CRDoubleMatrix >::get_concatenated_block().

template<class VALUE_TYPE>
const unsigned oomph::VectorMatrix< VALUE_TYPE >::nrow ( ) const
inline
template<class VALUE_TYPE>
Vector<VALUE_TYPE>& oomph::VectorMatrix< VALUE_TYPE >::operator[] ( const size_t  i)
inline

[] access function to the i-th inner vector.

Definition at line 195 of file vector_matrix.h.

References i, and oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix.

template<class VALUE_TYPE>
const Vector<VALUE_TYPE>& oomph::VectorMatrix< VALUE_TYPE >::operator[] ( const size_t  i) const
inline

[] access function to the i-th inner vector const version

Definition at line 201 of file vector_matrix.h.

References i, and oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix.

template<class VALUE_TYPE>
void oomph::VectorMatrix< VALUE_TYPE >::resize ( const size_t &  n,
const size_t &  m,
VALUE_TYPE  val = VALUE_TYPE() 
)
inline

Resize the existing VectorMatrix. WARNING: This invokes the resize function in std::vector, as such, only new values are assigned, old values as kept. e.g. if vec = [2,2,2], then vec.resize(5,3) gives vec = [2, 2, 2, 3, 3].

Definition at line 219 of file vector_matrix.h.

References i, and oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix.

Member Data Documentation

template<class VALUE_TYPE>
Vector<Vector<VALUE_TYPE> > oomph::VectorMatrix< VALUE_TYPE >::Vector_matrix
protected

The documentation for this class was generated from the following file: