RDNumeric::Vector< TYPE > Class Template Reference

A class to represent vectors of numbers. More...

`#include <Vector.h>`

## Public Types

typedef boost::shared_array< TYPE > | DATA_SPTR

## Public Member Functions

| Vector (unsigned int N)
| Initialize with only a size. More...
| Vector (unsigned int N, TYPE val)
| Initialize with a size and default value. More...
| Vector (unsigned int N, DATA_SPTR data)
| Initialize from a smart pointer. More...
| Vector (const Vector &other)
| copy constructor More...
| ~Vector ()
unsigned int | size () const
| return the size (dimension) of the vector More...
TYPE | getVal (unsigned int i) const
| returns the value at a particular index More...
void | setVal (unsigned int i, TYPE val)
| sets the index at a particular value More...
TYPE | operator[] (unsigned int i) const
TYPE & | operator[] (unsigned int i)
TYPE * | getData ()
| returns a pointer to our data array More...
const TYPE * | getData () const
| returns a const pointer to our data array More...
Vector< TYPE > & | assign (const Vector< TYPE > &other)
| Copy operator. More...
Vector< TYPE > & | operator+= (const Vector< TYPE > &other)
| elementwise addition, vectors must be the same size. More...
Vector< TYPE > & | operator-= (const Vector< TYPE > &other)
| elementwise subtraction, vectors must be the same size. More...
Vector< TYPE > & | operator*= (TYPE scale)
| multiplication by a scalar More...
Vector< TYPE > & | operator/= (TYPE scale)
| division by a scalar More...
TYPE | normL2Sq () const
| L2 norm squared. More...
TYPE | normL2 () const
| L2 norm. More...
TYPE | normL1 () const
| L1 norm. More...
TYPE | normLinfinity () const
| L-infinity norm. More...
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. More...
unsigned int | largestValId () const
| Gets the ID of the entry that has the largest value. More...
unsigned int | smallestValId () const
| Gets the ID of the entry that has the smallest value. More...
TYPE | dotProduct (const Vector< TYPE > other) const
| returns the dot product between two Vectors More...
void | normalize ()
| Normalize the vector using the L2 norm. More...
void | setToRandom (unsigned int seed=0)
| Set to a random unit vector. More...

## Detailed Description

### template<class TYPE>
class RDNumeric::Vector< TYPE >

A class to represent vectors of numbers.

Definition at line 28 of file Vector.h.

## Member Typedef Documentation

## DATA_SPTR

template<class TYPE>

typedef boost::shared_array<TYPE> RDNumeric::Vector< TYPE >::DATA_SPTR

Definition at line 30 of file Vector.h.

## Constructor & Destructor Documentation

## Vector() [1/4]

template<class TYPE>

RDNumeric::Vector< TYPE >::Vector | ( | unsigned int | N | ) |

inline explicit

Initialize with only a size.

Definition at line 33 of file Vector.h.

References RDKit::Drawing::N.

## Vector() [2/4]

template<class TYPE>

RDNumeric::Vector< TYPE >::Vector | ( | unsigned int | N,
|  | TYPE | val
| ) |  |

inline

Initialize with a size and default value.

Definition at line 41 of file Vector.h.

References RDKit::Drawing::N.

## Vector() [3/4]

template<class TYPE>

RDNumeric::Vector< TYPE >::Vector | ( | unsigned int | N,
|  | DATA_SPTR | data
| ) |  |

inline

Initialize from a smart pointer.

NOTE: the data is not copied in this case

Definition at line 56 of file Vector.h.

References RDKit::Drawing::N.

## Vector() [4/4]

template<class TYPE>

RDNumeric::Vector< TYPE >::Vector | ( | const Vector< TYPE > & | other | ) |

inline

copy constructor

We make a copy of the other vector's data.

Definition at line 64 of file Vector.h.

References RDNumeric::Vector< TYPE >::getData(), and RDNumeric::Vector< TYPE >::size().

## ~Vector()

template<class TYPE>

RDNumeric::Vector< TYPE >::~Vector | ( |  | ) |

inline

Definition at line 74 of file Vector.h.

## Member Function Documentation

## assign()

template<class TYPE>

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 114 of file Vector.h.

References RDNumeric::Vector< TYPE >::getData(), PRECONDITION, and RDNumeric::Vector< TYPE >::size().

## dotProduct()

template<class TYPE>

TYPE RDNumeric::Vector< TYPE >::dotProduct | ( | const Vector< TYPE > | other | ) | const

inline

returns the dot product between two Vectors

Definition at line 246 of file Vector.h.

References RDNumeric::Vector< TYPE >::getData(), PRECONDITION, and RDNumeric::Vector< TYPE >::size().

Referenced by RDNumeric::TanimotoSimilarity().

## getData() [1/2]

template<class TYPE>

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::Matrix< double >::getCol(), RDNumeric::SymmMatrix< TYPE >::getCol(), RDNumeric::Matrix< double >::getRow(), RDNumeric::SymmMatrix< TYPE >::getRow(), RDNumeric::multiply(), RDNumeric::Vector< TYPE >::operator+=(), RDNumeric::Vector< TYPE >::operator-=(), and RDNumeric::Vector< TYPE >::Vector().

## getData() [2/2]

template<class TYPE>

const TYPE* RDNumeric::Vector< TYPE >::getData | ( |  | ) | const

