29#ifndef OOMPH_VECTOR_HEADER
30#define OOMPH_VECTOR_HEADER
34#include <oomph-lib-config.h>
57 class Vector :
public std::vector<_Tp>
80 if (
__n >= this->size())
83 std::ostringstream error_message;
84 if (this->size() == 0)
87 <<
"Range Error: Vector is empty but you requested entry " <<
__n;
91 error_message <<
"Range Error: " <<
__n <<
" is not in the range (0,"
92 << this->size() - 1 <<
")";
101 return std::vector<_Tp>::operator[](
__n);
105 return std::vector<_Tp>::operator[](
__n);
114 if (
__n >= this->size())
117 std::ostringstream error_message;
118 error_message <<
"Range Error: " <<
__n <<
" is not in the range (0,"
119 << this->size() - 1 <<
")";
127 return std::vector<_Tp>::operator[](
__n);
131 return std::vector<_Tp>::operator[](
__n);
158 Vector(std::initializer_list<_Tp> init) : std::vector<
_Tp>(init) {}
169 for (
typename std::vector<_Tp>::iterator
it = std::vector<_Tp>::begin();
170 it != std::vector<_Tp>::end();
221 throw OomphLibError(
"Please use vector<bool> instead of Vector<bool>",
247 Vector(std::initializer_list<bool> init) : std::vector<
bool>(init) {}
255 for (std::vector<bool>::iterator
it = std::vector<bool>::begin();
256 it != std::vector<bool>::end();
268 namespace VectorHelpers
277 std::ostringstream
err;
278 err <<
"Vectors must be the same length."
279 <<
"len(a) = " << a.
size() <<
", "
280 <<
"len(b) = " << b.
size() <<
".";
305 return (std::sqrt(
dot(a, a)));
313 return std::acos(
dot(a, b) / std::sqrt(
dot(a, a) *
dot(b, b)));
324 if ((A.
size() != 3) || (B.size() != 3) || (C.
size() != 3))
326 std::ostringstream
err;
327 err <<
"Cross product only defined for vectors of length 3.\n"
328 <<
"len(a) = " << A.
size() <<
", "
329 <<
"len(b) = " << B.size() <<
", "
330 <<
"len(c) = " << C.
size() <<
".";
337 C[0] = A[1] * B[2] - A[2] * B[1];
338 C[1] = A[2] * B[0] - A[0] * B[2];
339 C[2] = A[0] * B[1] - A[1] * B[0];
double size() const
Calculate the size of the element (length, area, volume,...) in Eulerian computational coordinates....
An OomphLibError object which should be thrown when an run-time error is encountered....
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
size_t size_type
Typedef to make the constructors look a bit cleaner.
Vector(std::initializer_list< bool > init)
A constructor that creates a vector with entries set by the values in the input initialiser_list....
Vector(const double &dont_call_this_constructor)
Dummy constructor to avoid compiler from warning about only-private constructors.
void initialise(const bool &__value)
Iterate over all values and set to the desired value.
Vector()
Construct an empty vector.
Vector(size_type __n, const bool &__value)
A constructor that creates a vector of size __n and initialises every entry to __value.
const value_type & const_reference
Typedef to make the constructors look a bit cleaner.
Vector(size_type __n)
A constructor that creates a vector of size __n. Note the use of explicit for "strong" type checking.
Vector(const Vector< bool > &__x)
Copy constructor.
bool value_type
Typedef to make the constructors look a bit cleaner.
value_type & reference
Typedef to make the constructors look a bit cleaner.
A slight extension to the standard template vector class so that we can include "graceful" array rang...
Vector()
Construct an empty vector.
Vector(size_type __n, const _Tp &__value)
A constructor that creates a vector of size __n and initialises every entry to __value.
Vector(std::initializer_list< _Tp > init)
A constructor that creates a vector with entries set by the values in the input initialiser_list Exam...
Vector(const Vector< _Tp > &__x)
Copy constructor.
reference operator[](size_type __n)
Overload the bracket access operator to include array-range checking if the RANGE_CHECKING flag is se...
_Tp value_type
Typedef to make the constructors look a bit cleaner.
value_type & reference
Typedef to make the constructors look a bit cleaner.
size_t size_type
Typedef to make the constructors look a bit cleaner.
const_reference error_checked_access(size_type __n) const
const_reference operator[](size_type __n) const
Overloaded, range-checking, bracket access operator (const version)
Vector(size_type __n)
A constructor that creates a vector of size __n. Note the use of explicit for "strong" type checking.
reference error_checked_access(size_type __n)
const value_type & const_reference
Typedef to make the constructors look a bit cleaner.
void initialise(const _Tp &__value)
Iterate over all values and set to the desired value.
double dot(const Vector< double > &a, const Vector< double > &b)
Probably not always best/fastest because not optimised for dimension but useful...
void cross(const Vector< double > &A, const Vector< double > &B, Vector< double > &C)
Cross product using "proper" output (move semantics means this is ok nowadays).
double angle(const Vector< double > &a, const Vector< double > &b)
Get the angle between two vector.
void check_lengths_match(const Vector< double > &a, const Vector< double > &b)
Check the lengths if two Vectors are the same length.
double magnitude(const Vector< double > &a)
Get the magnitude of a vector.
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).