30 #ifndef OOMPH_VECTOR_MATRIX_HEADER 31 #define OOMPH_VECTOR_MATRIX_HEADER 36 #include <oomph-lib-config.h> 81 template<
class VALUE_TYPE>
94 VectorMatrix(
const unsigned& n,
const unsigned& m,
const VALUE_TYPE& val)
128 for (
unsigned row_i = 0; row_i < para_nrow; row_i++)
130 unsigned current_inner_vector_size =
Vector_matrix[row_i].size();
131 if(current_inner_vector_size != inner_vector0_size)
133 std::ostringstream err_msg;
134 err_msg <<
"The size of the inner vectors are not consistent.\n" 135 <<
"Vector_matrix[0].size() is " << inner_vector0_size <<
"\n" 136 <<
"Vector_matrix[" <<row_i <<
"] is " 137 << current_inner_vector_size <<
"\n";
140 OOMPH_CURRENT_FUNCTION,
141 OOMPH_EXCEPTION_LOCATION);
159 const unsigned para_nrow = this->
nrow();
165 for (
unsigned row_i = 0; row_i < para_nrow; row_i++)
167 unsigned current_inner_vector_size =
Vector_matrix[row_i].size();
168 if(current_inner_vector_size != inner_vector0_size)
170 std::ostringstream err_msg;
171 err_msg <<
"The size of the inner vectors are not consistent.\n" 172 <<
"Vector_matrix[0].size() is " << inner_vector0_size <<
"\n" 173 <<
"Vector_matrix[" <<row_i <<
"] is " 174 << current_inner_vector_size <<
"\n";
177 OOMPH_CURRENT_FUNCTION,
178 OOMPH_EXCEPTION_LOCATION);
184 if(this->
nrow() == 0)
219 void resize(
const size_t& n,
const size_t& m,
220 VALUE_TYPE val = VALUE_TYPE())
223 for (
unsigned i = 0;
i < n ;
i++)
235 void assign(
const size_t & n,
const size_t& m,
236 const VALUE_TYPE& val)
253 const VALUE_TYPE& val)
void clear()
Clears the outer vector. Calling Vector::clear() will invoke the destructor of all the inner Vectors...
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.
VectorMatrix(const unsigned &n, const unsigned &m, const VALUE_TYPE &val)
Constructor - constructs an n by m matrix with value val.
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...
Vector< VALUE_TYPE > & operator[](const size_t i)
[] access function to the i-th inner vector.
Vector< Vector< VALUE_TYPE > > Vector_matrix
const unsigned nrow() const
returns the number of rows. This is the outer Vector size.
VectorMatrix()
Default constructor - constructs an empty matrix.
void build_vectors(const unsigned &n, const unsigned &m)
Builds an n by m VectorMatrix with default VALUE_TYPE.
const unsigned ncol() const
return the number of columns. This is the size of the first inner vectors, or returns 0 if the outer ...
VectorMatrix(const unsigned &n, const unsigned &m)
Constructor - constructs an n by m matrix, the value is defined by the default initialisation of VALU...
virtual ~VectorMatrix()
Default virtual destructor.
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].