namespace ewalena
0.2.15
ewalena is not an acronym
|
#include <include/ewalena/lac/vector.h>
Public Member Functions | |
void | diag (const Matrix< ValueType > &M) |
ValueType | l1_norm () |
ValueType | l2_norm () |
void | l2_normalize () |
ValueType | lp_norm (unsigned int p) |
void | lp_normalize (const unsigned int p) |
unsigned int | n_rows () const |
ValueType & | operator() (const unsigned int i) |
const ValueType & | operator() (const unsigned int i) const |
void | operator*= (const ValueType &scalar) |
void | operator+= (const Vector< ValueType > &v) |
void | operator-= (const Vector< ValueType > &v) |
void | operator/= (const ValueType &scalar) |
void | operator= (const Vector< ValueType > &v) |
bool | operator== (const Vector< ValueType > &v) const |
void | reinit () |
void | reinit (const unsigned int m, const bool zero=true) |
void | sadd (const ValueType a, const Vector< ValueType > &v) |
void | sadd (const ValueType a, const Vector< ValueType > &v, const ValueType b, const Vector< ValueType > &w) |
unsigned int | size () const |
Vector () | |
Vector (const unsigned int m, const bool zero=true) | |
Vector (const Vector< ValueType > &v) | |
Vector (std::initializer_list< ValueType > list) | |
~Vector () | |
Protected Member Functions | |
const ValueType * | operator* () const |
ValueType * | operator* () |
Private Attributes | |
unsigned int | __n_rows |
ValueType * | data |
Friends | |
std::ostream & | operator<< (std::ostream &output, const Vector< ValueType > &v) |
A class that denotes a simple vector with no special qualities, ie. no special data access, etc.
ewalena::Vector< ValueType >::Vector | ( | ) |
Constructor - a vector of zero dimension.
ewalena::Vector< ValueType >::~Vector | ( | ) |
Destructor.
ewalena::Vector< ValueType >::Vector | ( | const unsigned int | m, |
const bool | zero = true |
||
) | [explicit] |
Initialize a vector to size m
. Vector elements are set to zero by default, and otherwise if zero=false
, vector elements are left in an unspecified state.
ewalena::Vector< ValueType >::Vector | ( | const Vector< ValueType > & | v | ) |
Initialize a vector with another vector v
with a memory copy.
ewalena::Vector< ValueType >::Vector | ( | std::initializer_list< ValueType > | list | ) |
Initialize a vector with list v
using a direct memory copy. The length of this
vector after initialization will be equal to the length of the list v
;
ewalena::Vector<double> V = {1.0, 1.1, 1.25}
. void ewalena::Vector< ValueType >::diag | ( | const Matrix< ValueType > & | M | ) | [inline] |
Return the diagonal of a matrix as this vector.
ValueType ewalena::Vector< ValueType >::l1_norm | ( | ) |
Return the -norm of this vector.
ValueType ewalena::Vector< ValueType >::l2_norm | ( | ) |
Return the -norm of this vector.
void ewalena::Vector< ValueType >::l2_normalize | ( | ) | [inline] |
Normalise this vector by the -norm.
ValueType ewalena::Vector< ValueType >::lp_norm | ( | unsigned int | p | ) |
Return the -norm of this vector, where
.
void ewalena::Vector< ValueType >::lp_normalize | ( | const unsigned int | p | ) | [inline] |
Normalise this vector by the -norm, where
.
unsigned int ewalena::Vector< ValueType >::n_rows | ( | ) | const [inline] |
Return the size of this vector.
ValueType & ewalena::Vector< ValueType >::operator() | ( | const unsigned int | i | ) | [inline] |
Read-write access to the i
th index of this vector.
const ValueType & ewalena::Vector< ValueType >::operator() | ( | const unsigned int | i | ) | const [inline] |
Read only access to the i
th index of this vector.
const ValueType* ewalena::Vector< ValueType >::operator* | ( | ) | const [inline, protected] |
Read only access operator to the underlying C array structure associated with this vector.
ValueType* ewalena::Vector< ValueType >::operator* | ( | ) | [inline, protected] |
Read-write access operator to the underlying C array structure associated with this vector.
void ewalena::Vector< ValueType >::operator*= | ( | const ValueType & | scalar | ) | [inline] |
Inline multiplication operator. Multiply each component of this
vector by a scalar
.
void ewalena::Vector< ValueType >::operator+= | ( | const Vector< ValueType > & | v | ) | [inline] |
Inline addition operator. Add v
to this
vector.
void ewalena::Vector< ValueType >::operator-= | ( | const Vector< ValueType > & | v | ) | [inline] |
Inline subtraction operator. Subtract v
from this
vector.
void ewalena::Vector< ValueType >::operator/= | ( | const ValueType & | scalar | ) | [inline] |
Inline division operator. Divide each component of this
vector by a scalar
.
void ewalena::Vector< ValueType >::operator= | ( | const Vector< ValueType > & | v | ) | [inline] |
Copy/equality operator. Make this
vector equal to v
. All data in this
is overwritten, and its size is changed if needed.
bool ewalena::Vector< ValueType >::operator== | ( | const Vector< ValueType > & | v | ) | const [inline] |
Equivalence operator. Return true if this
vector is an identical copy of the vector v
.
void ewalena::Vector< ValueType >::reinit | ( | ) |
Reinitialise the contents of this vector to nothing (zero).
void ewalena::Vector< ValueType >::reinit | ( | const unsigned int | m, |
const bool | zero = true |
||
) |
Reinitialise this vector to size m
.
void ewalena::Vector< ValueType >::sadd | ( | const ValueType | a, |
const Vector< ValueType > & | v | ||
) | [inline] |
Scale-and-add. Return this = a*v
;
void ewalena::Vector< ValueType >::sadd | ( | const ValueType | a, |
const Vector< ValueType > & | v, | ||
const ValueType | b, | ||
const Vector< ValueType > & | w | ||
) | [inline] |
Scale-and-add. Return this = a*v + b*w
;
unsigned int ewalena::Vector< ValueType >::size | ( | ) | const |
Return the size of this vector (number of rows).
std::ostream& operator<< | ( | std::ostream & | output, |
const Vector< ValueType > & | v | ||
) | [friend] |
Output operator to stream.
unsigned int ewalena::Vector< ValueType >::__n_rows [private] |
Internal reference to this vector size, ie. the number of rows this vector has.
ValueType* ewalena::Vector< ValueType >::data [private] |
Internal object denoting this vector data.