#include <Vector.h>
Public Types | |
| typedef boost::shared_array< TYPE > | DATA_SPTR |
Public Member Functions | |
| Vector (unsigned int N) | |
| Initialize with only a size. | |
| Vector (unsigned int N, TYPE val) | |
| Initialize with a size and default value. | |
| Vector (unsigned int N, DATA_SPTR data) | |
| Initialize from a smart pointer. | |
| Vector (const Vector &other) | |
| copy constructor | |
| ~Vector () | |
| unsigned int | size () const |
| return the size (dimension) of the vector | |
| TYPE | getVal (unsigned int i) const |
| returns the value at a particular index | |
| void | setVal (unsigned int i, TYPE val) |
| sets the index at a particular value | |
| TYPE | operator[] (unsigned int i) const |
| TYPE & | operator[] (unsigned int i) |
| TYPE * | getData () |
| returns a pointer to our data array | |
| const TYPE * | getData () const |
| returns a const pointer to our data array | |
| Vector< TYPE > & | assign (const Vector< TYPE > &other) |
| Copy operator. | |
| Vector< TYPE > & | operator+= (const Vector< TYPE > &other) |
| elementwise addition, vectors must be the same size. | |
| Vector< TYPE > & | operator-= (const Vector< TYPE > &other) |
| elementwise subtraction, vectors must be the same size. | |
| Vector< TYPE > & | operator*= (TYPE scale) |
| multiplication by a scalar | |
| Vector< TYPE > & | operator/= (TYPE scale) |
| division by a scalar | |
| TYPE | normL2Sq () const |
| L2 norm squared. | |
| TYPE | normL2 () const |
| L2 norm. | |
| TYPE | normL1 () const |
| L1 norm. | |
| TYPE | normLinfinity () const |
| L-infinity norm. | |
| unsigned int | largestAbsValId () const |
| Gets the ID of the entry that has the largest absolute value i.e. the entry being used for the L-infinity norm. | |
| unsigned int | largestValId () const |
| Gets the ID of the entry that has the largest value. | |
| TYPE | dotProduct (const Vector< TYPE > other) |
| returns the dot product between two Vectors | |
| void | normalize () |
| Normalize the vector using the L2 norm. | |
| void | setToRandom (unsigned int seed=0) |
| Set to a random unit vector. | |
Definition at line 24 of file Vector.h.
| typedef boost::shared_array<TYPE> RDNumeric::Vector< TYPE >::DATA_SPTR |
| RDNumeric::Vector< TYPE >::Vector | ( | unsigned int | N | ) | [inline, explicit] |
| RDNumeric::Vector< TYPE >::Vector | ( | unsigned int | N, | |
| TYPE | val | |||
| ) | [inline] |
| RDNumeric::Vector< TYPE >::Vector | ( | unsigned int | N, | |
| DATA_SPTR | data | |||
| ) | [inline] |
| RDNumeric::Vector< TYPE >::Vector | ( | const Vector< TYPE > & | other | ) | [inline] |
copy constructor
We make a copy of the other vector's data.
Definition at line 62 of file Vector.h.
References RDNumeric::Vector< TYPE >::getData(), and RDNumeric::Vector< TYPE >::size().
| RDNumeric::Vector< TYPE >::~Vector | ( | ) | [inline] |
| unsigned int RDNumeric::Vector< TYPE >::size | ( | ) | const [inline] |
return the size (dimension) of the vector
Definition at line 75 of file Vector.h.
Referenced by RDNumeric::Vector< TYPE >::assign(), RDNumeric::Vector< TYPE >::dotProduct(), RDNumeric::SymmMatrix< TYPE >::getCol(), RDNumeric::Matrix< double >::getCol(), RDNumeric::SymmMatrix< TYPE >::getRow(), RDNumeric::Matrix< double >::getRow(), RDNumeric::multiply(), RDNumeric::Vector< TYPE >::operator+=(), RDNumeric::Vector< TYPE >::operator-=(), operator<<(), and RDNumeric::Vector< TYPE >::Vector().
| TYPE RDNumeric::Vector< TYPE >::getVal | ( | unsigned int | i | ) | const [inline] |
returns the value at a particular index
Definition at line 80 of file Vector.h.
References RANGE_CHECK.
Referenced by operator<<().
| void RDNumeric::Vector< TYPE >::setVal | ( | unsigned int | i, | |
| TYPE | val | |||
| ) | [inline] |
sets the index at a particular value
Definition at line 86 of file Vector.h.
References RANGE_CHECK.
| TYPE RDNumeric::Vector< TYPE >::operator[] | ( | unsigned int | i | ) | const [inline] |
| TYPE& RDNumeric::Vector< TYPE >::operator[] | ( | unsigned int | i | ) | [inline] |
| TYPE* RDNumeric::Vector< TYPE >::getData | ( | ) | [inline] |
returns a pointer to our data array
Definition at line 102 of file Vector.h.
Referenced by RDNumeric::Vector< TYPE >::assign(), RDNumeric::Vector< TYPE >::dotProduct(), RDNumeric::SymmMatrix< TYPE >::getCol(), RDNumeric::Matrix< double >::getCol(), RDNumeric::SymmMatrix< TYPE >::getRow(), RDNumeric::Matrix< double >::getRow(), RDNumeric::multiply(), RDNumeric::Vector< TYPE >::operator+=(), RDNumeric::Vector< TYPE >::operator-=(), and RDNumeric::Vector< TYPE >::Vector().
| const TYPE* RDNumeric::Vector< TYPE >::getData | ( | ) | const [inline] |
| Vector<TYPE>& RDNumeric::Vector< TYPE >::assign | ( | const Vector< TYPE > & | other | ) | [inline] |
Copy operator.
We make a copy of the other Vector's data.
Definition at line 116 of file Vector.h.
References CHECK_INVARIANT, RDNumeric::Vector< TYPE >::getData(), and RDNumeric::Vector< TYPE >::size().
| Vector<TYPE>& RDNumeric::Vector< TYPE >::operator+= | ( | const Vector< TYPE > & | other | ) | [inline] |
elementwise addition, vectors must be the same size.
Definition at line 124 of file Vector.h.
References CHECK_INVARIANT, RDNumeric::Vector< TYPE >::getData(), and RDNumeric::Vector< TYPE >::size().
| Vector<TYPE>& RDNumeric::Vector< TYPE >::operator-= | ( | const Vector< TYPE > & | other | ) | [inline] |
elementwise subtraction, vectors must be the same size.
Definition at line 136 of file Vector.h.
References CHECK_INVARIANT, RDNumeric::Vector< TYPE >::getData(), and RDNumeric::Vector< TYPE >::size().
| Vector<TYPE>& RDNumeric::Vector< TYPE >::operator*= | ( | TYPE | scale | ) | [inline] |
| Vector<TYPE>& RDNumeric::Vector< TYPE >::operator/= | ( | TYPE | scale | ) | [inline] |
| TYPE RDNumeric::Vector< TYPE >::normL2Sq | ( | ) | const [inline] |
L2 norm squared.
Definition at line 166 of file Vector.h.
Referenced by RDNumeric::Vector< TYPE >::normL2().
| TYPE RDNumeric::Vector< TYPE >::normL2 | ( | ) | const [inline] |
L2 norm.
Definition at line 177 of file Vector.h.
References RDNumeric::Vector< TYPE >::normL2Sq().
Referenced by RDNumeric::Vector< TYPE >::normalize().
| TYPE RDNumeric::Vector< TYPE >::normL1 | ( | ) | const [inline] |
| TYPE RDNumeric::Vector< TYPE >::normLinfinity | ( | ) | const [inline] |
| unsigned int RDNumeric::Vector< TYPE >::largestAbsValId | ( | ) | const [inline] |
| unsigned int RDNumeric::Vector< TYPE >::largestValId | ( | ) | const [inline] |
| TYPE RDNumeric::Vector< TYPE >::dotProduct | ( | const Vector< TYPE > | other | ) | [inline] |
returns the dot product between two Vectors
Definition at line 235 of file Vector.h.
References CHECK_INVARIANT, RDNumeric::Vector< TYPE >::getData(), and RDNumeric::Vector< TYPE >::size().
| void RDNumeric::Vector< TYPE >::normalize | ( | ) | [inline] |
Normalize the vector using the L2 norm.
Definition at line 248 of file Vector.h.
References RDNumeric::Vector< TYPE >::normL2().
Referenced by RDNumeric::Vector< TYPE >::setToRandom().
| void RDNumeric::Vector< TYPE >::setToRandom | ( | unsigned int | seed = 0 |
) | [inline] |
Set to a random unit vector.
Definition at line 254 of file Vector.h.
References RDNumeric::Vector< TYPE >::normalize().
1.5.6