NetworKit::Vector Class Reference

The Vector class represents a basic vector with double coefficients. More...

`#include <Vector.h>`

## Public Member Functions

Vector ()
Default constructor. More...

Vector (const count dimension, const double initialValue=0, const bool transpose=false)
Constructs the Vector with dimension elements with value initialValue. More...

Vector (const std::vector< double > &values, const bool transpose=false)
Constructs the Vector with the contents of values. More...

Vector (const std::initializer_list< double > &list)
Constructs the Vector from the contents of the initializer list list. More...

Vector (const Vector &other)=default
Default copy constructor. More...

Vector (Vector &&other)=default
Default move constructor. More...

virtual ~Vector ()=default
Default destructor. More...

Vectoroperator= (const Vector &other)=default
Default copy assignment operator. More...

Vectoroperator= (Vector &&other)=default
Default move assignment operator. More...

count getDimension () const

bool isTransposed () const
A transposed vector is a row vector. More...

Vector transpose () const

double length () const
Calculates and returns the Euclidean length of this vector. More...

double mean () const
Calculates and returns the arithmetic mean of this vector. More...

double & operator[] (const index idx)
Returns a reference to the element at index idx without checking the range of this vector. More...

const double & operator[] (const index idx) const
Returns a constant reference to the element at index idx without checking the range of this vector. More...

double & at (const index idx)
Returns a reference to the element at index idx. More...

bool operator== (const Vector &other) const
Compares this vector and other element-wise. More...

bool operator!= (const Vector &other) const
Compares this vector and other element-wise. More...

double operator* (const Vector &other) const
Computes the inner product (dot product) of this vector and other. More...

template<typename Matrix = DynamicMatrix>
Vector operator* (const Matrix &matrix) const
Multiplies this vector with matrix and returns the result. More...

Vector operator* (const double &scalar) const
Multiplies this vector with a scalar specified in scalar and returns the result in a new vector. More...

Vectoroperator*= (const double &scalar)
Multiplies this vector with a scalar specified in scalar. More...

Vector operator/ (const double &divisor) const
Divides this vector by a divisor specified in divisor and returns the result in a new vector. More...

Vectoroperator/= (const double &divisor)
Divides this vector by a divisor specified in divisor. More...

Vector operator+ (const Vector &other) const
Adds this vector to other and returns the result. More...

Vector operator+ (const double value) const
Adds value to each element of this vector and returns the result. More...

Vectoroperator+= (const Vector &other)
Adds other to this vector. More...

Vectoroperator+= (const double value)
Adds value to each element of this vector. More...

Vector operator- (const Vector &other) const
Subtracts other from this vector and returns the result. More...

Vector operator- (const double value) const
Subtracts value from each element of this vector and returns the result. More...

Vectoroperator-= (const Vector &other)
Subtracts other from this vector. More...

Vectoroperator-= (const double value)
Subtracts value from each element of this vector. More...

template<typename F >
void apply (const F unaryElementFunction)
Applies the unary function unaryElementFunction to each value in the Vector. More...

template<typename L >
void forElements (L handle)
Iterate over all elements of the vector and call handler (lambda closure). More...

template<typename L >
void forElements (L handle) const
Iterate over all elements of the vector and call handler (lambda closure). More...

template<typename L >
void parallelForElements (L handle)
Iterate in parallel over all elements of the vector and call handler (lambda closure). More...

template<typename L >
void parallelForElements (L handle) const
Iterate in parallel over all elements of the vector and call handler (lambda closure). More...

## Static Public Member Functions

template<class Matrix = DynamicMatrix>
static Matrix outerProduct (const Vector &v1, const Vector &v2)
Computes the outer product of v1 and v2. More...

static double innerProduct (const Vector &v1, const Vector &v2)
Computes the inner product (dot product) of the vectors v1 and v2. More...

## Detailed Description

The Vector class represents a basic vector with double coefficients.

## Constructor & Destructor Documentation

 NetworKit::Vector::Vector ( )

Default constructor.

 NetworKit::Vector::Vector ( const count dimension, const double initialValue = `0`, const bool transpose = `false` )

Constructs the Vector with dimension elements with value initialValue.

Parameters
 dimension The dimension of this vector. initialValue All coefficients will be initialized to initialValue. transpose Indicates whether this vector is transposed (row vector) or not (column vector).
 NetworKit::Vector::Vector ( const std::vector< double > & values, const bool transpose = `false` )

Constructs the Vector with the contents of values.

Parameters
 values The values of this Vector. transpose Indicates whether this vector is transposed (row vector) or not (column vector).
 NetworKit::Vector::Vector ( const std::initializer_list< double > & list )

Constructs the Vector from the contents of the initializer list list.

Parameters
 list The initializer list.
 NetworKit::Vector::Vector ( const Vector & other )
default

Default copy constructor.

 NetworKit::Vector::Vector ( Vector && other )
default

Default move constructor.

 virtual NetworKit::Vector::~Vector ( )
virtualdefault

Default destructor.

## Member Function Documentation

template<typename F >
 void NetworKit::Vector::apply ( const F unaryElementFunction )

Applies the unary function unaryElementFunction to each value in the Vector.

Note that it must hold that the function applied to the zero element of this matrix returns the zero element.

