10 #ifndef MECURYDPM_VECTOR_H
11 #define MECURYDPM_VECTOR_H
22 template<
unsigned int N>
60 Vec3D(
const std::array<Mdouble, 3>& vector)
95 {
return X == 0.0 &&
Y == 0.0 &&
Z == 0.0; }
126 return X ==
a.X and
Y ==
a.Y and
Z ==
a.Z;
180 return X>=
a.X &&
Y>=
a.Y &&
Z>=
a.Z;
184 return X<
a.X &&
Y<
a.Y &&
Z<
a.Z;
304 const double X =
a.X-
b.X;
305 const double Y =
a.Y-
b.Y;
306 const double Z =
a.Z-
b.Z;
307 return (
X *
X +
Y *
Y +
Z *
Z);
326 return (
a.X *
a.X +
a.Y *
a.Y +
a.Z *
a.Z);
364 throw std::out_of_range(
"Index out of bounds");
382 throw std::out_of_range(
"Index out of bounds");
double Mdouble
Definition: GeneralDefine.h:13
Scalar * b
Definition: benchVecAdd.cpp:17
Definition: SmallVector.h:42
Definition: Kernel/Math/Vector.h:30
Mdouble & y()
RW reference to Y.
Definition: Kernel/Math/Vector.h:401
Mdouble Y
Definition: Kernel/Math/Vector.h:45
static Vec3D square(const Vec3D &a)
Calculates the pointwise square of a Vec3D.
Definition: Vector.cc:94
friend std::istream & operator>>(std::istream &is, Vec3D &a)
Adds elements to an input stream.
Definition: Vector.cc:393
static Mdouble getDistance(const Vec3D &a, const Vec3D &b)
Calculates the distance between two Vec3D: .
Definition: Vector.cc:155
Vec3D getCylindricalTensorField(const Vec3D &position) const
Returns this vector field at point p to cylindrical coordinates.
Definition: Vector.cc:280
Vec3D operator/(Mdouble a) const
Divides by a scalar.
Definition: Kernel/Math/Vector.h:158
Vec3D operator*(const Mdouble a) const
Multiplies by a scalar.
Definition: Kernel/Math/Vector.h:147
Mdouble Z
Definition: Kernel/Math/Vector.h:45
Mdouble & z()
RW reference to Z.
Definition: Kernel/Math/Vector.h:413
Vec3D divideElementwise(const Vec3D &a) const
Definition: Kernel/Math/Vector.h:133
Mdouble getRadialCoordinateSquared() const
Returns the square of the radial cylindrical coordinate, r^2=x^2+y^2.
Definition: Vector.cc:217
static Vec3D max(const Vec3D &a, const Vec3D &b)
Calculates the pointwise maximum of two Vec3D.
Definition: Vector.cc:69
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
Definition: Vector.cc:82
Mdouble y() const
RO reference to Y.
Definition: Kernel/Math/Vector.h:407
Mdouble dot(const Vec3D &b) const
Calculates the dot product of this with another Vec3D: .
Definition: Kernel/Math/Vector.h:237
void setNaN()
Sets all elements to NaN.
Definition: Vector.cc:33
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Kernel/Math/Vector.h:324
Vec3D & operator+=(const Vec3D &a)
Adds another vector.
Definition: Kernel/Math/Vector.h:168
bool operator==(const Vec3D &a) const
Definition: Kernel/Math/Vector.h:124
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:143
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Definition: Vector.cc:174
Vec3D operator-(const Vec3D a) const
Binary vector subtraction.
Definition: Kernel/Math/Vector.h:119
Mdouble X
the vector components
Definition: Kernel/Math/Vector.h:45
Vec3D getSphericalCoordinates() const
Returns the representation of this Vec3D in spherical coordinates.
Definition: Vector.cc:231
Vec3D multiplyElementwise(const Vec3D &a) const
Definition: Kernel/Math/Vector.h:129
Vec3D & operator-=(const Vec3D &a)
Subtracts another vector.
Definition: Kernel/Math/Vector.h:193
Vec3D getCylindricalCoordinates() const
Returns the representation of this Vec3D in cylindrical coordinates.
Definition: Vector.cc:270
friend Vec3D operator-(const Vec3D &a)
Reverts the direction of a vector.
Definition: Kernel/Math/Vector.h:500
Vec3D(const std::array< Mdouble, 3 > &vector)
Alternative constructor, taking a const std::array<Mdouble, 3>
Definition: Kernel/Math/Vector.h:60
Vec3D()
constructor
Definition: Kernel/Math/Vector.h:50
bool operator<(const Vec3D &a) const
Definition: Kernel/Math/Vector.h:183
Vec3D signedSquare() const
Definition: Kernel/Math/Vector.h:137
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Definition: Kernel/Math/Vector.h:303
static double min(const Vec3D &a)
Calculates the minimum coordinate of vector a.
Definition: Kernel/Math/Vector.h:257
bool operator>=(const Vec3D &a) const
Checks if all coordinates satisfy this>=a.
Definition: Kernel/Math/Vector.h:179
Vec3D cross(const Vec3D &b) const
Calculates the cross product of this with another Vec3D: .
Definition: Kernel/Math/Vector.h:287
void setZero()
Sets all elements to zero.
Definition: Vector.cc:23
Vec3D(const Mdouble x, const Mdouble y, const Mdouble z)
Alternative constructor, taking the three elements as arguments.
Definition: Kernel/Math/Vector.h:74
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
Definition: Vector.cc:164
static double max(const Vec3D &a)
Calculates the maximum coordinate of vector a.
Definition: Kernel/Math/Vector.h:252
Mdouble getZ() const
Definition: Kernel/Math/Vector.h:437
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:56
void set(Mdouble x, Mdouble y, Mdouble z)
Definition: Kernel/Math/Vector.h:440
void setLength(Mdouble length)
Make this Vec3D a certain length.
Definition: Vector.cc:118
Mdouble & x()
RW reference to X.
Definition: Kernel/Math/Vector.h:389
void setComponent(int index, double val)
Sets the requested component of this Vec3D to the requested value.
Definition: Vector.cc:197
Mdouble getRadialCoordinate() const
Returns the square of the radial cylindrical coordinate, r=sqrt(x^2+y^2).
Definition: Vector.cc:222
Vec3D & operator/=(const Mdouble a)
Divides by a scalar.
Definition: Kernel/Math/Vector.h:220
bool isNaN() const
Checks if ALL elements are zero.
Definition: Vector.cc:44
void setY(Mdouble y)
Definition: Kernel/Math/Vector.h:425
friend std::ostream & operator<<(std::ostream &os, const Vec3D &a)
Adds elements to an output stream.
Definition: Vector.cc:380
Mdouble getLength() const
Calculates the length of this Vec3D: .
Definition: Vector.cc:339
Vec3D & operator*=(Mdouble a)
Multiplies by a scalar.
Definition: Kernel/Math/Vector.h:207
bool isEqualTo(const Vec3D &other, double tol) const
Checks if the length this Vec3D is equal the length of other with a certain tolerance.
Definition: Vector.cc:313
Mdouble x() const
RO reference to X.
Definition: Kernel/Math/Vector.h:395
Mdouble getX() const
Definition: Kernel/Math/Vector.h:431
Vec3D getFromCylindricalCoordinates() const
Returns the representation of this Vec3D in cylindrical coordinates.
Definition: Vector.cc:298
Mdouble & operator[](int index)
Implements operator [] to easier access to x, y, z.
Definition: Kernel/Math/Vector.h:353
void setZ(Mdouble z)
Definition: Kernel/Math/Vector.h:428
bool isZero() const
Checks if ALL elements are zero.
Definition: Kernel/Math/Vector.h:94
void normalise()
Makes this Vec3D unit length.
Definition: Vector.cc:103
friend Vec3D operator*(Mdouble a, const Vec3D &b)
Multiplies all elements by a scalar.
Definition: Kernel/Math/Vector.h:513
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
Definition: Vector.cc:364
void setX(Mdouble x)
Definition: Kernel/Math/Vector.h:422
Mdouble z() const
RO reference to Z.
Definition: Kernel/Math/Vector.h:419
Mdouble getY() const
Definition: Kernel/Math/Vector.h:434
static Vec3D sqrt(const Vec3D &a)
Calculates the pointwise square root of a Vec3D.
Definition: Vector.cc:131
Vec3D operator+(const Vec3D &a) const
Adds another vector.
Definition: Kernel/Math/Vector.h:108
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
const Scalar * a
Definition: level2_cplx_impl.h:32
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
val
Definition: calibrate.py:119