The vector class

## Inheritance:

### Public Methods

Vector()
Constructor with no arguments (must subsequently invoke "alloc" to allocate memory)
Vector(size_type n)
Constructor: create vector of "n" elements.
Vector(size_type n, const T &e)
Constructor: create vector of "n" elements "e".
Vector(const Vector<T> &)
Copy constructor: elements are copied into a new vector.
Vector<T> & operator=(const T f)
Assignment operator: set all elements to "f".
Vector<T> & operator+=(const T f)
Add the value "f" to every element of the vector.
Vector<T> & operator-=(const T f)
Subtract the value "f" to every element of the vector.
Vector<T> & operator*=(const T f)
Multiply every element by the value "f".
Vector<T> & operator/=(const T f)
Divide every element by the value "f".
Vector<T> & operator+=(const Vector<T> &w)
Vector<T> & operator-=(const Vector<T> &w)
Vector subtraction.
Vector<T> & operator*=(const Vector<T> &w)
Elementwise multiplication.
Vector<T> & operator/=(const Vector<T> &w)
Elementwise division.
void space(const T xmin, const T xmax)
Uniform grid generation.
void range(const T imin=0)
Uniform grid generation with unit increment.
void random(void)
Fill the vector with random numbers between 0 and 1 (two subsequent calls to random will generate different elements)
size_t bra(const T elem)
Return the index of the element closest to the left of/at position of elem.
Vector<size_t> bra(const Vector<T> &elem)
Return the indices of the elements that are closest to the left of elem.
size_t ket(const T elem)
Return the index of the element closest to the right of elem.
Vector<size_t> ket(const Vector<T> &elem)
Return the indices of the elements that are closest to the right of elem.
Vector<T> & alloc(const size_type n)
Resizes the vector to the "n" size.
inline const T& operator()(size_type i) const
Return reference to "i"-th element.
inline T& operator()(size_type i)
Returns reference to an element of index "i" (can be used for assignment).

## Documentation

The vector class

The class to represent vectors. Elements are adjacent in memory.

Vector()
Constructor with no arguments (must subsequently invoke "alloc" to allocate memory)

Vector(size_type n)
Constructor: create vector of "n" elements.

Parameters:
n - vector size

Vector(size_type n, const T &e)
Constructor: create vector of "n" elements "e".

Parameters:
n - vector size
e - value of each element

Vector(const Vector<T> &)
Copy constructor: elements are copied into a new vector.
Parameters:
vector - to be copied

Vector<T> & operator=(const T f)
Assignment operator: set all elements to "f".
Parameters:
f - scalar
Returns:
vector instance

Vector<T> & operator+=(const T f)
Add the value "f" to every element of the vector.
Parameters:
f - scalar
Returns:
vector

Vector<T> & operator-=(const T f)
Subtract the value "f" to every element of the vector.
Parameters:
f - scalar
Returns:
vector

Vector<T> & operator*=(const T f)
Multiply every element by the value "f".
Parameters:
f - scalar
Returns:
vector

Vector<T> & operator/=(const T f)
Divide every element by the value "f".
Parameters:
f - scalar
Returns:
vector

Vector<T> & operator+=(const Vector<T> &w)
Parameters:
w - vector
Returns:
vector = original vector incremented by w

Vector<T> & operator-=(const Vector<T> &w)
Vector subtraction.
Parameters:
w - vector
Returns:
vector = original vector decremented by w

Vector<T> & operator*=(const Vector<T> &w)
Elementwise multiplication. Multiply every vector element (of the vector on the left of "*=") by its counterpart in the "b" vector.
Parameters:
w - vector
Returns:
vector

Vector<T> & operator/=(const Vector<T> &w)
Elementwise division. Divide every vector element (of the vector on the left of "*=") by its counterpart in the "b" vector.
Parameters:
w - vector
Returns:
vector

void space(const T xmin, const T xmax)
Uniform grid generation. Elements are set so as to span uniformly from xmin to xmax, in increasing order.
Parameters:
- xmin minimum value
- xmax maximum value

void range(const T imin=0)
Uniform grid generation with unit increment. Similar to space except that the increment is one. For instance x.range(0) has elements 0, 1, ... (up to size x.size()-1).
space

void random(void)
Fill the vector with random numbers between 0 and 1 (two subsequent calls to random will generate different elements)

size_t bra(const T elem)
Return the index of the element closest to the left of/at position of elem. This assumes that the sequence is monotonically increasing. The min/max return values are 0 and size()-1, respectively.
Parameters:
elem - reference abscissa
ket

Vector<size_t> bra(const Vector<T> &elem)
Return the indices of the elements that are closest to the left of elem. This assumes that the sequence is monotonically increasing.
Parameters:
elem - reference abscissa

size_t ket(const T elem)
Return the index of the element closest to the right of elem. This assumes that the sequence is monotonically increasing. The min/max return values are 0 and size()-1, respectively.
Parameters:
elem - reference abscissa
bra

Vector<size_t> ket(const Vector<T> &elem)
Return the indices of the elements that are closest to the right of elem. This assumes that the sequence is monotonically increasing.
Parameters:
elem - reference abscissa

Vector<T> & alloc(const size_type n)
Resizes the vector to the "n" size.
Parameters:
n - new size

inline const T& operator()(size_type i) const
Return reference to "i"-th element.
Parameters:
i - index
Returns:
element

inline T& operator()(size_type i)
Returns reference to an element of index "i" (can be used for assignment).
Parameters:
i - index
Returns:
element

This class has no child classes.