dVectorN
dVectorN is the dynamic storage container storing variable length vector of double values. The size of the vector can be set during run time.
The data inside of the dVectorN container is manipulated using a number of dedicated methods:
Constructors
cppdVectorN();Default constructor. Creates empty vector.
cppdVectorN(const size_t size_in): storage(size_in, 0.0);Constructor. Creates the vector of the given size and sets its components to zero.
cppdVectorN(const size_t size_in, const double value);Constructor. Creates the vector of the given size and sets its components to the given value.
cppdVectorN(const dVectorN& rhs);Copy constructor. Initializes current vector with the copy of the
rhsvector.
cppdVectorN(const std::vector<double>& vec);Constructor. Initializes the current vector with the content of the std::vector<>.
cppdVectorN(std::initializer_list<double> vecinit);Constructor. Initializes the current vector with the content of the std::initializer_list<>.
cppvoid set_to_zero();Sets all component of the current vector to the zero.
cppvoid set_to_value(const double value);Sets all component of the current vector to the given value.
cppvoid Allocate(const size_t size_in);Allocates the storage of the current vector to the given size.
cppvoid push_back(const double value);Append new vector component at the back of the current vector. Increases vector size by 1.
cppstatic dVectorN ZeroVector(size_t size_in);Returns vector of the given size with all its element set to zero.
cppstatic dVectorN UnitVector(size_t size_in);Returns vector with the given size with all its element set to one.
Access operators
cppdouble& operator[](const size_t i):Random access operator. Returns the reference to the vector component pointer to by the index i.
cppdouble const& operator[](const size_t i) const;Random access operator. Returns const reference to the vector component pointer to by the index i.
cppdouble* data(void);Returns pointer to the stored data.
cppconst double* data(void) const;Returns const pointer to the stored data.
Arithmetic and matrix-vector operations
cppdouble norm() const;Returns the norm of the current vector.
cppdouble sum() const;Returns the sum of all elements of the current vector.
cppdouble max() const;Returns the maximum of all elements of the current vector.
cppdouble absMax() const;Returns the maximum (by the absolute value) of all elements of the current vector.
cppdouble Average() const;Returns the average of all elements of the current vector.
cppvoid normalize();Normalizes the current vector.
cppdVectorN& pow(double exponent);Rises all elements of the current vector to the given exponent.
cppdVectorN& sqrt();Takes the square roots of all current vector components.
cppdVectorN sqrted() const;Returns the copy of the current vector with the square roots of all its components.
cppdVectorN& tanh();Takes hyperbolic tangent of all current vector components.
cppdVectorN& fabs();Applies absolute value to all current vector components.
cppdVectorN fabsd();Returns the copy of the current vector with the absolute values of all its components.
cppdouble dot(const dVectorN& rhs) const;Dot product of the two vectors.
cppdVectorN& min(const dVectorN& rhs);Replaces the elements of the current vector with the minimum elements between the two vectors.
cppdVectorN minimized(const dVectorN& rhs) const;Returns vector containing minimum elements between the two vectors.
cppdVectorN& max(const dVectorN& rhs);Replaces the elements of the current vector with the maximum elements between the two vectors.
cppdVectorN maximized(const dVectorN& rhs) const;Returns vector containing maximum elements between the two vectors.
cppdVectorN& min(double scalar);Applies upper value limit, set by the scalar factor, to all elements of the current vector.
cppdVectorN minimized(double scalar) const;Returns vector containing the elements of the current vector with upper value limit, set by the scalar factor, applied to all elements.
cppdVectorN& max(double scalar);Applies lower value limit, set by the scalar factor, to all elements of the current vector
cppdVectorN maximized(double scalar) const;Returns vector containing the elements of the current vector with lower value limit, set by the scalar factor, applied to all elements.
cppdVectorN& operator=(const dVectorN& rhs);Assigns the copy of the
rhsto the current vector.
cppdVectorN operator*(const double m) const;Returns the copy of the current vector with all its components multiplied by the value
m.
cppdVectorN operator/(const double m) const;Returns the copy of the current vector with all its components divided by the value
m.
cppdVectorN& operator*=(const double m);Multiplies all elements of the current vector by the value
m.
cppdVectorN& operator/=(const double m);Divides all elements of the current vector by the value
m.
cppdVectorN operator+(const dVectorN& rhs) const;Returns the sum of the current vector and the
rhs.
cppdVectorN operator-(const dVectorN& rhs) const;Returns the difference of the current vector and the
rhs.
cppdVectorN operator*(const dVectorN& rhs) const;Returns a copy of the current vector component-wise multiplied with the
rhs(non-standard operator).
cppdVectorN operator/(const dVectorN& rhs) const;Returns a copy of the current vector component-wise divided by the
rhs(non-standard operator).
cppdVectorN& operator+=( const dVectorN& rhs);Adds
rhsvector to the current vector.
cppdVectorN& operator-=(const dVectorN& rhs);Subtracts
rhsvector from the current vector.
cppdVectorN& operator/=(const dVectorN& rhs);Returns component-wise division of the current vector and the
rhs(non-standard operator).
cppdVectorN& operator*=(const dVectorN& rhs);Returns component-wise product of the current vector and the
rhs(non-standard operator).
Container properties
cppsize_t size(void) const;Returns the size of the vector.
Read/write methods
cppstd::string print(void) const;Returns formatted string with vector content.
cppvoid read_binary(std::istream& inp);Reads vector content from the binary input stream.
cppvoid write_binary(std::ostream& outp) const;Writes vector content into the binary output stream.
Iterators
cppiterator begin();Iterator to the begin of the vector.
cppciterator cbegin() const;Constant iterator to the begin of the vector.
cppiterator end();Iterator to the end of the vector.
cppciterator cend() const;Constant iterator to the end of the vector.