Parameters
 unaryElementFunction
 double& NetworKit::Vector::at ( const index idx )
inline

Returns a reference to the element at index idx.

If idx is not a valid index an exception is thrown.

Parameters
 idx The index of the element.
Returns
Reference to the element at index idx.
template<typename L >
 void NetworKit::Vector::forElements ( L handle )
inline

Iterate over all elements of the vector and call handler (lambda closure).

template<typename L >
 void NetworKit::Vector::forElements ( L handle ) const
inline

Iterate over all elements of the vector and call handler (lambda closure).

 count NetworKit::Vector::getDimension ( ) const
inline
Returns
dimension of vector
 double NetworKit::Vector::innerProduct ( const Vector & v1, const Vector & v2 )
static

Computes the inner product (dot product) of the vectors v1 and v2.

Returns
The result of the inner product.
 bool NetworKit::Vector::isTransposed ( ) const

A transposed vector is a row vector.

Returns
True, if this vector is transposed, otherwise false.
 double NetworKit::Vector::length ( ) const

Calculates and returns the Euclidean length of this vector.

Returns
The Euclidean length of this vector.
 double NetworKit::Vector::mean ( ) const

Calculates and returns the arithmetic mean of this vector.

Returns
The arithmetic mean of this vector.
 bool NetworKit::Vector::operator!= ( const Vector & other ) const

Compares this vector and other element-wise.

Returns
True, if this vector is element-wise unequal to other, otherwise false.
 double NetworKit::Vector::operator* ( const Vector & other ) const

Computes the inner product (dot product) of this vector and other.

Returns
The result of the inner product.
template<class Matrix >
 Vector NetworKit::Vector::operator* ( const Matrix & matrix ) const

Multiplies this vector with matrix and returns the result.

Returns
The result of multiplying this vector with matrix.
 Vector NetworKit::Vector::operator* ( const double & scalar ) const

Multiplies this vector with a scalar specified in scalar and returns the result in a new vector.

Returns
The result of multiplying this vector with scalar.
 Vector & NetworKit::Vector::operator*= ( const double & scalar )

Multiplies this vector with a scalar specified in scalar.

Returns
Reference to this vector.
 Vector NetworKit::Vector::operator+ ( const Vector & other ) const

Adds this vector to other and returns the result.

Note that the dimensions of the vectors have to be the same.

Returns
The sum of this vector and other.
 Vector NetworKit::Vector::operator+ ( const double value ) const

Adds value to each element of this vector and returns the result.

 Vector & NetworKit::Vector::operator+= ( const Vector & other )

Note that the dimensions of the vectors have to be the same.

Returns
Reference to this vector.
 Vector & NetworKit::Vector::operator+= ( const double value )

Adds value to each element of this vector.

 Vector NetworKit::Vector::operator- ( const Vector & other ) const

Subtracts other from this vector and returns the result.

Note that the dimensions of the vectors have to be the same.

Returns
The difference of this vector and other.
 Vector NetworKit::Vector::operator- ( const double value ) const

Subtracts value from each element of this vector and returns the result.

 Vector & NetworKit::Vector::operator-= ( const Vector & other )

Subtracts other from this vector.

Note that the dimensions of the vectors have to be the same.

Returns
Reference to this vector.
 Vector & NetworKit::Vector::operator-= ( const double value )

Subtracts value from each element of this vector.

 Vector NetworKit::Vector::operator/ ( const double & divisor ) const

Divides this vector by a divisor specified in divisor and returns the result in a new vector.

Returns
The result of dividing this vector by divisor.
 Vector & NetworKit::Vector::operator/= ( const double & divisor )

Divides this vector by a divisor specified in divisor.

Returns
Reference to this vector.
 Vector& NetworKit::Vector::operator= ( const Vector & other )
default

Default copy assignment operator.

 Vector& NetworKit::Vector::operator= ( Vector && other )
default

Default move assignment operator.

 bool NetworKit::Vector::operator== ( const Vector & other ) const

Compares this vector and other element-wise.

Returns
True, if this vector is element-wise equal to other, otherwise false.
 double& NetworKit::Vector::operator[] ( const index idx )
inline

Returns a reference to the element at index idx without checking the range of this vector.

Parameters
 idx The index of the element.
Returns
Reference to the element at index idx.
 const double& NetworKit::Vector::operator[] ( const index idx ) const
inline

Returns a constant reference to the element at index idx without checking the range of this vector.

idx The index of the element.

Returns
Constant reference to the element at index idx.
template<class Matrix >
 Matrix NetworKit::Vector::outerProduct ( const Vector & v1, const Vector & v2 )
static

Computes the outer product of v1 and v2.

Parameters
 v1 First Vector. v2 Second Vector.
Returns
The resulting matrix from the outer product.
template<typename L >
 void NetworKit::Vector::parallelForElements ( L handle )
inline

Iterate in parallel over all elements of the vector and call handler (lambda closure).

template<typename L >
 void NetworKit::Vector::parallelForElements ( L handle ) const
inline

Iterate in parallel over all elements of the vector and call handler (lambda closure).

 Vector NetworKit::Vector::transpose ( ) const
Returns
Transposed copy of this vector.

The documentation for this class was generated from the following files: