Main Page | Class Hierarchy | Class List | File List | Class Members

PLib::Vector< T > Class Template Reference

A template vector class. More...

#include <vector.h>

Inheritance diagram for PLib::Vector< T >:

PLib::BasicArray< T > PLib::CVector< T > List of all members.

Public Member Functions

int rows () const
 Vector ()
 Vector (const int r)
 Vector (const Vector< T > &v)
 Vector (const BasicArray< T > &v)
 Vector (T *ap, const int size)
 Vector (BasicList< T > &list)
Vector< T > & operator= (const Vector< T > &v)
Vector< T > & operator= (const BasicArray< T > &b)
Vector< T > & operator+= (const Vector< T > &a)
Vector< T > & operator-= (const Vector< T > &a)
operator= (const T d)
void as (int i, const Vector< T > &b)
Vector< T > get (int i, int l)
int minIndex () const
minimum () const
void qSortStd ()
void qSort (int M=7)
void sortIndex (Vector< int > &index, int M=7) const

Friends

Vector< T > operator+ (const Vector< T > &a, const Vector< T > &b)
Vector< T > operator- (const Vector< T > &a, const Vector< T > &b)
operator * (const Vector< T > &a, const Vector< T > &b)
Vector< T > operator * (const Vector< T > &v, const double d)
Vector< T > operator * (const Vector< T > &v, const Complex d)
Vector< T > operator * (const double d, const Vector< T > &v)
Vector< T > operator * (const Complex d, const Vector< T > &v)
int operator== (const Vector< T > &a, const Vector< T > &b)
int operator!= (const Vector< T > &a, const Vector< T > &b)

Detailed Description

template<class T>
class PLib::Vector< T >

A template vector class.

A simple vector class with basic linear algebraic vector operators defined.

Author:
Philippe Lavoie
Date:
4 Oct. 1996


Constructor & Destructor Documentation

template<class T>
PLib::Vector< T >::Vector  )  [inline]
 

Basic constructor.


Member Function Documentation

template<class T>
void PLib::Vector< T >::as int  i,
const Vector< T > &  b
 

copies the values of b to the vector starting from the index i.

The values of the vector b replace the values of the vector starting at the index i.

Parameters:
i the index to start copying from
b the vector to copy from
Warning:
The vector b must fit entirely into the vector when starting at i.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
Vector< T > PLib::Vector< T >::get int  i,
int  l
 

extract a vector of size l starting at index i

This extracts a vector of size l by copying the values from the vector starting at index i.

Parameters:
i the index to start copying from
l the length of the new vector
Returns:
A vector representing the range [i..i+l] from this vector
Warning:
The vector extracted must fit inside the vector starting at i.
Author:
Philippe Lavoie
Date:
24 January 1997

int PLib::Vector< T >::minIndex  )  const
 

finds the index of its minimal entry

Scans the vector to find its minimal value and returns the index of that value.

Returns:
the index of the minimal component.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
Vector< T > & PLib::Vector< T >::operator+= const Vector< T > &  a  ) 
 

the += operator

Each component of the vector is increased by the components of vector a.

Parameters:
a the vector to add to itself
Returns:
a reference to itself
Warning:
The vectors must have the same size.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
Vector< T > & PLib::Vector< T >::operator-= const Vector< T > &  a  ) 
 

the -= operator

Each component of the vector is decreased by the components of vector a.

Parameters:
a the vector to substract from itself
Returns:
a reference to itself
Warning:
The vectors must have the {same} size.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
T PLib::Vector< T >::operator= const T  d  ) 
 

assigns all the components of the vector to a value

All the components of the vector are assigned to the value d

Parameters:
d the value to assigned the vector to
Returns:
the value of d
Author:
Philippe Lavoie
Date:
24 January 1997

Reimplemented from PLib::BasicArray< T >.

template<class T>
Vector< T > & PLib::Vector< T >::operator= const BasicArray< T > &  b  ) 
 