inline

returns a const pointer to our data array

Definition at line 105 of file Vector.h.

## getVal()

template<class TYPE>

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 PRECONDITION.

Referenced by operator<<().

## largestAbsValId()

template<class TYPE>

unsigned int RDNumeric::Vector< TYPE >::largestAbsValId | ( |  | ) | const

inline

Gets the ID of the entry that has the largest absolute value i.e. the entry being used for the L-infinity norm.

Definition at line 204 of file Vector.h.

## largestValId()

template<class TYPE>

unsigned int RDNumeric::Vector< TYPE >::largestValId | ( |  | ) | const

inline

Gets the ID of the entry that has the largest value.

Definition at line 218 of file Vector.h.

## normalize()

template<class TYPE>

void RDNumeric::Vector< TYPE >::normalize | ( |  | ) |

inline

Normalize the vector using the L2 norm.

Definition at line 260 of file Vector.h.

References RDNumeric::Vector< TYPE >::normL2().

Referenced by RDNumeric::Vector< TYPE >::setToRandom().

## normL1()

template<class TYPE>

TYPE RDNumeric::Vector< TYPE >::normL1 | ( |  | ) | const

inline

L1 norm.

Definition at line 179 of file Vector.h.

## normL2()

template<class TYPE>

TYPE RDNumeric::Vector< TYPE >::normL2 | ( |  | ) | const

inline

L2 norm.

Definition at line 176 of file Vector.h.

References RDNumeric::Vector< TYPE >::normL2Sq().

Referenced by RDNumeric::Vector< TYPE >::normalize().

## normL2Sq()

template<class TYPE>

TYPE RDNumeric::Vector< TYPE >::normL2Sq | ( |  | ) | const

inline

L2 norm squared.

Definition at line 165 of file Vector.h.

Referenced by RDNumeric::Vector< TYPE >::normL2(), and RDNumeric::TanimotoSimilarity().

## normLinfinity()

template<class TYPE>

TYPE RDNumeric::Vector< TYPE >::normLinfinity | ( |  | ) | const

inline

L-infinity norm.

Definition at line 190 of file Vector.h.

## operator*=()

template<class TYPE>

Vector<TYPE>& RDNumeric::Vector< TYPE >::operator*= | ( | TYPE | scale | ) |

inline

multiplication by a scalar

Definition at line 147 of file Vector.h.

## operator+=()

template<class TYPE>

Vector<TYPE>& RDNumeric::Vector< TYPE >::operator+= | ( | const Vector< TYPE > & | other | ) |

inline

elementwise addition, vectors must be the same size.

Definition at line 123 of file Vector.h.

References RDNumeric::Vector< TYPE >::getData(), PRECONDITION, and RDNumeric::Vector< TYPE >::size().

## operator-=()

template<class TYPE>

Vector<TYPE>& RDNumeric::Vector< TYPE >::operator-= | ( | const Vector< TYPE > & | other | ) |

inline

elementwise subtraction, vectors must be the same size.

Definition at line 135 of file Vector.h.

References RDNumeric::Vector< TYPE >::getData(), PRECONDITION, and RDNumeric::Vector< TYPE >::size().

## operator/=()

template<class TYPE>

Vector<TYPE>& RDNumeric::Vector< TYPE >::operator/= | ( | TYPE | scale | ) |

inline

division by a scalar

Definition at line 156 of file Vector.h.

## operator[]() [1/2]

template<class TYPE>

TYPE RDNumeric::Vector< TYPE >::operator[] | ( | unsigned int | i | ) | const

inline

Definition at line 91 of file Vector.h.

References PRECONDITION.

## operator[]() [2/2]

template<class TYPE>

TYPE& RDNumeric::Vector< TYPE >::operator[] | ( | unsigned int | i | ) |

inline

Definition at line 96 of file Vector.h.

References PRECONDITION.

## setToRandom()

template<class TYPE>

void RDNumeric::Vector< TYPE >::setToRandom | ( | unsigned int | seed = `0` | ) |

inline

Set to a random unit vector.

Definition at line 266 of file Vector.h.

References RDNumeric::Vector< TYPE >::normalize().

## setVal()

template<class TYPE>

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 PRECONDITION.

Referenced by RDGeom::PointND::copy().

## size()

template<class TYPE>

unsigned int RDNumeric::Vector< TYPE >::size | ( |  | ) | const

inline

return the size (dimension) of the vector

Definition at line 77 of file Vector.h.

Referenced by RDNumeric::Vector< TYPE >::assign(), RDNumeric::Vector< TYPE >::dotProduct(), RDNumeric::Matrix< double >::getCol(), RDNumeric::SymmMatrix< TYPE >::getCol(), RDNumeric::Matrix< double >::getRow(), RDNumeric::SymmMatrix< TYPE >::getRow(), RDNumeric::multiply(), RDNumeric::Vector< TYPE >::operator+=(), RDNumeric::Vector< TYPE >::operator-=(), operator<<(), and RDNumeric::Vector< TYPE >::Vector().

## smallestValId()

template<class TYPE>

unsigned int RDNumeric::Vector< TYPE >::smallestValId | ( |  | ) | const

inline

Gets the ID of the entry that has the smallest value.

Definition at line 232 of file Vector.h.

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

- Vector.h