25 template <
typename _Type>
33 template <
typename _Type>
37 typedef typename std::vector<_Type>::iterator
elt_iter;
38 typedef typename std::vector<_Type>::const_iterator
elt_citer;
39 typedef typename std::vector<_Type>::reverse_iterator
elt_riter;
40 typedef typename std::vector<_Type>::const_reverse_iterator
elt_criter;
61 template <
typename _sourceType>
64 m_vec.resize(source.size());
67 p_from = source.begin();
68 p_from != source.end();
69 ++p_from, ++p_local) {
88 return m_vec.rbegin();
98 return m_vec.rbegin();
190 void assign(
const std::size_t n,
const _Type elem) {
191 m_vec.assign(n, elem);
241 void swap(
const std::size_t& i,
const std::size_t& j);
249 void dump_file(std::string filename,
int precision = 10)
const;
257 std::vector<_Type> m_vec;
267 template <
typename _Type>
275 m_vec = source.m_vec;
281 m_vec = source.m_vec;
284 template <
typename _Type>
287 if((i < 0) || (i >= size())) {
289 problem =
" The DenseVector.operator[] method has a range error. \n";
296 template <
typename _Type>
299 if((i < 0) || (i >= size())) {
301 problem =
" The DenseVector.operator[] method has a range error. \n";
309 template <
typename _Type>
311 m_vec.push_back(fill);
314 template <
typename _Type>
316 m_vec.resize(length);
319 template <
typename _Type>
324 template <
typename _Type>
329 template <
typename _Type>
334 template <
typename _Type>
339 template <
typename _Type>
344 template <
typename _Type>
351 template <
typename _Type>
359 template <
typename _Type>
366 template <
typename _Type>
374 template <
typename _Type>
377 if(x.
size() != size()) {
379 problem =
" The DenseVector.operator-= method is trying to use \n";
380 problem +=
" two vectors of unequal length \n";
384 std::transform(m_vec.begin(), m_vec.end(), x.
begin(), m_vec.begin(), std::minus<_Type>());
388 template <
typename _Type>
391 if(x.
size() != size()) {
393 problem =
" The DenseVector.operator+= method is trying to use \n";
394 problem +=
" two vectors of unequal length \n";
398 std::transform(m_vec.begin(), m_vec.end(), x.
begin(), m_vec.begin(), std::plus<_Type>());
402 template <
typename _Type>
405 if(x.
size() != size()) {
407 problem =
" The DenseVector.operator- method is trying to use \n";
408 problem +=
" two vectors of unequal length \n";
417 template <
typename _Type>
424 template <
typename _Type>
427 if(x.
size() != size()) {
429 problem =
" The DenseVector.operator+ method is trying to use \n";
430 problem +=
" two vectors of unequal length \n";
439 template <
typename _Type>
443 m_vec = source.m_vec;
The collection of CppNoddy exceptions.
Some Function Objects that CppNoddy makes use of in algorithms applied to STL containers.
A matrix class that constructs a BANDED matrix.
An DenseVector class – a dense vector object.
elt_citer begin() const
Pass through to the storage container.
double one_norm() const
l1-norm.
std::vector< _Type >::const_reverse_iterator elt_criter
void dump_file(std::string filename, int precision=10) const
Dump the contents to a file, each element on a separate line.
void push_back(const _Type &fill)
A pass-thru definition of push_back.
std::size_t nelts() const
Get the number of elements in the vector Since the vector is dense, the number of elements is the siz...
double inf_norm() const
Infinity norm.
elt_criter rend() const
Pass through to the storage container.
void resize(const std::size_t &length)
A pass-thru definition of resize.
void sub(const DenseVector< _Type > &x)
Subtract a vector, element wise, equivalent to -=.
elt_citer end() const
Pass through to the storage container.
void dump() const
Dump to std::cout.
elt_riter rend()
Pass through to the storage container.
DenseVector< _Type > & operator*=(const _Type &m)
Overloading *= for scalar multiplication.
void add(const DenseVector< _Type > &x)
Add a vector, element wise, equivalent to +=.
std::vector< _Type >::reverse_iterator elt_riter
DenseVector< _Type > & operator/=(const _Type &m)
Overloading /= for scalar multiplication.
DenseVector< _Type > operator+() const
Overloading for +.
void reserve(const std::size_t &n)
Reserve space for the vector.
std::vector< _Type >::const_iterator elt_citer
void swap(const std::size_t &i, const std::size_t &j)
Swap elements i and j.
void clear()
A pass-thru definition of clear.
std::size_t size() const
A pass-thru definition to get the size of the vector.
_Type & operator[](const std::size_t &i)
Overloading of the [] operator.
DenseVector< _Type > operator*(const _Type &m) const
Operator overloading for scalar multiplication.
DenseVector< _Type > operator+(const DenseVector< _Type > &x) const
Operator overloading for addition.
DenseVector< _Type > & operator-=(const DenseVector< _Type > &x)
Overloading the -= operator.
elt_riter rbegin()
Pass through to the storage container.
DenseVector(const DenseVector< _sourceType > &source)
A templated implicitly converting copy constructor.
const _Type & operator[](const std::size_t &i) const
Overloading of the [] operator.
DenseVector & operator=(const DenseVector &source)
Copy assignment.
void scale(const _Type &scale)
Scale each element of the vector, equivalent to *=.
elt_iter begin()
Pass through to the storage container.
DenseVector()
Constructor for a non-filled vector, to be filled by the user.
DenseVector< _Type > operator/(const _Type &m) const
Operaotr overloading for scalar division.
DenseVector< _Type > operator-(const DenseVector< _Type > &x) const
Operator overloading for subtraction.
void assign(const std::size_t n, const _Type elem)
A pass-thru definition of assign.
double two_norm() const
l2-norm.
elt_iter end()
Pass through to the storage container.
elt_criter rbegin() const
Pass through to the storage container.
std::vector< _Type >::iterator elt_iter
DenseVector< _Type > operator-() const
Overloading for -.
DenseVector< _Type > & operator+=(const DenseVector< _Type > &x)
Overloading the += operator.
An exception class to be thrown when a container of incorrect geometry used in any class/method.
An exception to indicate that a CppNoddy container has been accessed with index/indices outside the m...
A unary pure function object that scales through multiplication.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...