the assignment operator with a BasicArray

Parameters:
b the BasicArray to copy
Returns:
a reference to itself
Author:
Philippe Lavoie
Date:
24 January 1997

Reimplemented from PLib::BasicArray< T >.

template<class T>
Vector< T > & PLib::Vector< T >::operator= const Vector< T > &  b  ) 
 

the assignment operator

The values of a vector are copied to this one

Parameters:
b the vector to copy
Returns:
a reference to itself
Author:
Philippe Lavoie
Date:
24 January 1997

void PLib::Vector<>::qSort int  M = 7  ) 
 

do a quick sort using an optimized algorithm

Do a quick sort of the vector using an algorithm based on the one described in "Numerical Recipes in C". You should use this method over using qSortStd since it is usually faster.

Parameters:
M regions smaller than this value are sorted using the insertion method, the default value of 7 is suitable for most cases.
Returns:
The vector is sorted in ascending order
Warning:
Some types don't have comparison operators and are not supported.
Author:
Philippe Lavoie
Date:
21 May 1997

template<class T>
void PLib::Vector< T >::qSortStd  ) 
 

do a quick sort using the standard C library sort algorithm

Performs a quick sort of the vector. The quick sort algorithm used is the one from the standard C library.

Returns:
The vector is sorted in ascending order
Warning:
Due to the use of the standard library, only certain types can be used with this function: int, float and double.
Author:
Philippe Lavoie
Date:
21 May 1997

template<class T>
int PLib::Vector< T >::rows  )  const [inline]
 

< a reference to the size of the vector

void PLib::Vector<>::sortIndex Vector< int > &  index,
int  M = 7
const
 

generates sorted index vector

A sorted index vector is generated by this routine. It is based on a routine described in "Numercial Recipes in C".

Parameters:
index The index vector
M regions smaller than this value are sorted using the insertion method, the default value of 7 is suitable for most cases.
Returns:
index holds a sorted index vector
Warning:
Some types don't have comparison operators and are not supported.
Author:
Philippe Lavoie
Date:
21 May 1997


Friends And Related Function Documentation

template<class T>
Vector<T> operator * const Vector< T > &  v,
const Complex  d
[friend]
 

multiplies the vector with a complex number

Parameters:
v the vector to multiply
d the complex value to multiply $v$ with
Returns:
a vector having d.v
Warning:
If the vector is not of complex type, then the vector will be multiplied by the real part of d.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
Vector<T> operator * const Vector< T > &  v,
const double  d
[friend]
 

multiplies a vector with a double

Multiplies all the elements of the vector v with a double d.

Parameters:
v the vector to multiply
d multiply the vector by this value
Returns:
a vector having value d.V
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
T operator * const Vector< T > &  a,
const Vector< T > &  b
[friend]
 

the multiplicative operator

Parameters:
a the first vector
b the second vector to multiply with
Returns:
a*b
Warning:
The vectors must have the same size.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
Vector<T> operator+ const Vector< T > &  a,
const Vector< T > &  b
[friend]
 

Adds two vectors.

Parameters:
a the first vector to add
b the second vector to add
Returns:
the result of $a+b$
Warning:
The vectors must have the {same} size.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
Vector<T> operator- const Vector< T > &  a,
const Vector< T > &  b
[friend]
 

Substracts two vectors.

Parameters:
a the first vector to add
b the second vector to add
Returns:
the result of a-b
Warning:
The vectors must have the same size.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
int operator== const Vector< T > &  a,
const Vector< T > &  b
[friend]
 

the equality operator

Parameters:
a the first vector to check
b the second vector to check
Returns:
1 if the vectors are equal, 0 otherwise
Author:
Philippe Lavoie
Date:
24 January 1997


The documentation for this class was generated from the following files:
Generated on Sun Dec 21 02:25:33 2003 for NURBS++ by doxygen 1.3.4