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
cppdVector3();Default constructor, sets vector values to zero;
cppdVector3(const dVector3& vecinit);Copy constructor, initializes the current vector with a copy of
vecinit.
cppdVector3(std::array<double,3> vecinit);Constructor, initializes the current vector with a copy of
vecinit.
cppdVector3(std::array<int,3> vecinit);Constructor, initializes the current vector with a copy of
vecinit.
cppdVector3(std::initializer_list<double> vecinit);Constructor, initializes the current vector using initializer list
vecinit.
cppstatic dVector3 ZeroVector(void);Constructs and returns zero-valued vector.
Access operators
cppdouble& operator[](const size_t i); double const& operator[](const size_t i) const;Return (const) reference to the element
i.
cppdouble getX(void) const;Returns the value of the first (X) vector element.
cppdouble getY(void) const;Returns the value of the second (Y) vector element.
cppdouble getZ(void) const;Returns the value of the third (Z) vector element.
cppdouble* data(void); const double* data(void) const;Returns (const) pointer to the first element of the vector.
Arithmetic and vector operations
cppdouble operator*(const dVector3& rhs) const;Returns scalar vector product.
cppdVector3 cross(const dVector3& rhs) const;Returns cross product of two vectors.
cppdMatrix3x3 dyadic(const dVector3& rhs) const;Returns dyadic product of two vectors.
cppdVector3 operator*(const double m) const;Returns current vector with all components multiplied by the factor
m.
cppdVector3 operator/(const double m) const;Returns current vector with all components divided by the factor
m.
cppdVector3 operator+(const dVector3& rhs) const;Returns the sum of two vectors.
cppdVector3 operator-(const dVector3& rhs) const;Returns the difference of two vectors.
cppdVector3& operator*=(const double m);Multiplies all entries of the current vector by the factor
m.
cppdVector3& operator/=(const double m);Divides all entries of the current vector by the factor
m.
cppdVector3& operator-=(const dVector3& rhs);Subtracts vector
rhsfrom the current vector.
cppdVector3& operator+=(const dVector3& rhs);Adds vector
rhsto the current vector.
cppdVector3& operator=(const dVector3& rhs);Assigns the content of the vector
rhsto the current vector.
cppdVector3& operator=(const double rhs[3]);Assigns the content of the vector
rhsto the current vector.
cppdouble abs() const; double length(void) const;Return the length of the current vector.
cppdouble p_norm(double p);Returns p-norm of the current vector with the given
p.
Data manipulation methods
cppvoid setX(const double newX);Sets first (X) vector element to the specified value
newX.
cppvoid setY(const double newX);Sets second (Y) vector element to the specified value
newY.
cppvoid setY(const double newX);Sets third (Z) vector element to the specified value
newZ.
cppvoid set_to_zero(void);Sets all entries to zero.
cppdVector3& normalize(void);Normalizes the current vector.
cppdVector3 normalized(void) const;Returns normalized copy of the current vector.
cppdVector3& rotate(const dMatrix3x3& RotationMatrix);Rotates current vector using the specified
RotationMatrix.
cppdVector3 rotated(const dMatrix3x3& RotationMatrix) const;Returns rotated copy of the current vector using the specified
RotationMatrix.
cppdVector3 Xreflected(void) constReturns a copy of the current vector with the sign of the first (X) component reversed.
cppdVector3 Yreflected(void) constReturns a copy of the current vector with the sign of the second (Y) component reversed.
cppdVector3 Zreflected(void) constReturns a copy of the current vector with the sign of the third (Z) component reversed.
Container properties
cppconstexpr size_t size(void) const;Returns the size of the stored vector.
MPI communication methods
cppvoid pack(std::vector<double>& buffer);Packs the content of the current object into the MPI communication buffer.
cppvoid 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
cppstd::string print(void) const;Returns formatted string of the vector values ready to print to the terminal.
cppvoid read_ASCII(std::istream& inp);Reads vector content from the input stream.
cppvoid write_ASCII(std::ostream& outp, const int precision = 16, const char sep = ' ') const;Writes vector content in ASCII format with the specified
precisionusingsepas entry separator into the output stream.
cppstd::string get_output_string(const int precision = 16, const char sep = ' ') const;Returns output string with vector content in ASCII format with the specified
precisionusingsepas entry separator.
cppstd::vector<double> get_vector() const;Returns
std::vectorcontaining current vector components.
cppstd::vector<float> get_vector_float() const;Returns
std::vector<float>containing current vector components rounded tofloatprecision.