namespace ewalena  0.2.15
ewalena is not an acronym
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Private Attributes | Friends
ewalena::Vector< ValueType > Class Template Reference

#include <include/ewalena/lac/vector.h>

List of all members.

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)

Detailed Description

template<typename ValueType = double>
class ewalena::Vector< ValueType >

A class that denotes a simple vector with no special qualities, ie. no special data access, etc.

Author:
Toby D. Young 2012.

Constructor & Destructor Documentation

template<typename ValueType = double>
ewalena::Vector< ValueType >::Vector ( )

Constructor - a vector of zero dimension.

template<typename ValueType = double>
ewalena::Vector< ValueType >::~Vector ( )

Destructor.

template<typename ValueType = double>
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.

template<typename ValueType = double>
ewalena::Vector< ValueType >::Vector ( const Vector< ValueType > &  v)

Initialize a vector with another vector v with a memory copy.

template<typename ValueType = double>
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;

Note:
A typical usage of this could be: ewalena::Vector<double> V = {1.0, 1.1, 1.25}.

Member Function Documentation

template<typename ValueType >
void ewalena::Vector< ValueType >::diag ( const Matrix< ValueType > &  M) [inline]

Return the diagonal of a matrix as this vector.

template<typename ValueType >
ValueType ewalena::Vector< ValueType >::l1_norm ( )

Return the $\ell_1$-norm of this vector.

template<typename ValueType >
ValueType ewalena::Vector< ValueType >::l2_norm ( )

Return the $\ell_2$-norm of this vector.

template<typename ValueType >
void ewalena::Vector< ValueType >::l2_normalize ( ) [inline]

Normalise this vector by the $\ell_2$-norm.

template<typename ValueType >
ValueType ewalena::Vector< ValueType >::lp_norm ( unsigned int  p)

Return the $\ell_p$-norm of this vector, where $p\in{\mathbb Z}^+$.

template<typename ValueType >
void ewalena::Vector< ValueType >::lp_normalize ( const unsigned int  p) [inline]

Normalise this vector by the $\ell_p$-norm, where $p\in{\mathbb Z}^+$.

template<typename ValueType >
unsigned int ewalena::Vector< ValueType >::n_rows ( ) const [inline]

Return the size of this vector.

template<typename ValueType >
ValueType & ewalena::Vector< ValueType >::operator() ( const unsigned int  i) [inline]

Read-write access to the ith index of this vector.

template<typename ValueType >
const ValueType & ewalena::Vector< ValueType >::operator() ( const unsigned int  i) const [inline]

Read only access to the ith index of this vector.

template<typename ValueType = double>
const ValueType* ewalena::Vector< ValueType >::operator* ( ) const [inline, protected]

Read only access operator to the underlying C array structure associated with this vector.

template<typename ValueType = double>
ValueType* ewalena::Vector< ValueType >::operator* ( ) [inline, protected]

Read-write access operator to the underlying C array structure associated with this vector.

template<typename ValueType >
void ewalena::Vector< ValueType >::operator*= ( const ValueType &  scalar) [inline]

Inline multiplication operator. Multiply each component of this vector by a scalar.

template<typename ValueType >
void ewalena::Vector< ValueType >::operator+= ( const Vector< ValueType > &  v) [inline]

Inline addition operator. Add v to this vector.

template<typename ValueType >
void ewalena::Vector< ValueType >::operator-= ( const Vector< ValueType > &  v) [inline]

Inline subtraction operator. Subtract v from this vector.

template<typename ValueType >
void ewalena::Vector< ValueType >::operator/= ( const ValueType &  scalar) [inline]

Inline division operator. Divide each component of this vector by a scalar.

template<typename ValueType >
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.

template<typename ValueType >
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.

template<typename ValueType = double>
void ewalena::Vector< ValueType >::reinit ( )

Reinitialise the contents of this vector to nothing (zero).

template<typename ValueType = double>
void ewalena::Vector< ValueType >::reinit ( const unsigned int  m,
const bool  zero = true 
)

Reinitialise this vector to size m.

template<typename ValueType >
void ewalena::Vector< ValueType >::sadd ( const ValueType  a,
const Vector< ValueType > &  v 
) [inline]

Scale-and-add. Return this = a*v;

template<typename ValueType >
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;

template<typename ValueType = double>
unsigned int ewalena::Vector< ValueType >::size ( ) const

Return the size of this vector (number of rows).


Friends And Related Function Documentation

template<typename ValueType = double>
std::ostream& operator<< ( std::ostream &  output,
const Vector< ValueType > &  v 
) [friend]

Output operator to stream.


Member Data Documentation

template<typename ValueType = double>
unsigned int ewalena::Vector< ValueType >::__n_rows [private]

Internal reference to this vector size, ie. the number of rows this vector has.

template<typename ValueType = double>
ValueType* ewalena::Vector< ValueType >::data [private]

Internal object denoting this vector data.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines