Skip to content

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

cpp
dVectorN();

Default constructor. Creates empty vector.

cpp
dVectorN(const size_t size_in): storage(size_in, 0.0);

Constructor. Creates the vector of the given size and sets its components to zero.

cpp
dVectorN(const size_t size_in, const double value);

Constructor. Creates the vector of the given size and sets its components to the given value.

cpp
dVectorN(const dVectorN& rhs);

Copy constructor. Initializes current vector with the copy of the rhs vector.

cpp
dVectorN(const std::vector<double>& vec);

Constructor. Initializes the current vector with the content of the std::vector<>.

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

Constructor. Initializes the current vector with the content of the std::initializer_list<>.

cpp
void set_to_zero();

Sets all component of the current vector to the zero.

cpp
void set_to_value(const double value);

Sets all component of the current vector to the given value.

cpp
void Allocate(const size_t size_in);

Allocates the storage of the current vector to the given size.

cpp
void push_back(const double value);

Append new vector component at the back of the current vector. Increases vector size by 1.

cpp
static dVectorN ZeroVector(size_t size_in);

Returns vector of the given size with all its element set to zero.

cpp
static dVectorN UnitVector(size_t size_in);

Returns vector with the given size with all its element set to one.

Access operators

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

Random access operator. Returns the reference to the vector component pointer to by the index i.

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

Random access operator. Returns const reference to the vector component pointer to by the index i.

cpp
double* data(void);

Returns pointer to the stored data.

cpp
const double* data(void) const;

Returns const pointer to the stored data.

Arithmetic and matrix-vector operations

cpp
double norm() const;

Returns the norm of the current vector.

cpp
double sum() const;

Returns the sum of all elements of the current vector.

cpp
double max() const;

Returns the maximum of all elements of the current vector.

cpp
double absMax() const;

Returns the maximum (by the absolute value) of all elements of the current vector.

cpp
double Average() const;

Returns the average of all elements of the current vector.

cpp
void normalize();

Normalizes the current vector.

cpp
dVectorN& pow(double exponent);

Rises all elements of the current vector to the given exponent.

cpp
dVectorN& sqrt();

Takes the square roots of all current vector components.

cpp
dVectorN sqrted() const;

Returns the copy of the current vector with the square roots of all its components.

cpp
dVectorN& tanh();

Takes hyperbolic tangent of all current vector components.

cpp
dVectorN& fabs();

Applies absolute value to all current vector components.

cpp
dVectorN fabsd();

Returns the copy of the current vector with the absolute values of all its components.

cpp
double dot(const dVectorN& rhs) const;

Dot product of the two vectors.

cpp
dVectorN& min(const dVectorN& rhs);

Replaces the elements of the current vector with the minimum elements between the two vectors.

cpp
dVectorN minimized(const dVectorN& rhs) const;

Returns vector containing minimum elements between the two vectors.

cpp
dVectorN& max(const dVectorN& rhs);

Replaces the elements of the current vector with the maximum elements between the two vectors.

cpp
dVectorN maximized(const dVectorN& rhs) const;

Returns vector containing maximum elements between the two vectors.

cpp
dVectorN& min(double scalar);

Applies upper value limit, set by the scalar factor, to all elements of the current vector.

cpp
dVectorN 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.

cpp
dVectorN& max(double scalar);

Applies lower value limit, set by the scalar factor, to all elements of the current vector

cpp
dVectorN 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.

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

Assigns the copy of the rhs to the current vector.

cpp
dVectorN operator*(const double m) const;

Returns the copy of the current vector with all its components multiplied by the value m.

cpp
dVectorN operator/(const double m) const;

Returns the copy of the current vector with all its components divided by the value m.

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

Multiplies all elements of the current vector by the value m.

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

Divides all elements of the current vector by the value m.

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

Returns the sum of the current vector and the rhs.

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

Returns the difference of the current vector and the rhs.

cpp
dVectorN operator*(const dVectorN& rhs) const;

Returns a copy of the current vector component-wise multiplied with the rhs (non-standard operator).

cpp
dVectorN operator/(const dVectorN& rhs) const;

Returns a copy of the current vector component-wise divided by the rhs (non-standard operator).

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

Adds rhs vector to the current vector.

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

Subtracts rhs vector from the current vector.

cpp
dVectorN& operator/=(const dVectorN& rhs);

Returns component-wise division of the current vector and the rhs (non-standard operator).

cpp
dVectorN& operator*=(const dVectorN& rhs);

Returns component-wise product of the current vector and the rhs (non-standard operator).

Container properties

cpp
size_t size(void) const;

Returns the size of the vector.

Read/write methods

cpp
std::string print(void) const;

Returns formatted string with vector content.

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

Reads vector content from the binary input stream.

cpp
void write_binary(std::ostream& outp) const;

Writes vector content into the binary output stream.

Iterators

cpp
iterator begin();

Iterator to the begin of the vector.

cpp
citerator cbegin() const;

Constant iterator to the begin of the vector.

cpp
iterator end();

Iterator to the end of the vector.

cpp
citerator cend() const;

Constant iterator to the end of the vector.

Released under the GNU GPLv3 License.