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);
169 for (
typename std::vector<_Tp>::iterator it = std::vector<_Tp>::begin();
177 #ifdef RANGE_CHECKING
182 return error_checked_access(__n);
188 return error_checked_access(__n);
218 Vector(
const double& dont_call_this_constructor)
221 throw OomphLibError(
"Please use vector<bool> instead of Vector<bool>",
255 for (std::vector<bool>::iterator it = std::vector<bool>::begin();
268 namespace VectorHelpers
275 if (
a.size() !=
b.size())
277 std::ostringstream err;
278 err <<
"Vectors must be the same length."
279 <<
"len(a) = " <<
a.size() <<
", "
280 <<
"len(b) = " <<
b.size() <<
".";
295 for (
unsigned i = 0, ni =
a.size();
i < ni;
i++)
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];
AnnoyingScalar acos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:138
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Scalar * b
Definition: benchVecAdd.cpp:17
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Definition: matrices.h:74
Definition: oomph_definitions.h:222
Definition: oomph-lib/src/generic/Vector.h:201
size_t size_type
Typedef to make the constructors look a bit cleaner.
Definition: oomph-lib/src/generic/Vector.h:213
Vector(std::initializer_list< bool > init)
Definition: oomph-lib/src/generic/Vector.h:247
Vector(const double &dont_call_this_constructor)
Definition: oomph-lib/src/generic/Vector.h:218
void initialise(const bool &__value)
Iterate over all values and set to the desired value.
Definition: oomph-lib/src/generic/Vector.h:253
Vector()
Construct an empty vector.
Definition: oomph-lib/src/generic/Vector.h:230
Vector(size_type __n, const bool &__value)
Definition: oomph-lib/src/generic/Vector.h:238
const value_type & const_reference
Typedef to make the constructors look a bit cleaner.
Definition: oomph-lib/src/generic/Vector.h:210
Vector(size_type __n)
Definition: oomph-lib/src/generic/Vector.h:234
Vector(const Vector< bool > &__x)
Copy constructor.
Definition: oomph-lib/src/generic/Vector.h:250
bool value_type
Typedef to make the constructors look a bit cleaner.
Definition: oomph-lib/src/generic/Vector.h:204
value_type & reference
Typedef to make the constructors look a bit cleaner.
Definition: oomph-lib/src/generic/Vector.h:207
Definition: oomph-lib/src/generic/Vector.h:58
Vector()
Construct an empty vector.
Definition: oomph-lib/src/generic/Vector.h:141
Vector(size_type __n, const _Tp &__value)
Definition: oomph-lib/src/generic/Vector.h:149
Vector(std::initializer_list< _Tp > init)
Definition: oomph-lib/src/generic/Vector.h:158
Vector(const Vector< _Tp > &__x)
Copy constructor.
Definition: oomph-lib/src/generic/Vector.h:161
_Tp value_type
Typedef to make the constructors look a bit cleaner.
Definition: oomph-lib/src/generic/Vector.h:61
value_type & reference
Typedef to make the constructors look a bit cleaner.
Definition: oomph-lib/src/generic/Vector.h:64
size_t size_type
Typedef to make the constructors look a bit cleaner.
Definition: oomph-lib/src/generic/Vector.h:70
Vector(size_type __n)
Definition: oomph-lib/src/generic/Vector.h:145
const value_type & const_reference
Typedef to make the constructors look a bit cleaner.
Definition: oomph-lib/src/generic/Vector.h:67
void initialise(const _Tp &__value)
Iterate over all values and set to the desired value.
Definition: oomph-lib/src/generic/Vector.h:167
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
const Scalar * a
Definition: level2_cplx_impl.h:32
double dot(const Vector< double > &a, const Vector< double > &b)
Definition: oomph-lib/src/generic/Vector.h:291
void cross(const Vector< double > &A, const Vector< double > &B, Vector< double > &C)
Definition: oomph-lib/src/generic/Vector.h:319
double angle(const Vector< double > &a, const Vector< double > &b)
Get the angle between two vector.
Definition: oomph-lib/src/generic/Vector.h:309
void check_lengths_match(const Vector< double > &a, const Vector< double > &b)
Check the lengths if two Vectors are the same length.
Definition: oomph-lib/src/generic/Vector.h:271
double magnitude(const Vector< double > &a)
Get the magnitude of a vector.
Definition: oomph-lib/src/generic/Vector.h:303
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
void output(std::ostream &outfile)
Output with default number of plot points.
Definition: gen_axisym_advection_diffusion_elements.h:161
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
Definition: TutorialInplaceLU.cpp:2