Skip to content

dVector3

dVector3 is a static storage container which stores a vector of three double values. It is used to store position vectors, velocities, displacements etc., as a storage unit in Storage3D container.

The data inside of the dVector3 container is manipulated using a number of dedicated methods:

Constructors

cpp
dVector3();

Default constructor, sets vector values to zero;

cpp
dVector3(const dVector3& vecinit);

Copy constructor, initializes the current vector with a copy of vecinit.

cpp
dVector3(std::array<double,3> vecinit);

Constructor, initializes the current vector with a copy of vecinit.

cpp
dVector3(std::array<int,3> vecinit);

Constructor, initializes the current vector with a copy of vecinit.

cpp
dVector3(std::initializer_list<double> vecinit);

Constructor, initializes the current vector using initializer list vecinit.

cpp
static dVector3 ZeroVector(void);

Constructs and returns zero-valued vector.

Access operators

cpp
double& operator[](const size_t i);
double const& operator[](const size_t i) const;

Return (const) reference to the element i.

cpp
double getX(void) const;

Returns the value of the first (X) vector element.

cpp
double getY(void) const;

Returns the value of the second (Y) vector element.

cpp
double getZ(void) const;

Returns the value of the third (Z) vector element.

cpp
double* data(void);
const double* data(void) const;

Returns (const) pointer to the first element of the vector.

Arithmetic and vector operations

cpp
double operator*(const dVector3& rhs) const;

Returns scalar vector product.

cpp
dVector3 cross(const dVector3& rhs) const;

Returns cross product of two vectors.

cpp
dMatrix3x3 dyadic(const dVector3& rhs) const;

Returns dyadic product of two vectors.

cpp
dVector3 operator*(const double m) const;

Returns current vector with all components multiplied by the factor m.

cpp
dVector3 operator/(const double m) const;

Returns current vector with all components divided by the factor m.

cpp
dVector3 operator+(const dVector3& rhs) const;

Returns the sum of two vectors.

cpp
dVector3 operator-(const dVector3& rhs) const;

Returns the difference of two vectors.

cpp
dVector3& operator*=(const double m);

Multiplies all entries of the current vector by the factor m.

cpp
dVector3& operator/=(const double m);

Divides all entries of the current vector by the factor m.

cpp
dVector3& operator-=(const dVector3& rhs);

Subtracts vector rhs from the current vector.

cpp
dVector3& operator+=(const dVector3& rhs);

Adds vector rhs to the current vector.

cpp
dVector3& operator=(const dVector3& rhs);

Assigns the content of the vector rhs to the current vector.

cpp
dVector3& operator=(const double rhs[3]);

Assigns the content of the vector rhs to the current vector.

cpp
double abs() const;
double length(void) const;

Return the length of the current vector.

cpp
double p_norm(double p);

Returns p-norm of the current vector with the given p.

Data manipulation methods

cpp
void setX(const double newX);

Sets first (X) vector element to the specified value newX.

cpp
void setY(const double newX);

Sets second (Y) vector element to the specified value newY.

cpp
void setY(const double newX);

Sets third (Z) vector element to the specified value newZ.

cpp
void set_to_zero(void);

Sets all entries to zero.

cpp
dVector3& normalize(void);

Normalizes the current vector.

cpp
dVector3 normalized(void) const;

Returns normalized copy of the current vector.

cpp
dVector3& rotate(const dMatrix3x3& RotationMatrix);

Rotates current vector using the specified RotationMatrix.

cpp
dVector3 rotated(const dMatrix3x3& RotationMatrix) const;

Returns rotated copy of the current vector using the specified RotationMatrix.

cpp
dVector3 Xreflected(void) const

Returns a copy of the current vector with the sign of the first (X) component reversed.

cpp
dVector3 Yreflected(void) const

Returns a copy of the current vector with the sign of the second (Y) component reversed.

cpp
dVector3 Zreflected(void) const

Returns a copy of the current vector with the sign of the third (Z) component reversed.

Container properties

cpp
constexpr size_t size(void) const;

Returns the size of the stored vector.

MPI communication methods

cpp
void pack(std::vector<double>& buffer);

Packs the content of the current object into the MPI communication buffer.

cpp
void unpack(std::vector<double>& buffer, size_t& it);

Unpacks (reads) the content of the current object from the MPI communication buffer. The existing data in the container is overwritten.

Read/write methods

cpp
std::string print(void) const;

Returns formatted string of the vector values ready to print to the terminal.

cpp
void read_ASCII(std::istream& inp);

Reads vector content from the input stream.

cpp
void write_ASCII(std::ostream& outp, const int precision = 16, const char sep = ' ') const;

Writes vector content in ASCII format with the specified precision using sep as entry separator into the output stream.

cpp
std::string get_output_string(const int precision = 16, const char sep = ' ') const;

Returns output string with vector content in ASCII format with the specified precision using sep as entry separator.

cpp
std::vector<double> get_vector() const;

Returns std::vector containing current vector components.

cpp
std::vector<float> get_vector_float() const;

Returns std::vector<float> containing current vector components rounded to float precision.

Released under the GNU GPLv3 License.