26 #ifndef OOMPH_VECTOR_MATRIX_HEADER
27 #define OOMPH_VECTOR_MATRIX_HEADER
32 #include <oomph-lib-config.h>
77 template<
class VALUE_TYPE>
88 VectorMatrix(
const unsigned& n,
const unsigned& m,
const VALUE_TYPE& val)
122 for (
unsigned row_i = 0; row_i < para_nrow; row_i++)
124 unsigned current_inner_vector_size =
Vector_matrix[row_i].size();
125 if (current_inner_vector_size != inner_vector0_size)
127 std::ostringstream err_msg;
128 err_msg <<
"The size of the inner vectors are not consistent.\n"
129 <<
"Vector_matrix[0].size() is " << inner_vector0_size
131 <<
"Vector_matrix[" << row_i <<
"] is "
132 << current_inner_vector_size <<
"\n";
134 err_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
152 const unsigned para_nrow = this->
nrow();
158 for (
unsigned row_i = 0; row_i < para_nrow; row_i++)
160 unsigned current_inner_vector_size =
Vector_matrix[row_i].size();
161 if (current_inner_vector_size != inner_vector0_size)
163 std::ostringstream err_msg;
164 err_msg <<
"The size of the inner vectors are not consistent.\n"
165 <<
"Vector_matrix[0].size() is " << inner_vector0_size
167 <<
"Vector_matrix[" << row_i <<
"] is "
168 << current_inner_vector_size <<
"\n";
170 err_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
176 if (this->
nrow() == 0)
211 void resize(
const size_t& n,
const size_t& m, VALUE_TYPE val = VALUE_TYPE())
214 for (
unsigned i = 0;
i < n;
i++)
226 void assign(
const size_t& n,
const size_t& m,
const VALUE_TYPE& val)
242 const VALUE_TYPE& val)
An OomphLibError object which should be thrown when an run-time error is encountered....
VectorMatrix is a generalised, STL-map-based, matrix based on a Vector of Vectors.
void build_vectors(const unsigned &n, const unsigned &m)
Builds an n by m VectorMatrix with default VALUE_TYPE.
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.
Vector< Vector< VALUE_TYPE > > Vector_matrix
Here's the generalised matrix structure: A Vector of Vector to templated by VALUE_TYPE.
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 el...
virtual ~VectorMatrix()
Default virtual destructor.
const unsigned ncol() const
return the number of columns. This is the size of the first inner vectors, or returns 0 if the outer ...
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,...
const Vector< VALUE_TYPE > & operator[](const size_t i) const
[] access function to the i-th inner vector const version
const unsigned nrow() const
returns the number of rows. This is the outer Vector size.
VectorMatrix(const unsigned &n, const unsigned &m, const VALUE_TYPE &val)
Constructor - constructs an n by m matrix with value val.
void clear()
Clears the outer vector. Calling Vector::clear() will invoke the destructor of all the inner Vectors.
VectorMatrix()
Default constructor - constructs an empty matrix.
Vector< VALUE_TYPE > & operator[](const size_t i)
[] access function to the i-th inner vector.
VectorMatrix(const unsigned &n, const unsigned &m)
Constructor - constructs an n by m matrix, the value is defined by the default initialisation of VALU...
A slight extension to the standard template vector class so that we can include "graceful" array rang...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...