Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OSCAR::VectorNumeric< Type > Class Template Reference
[Math]

Represents a vector. More...

#include <VectorNumeric.h>

Inheritance diagram for OSCAR::VectorNumeric< Type >:

Inheritance graph
[legend]
List of all members.

Public Methods

 VectorNumeric (unsigned int sz, const Type *array=0)
 VectorNumeric (const VectorNumeric &rhs)
double GetMagnitude () const
double Norm () const
Type NormSqr () const
double GetMagnitude (unsigned int fromIndex, unsigned int toIndex) const
Type GetSum () const
Type GetAbsoluteValueSum () const
Type Max () const
unsigned int MaxIndex () const
Type Min () const
unsigned int MinIndex () const
VectorNumeric & Normalize ()
VectorNumeric Unit () const
void ToString (char *cmd)
String ToFlatString () const
VectorNumeric< Type > & operator= (const VectorNumeric< Type > &vectorToCopy)
VectorNumeric< Type > & operator= (Type rhs)
int operator== (const VectorNumeric &rhs) const
VectorNumeric< Type > operator+ (const VectorNumeric &rhs) const
VectorNumeric< Type > operator- (const VectorNumeric &rhs) const
VectorNumeric< Type > operator- () const
VectorNumeric< Type > operator * (Type rhs) const
VectorNumeric< Type > operator/ (Type rhs) const
VectorNumeric< Type > & operator *= (const Type rhs)
VectorNumeric< Type > & operator/= (const Type rhs)
VectorNumeric< Type > & operator+= (const Type rhs)
VectorNumeric< Type > & operator-= (const Type rhs)
VectorNumeric< Type > & operator+= (const VectorNumeric &rhs)
VectorNumeric< Type > & operator-= (const VectorNumeric &rhs)
VectorNumeric< Type > & SortAscending ()
VectorNumeric< Type > & SortDescending ()
Type Dot (const VectorNumeric &rhs) const
VectorNumeric< Type > Project (const VectorNumeric< Type > &that) const
void Orthog (VectorNumeric &rhs) const
void Null ()

Protected Methods

 VectorNumeric ()
bool quickSort (Type *pArr, unsigned int iSize, bool bAscending)
void quickSortRecursive (Type *pArr, int d, int h, bool bAscending)

Detailed Description

template<class Type>
class OSCAR::VectorNumeric< Type >

Author:
Chetan Kapoor
Represents a vector. This is a template class that can be used to build a vector of any numeric type (float, double, int, etc...). This class is used extensively in libraries and applications to represent vectors.


Constructor & Destructor Documentation

template<class Type>
OSCAR::VectorNumeric< Type >::VectorNumeric unsigned int    sz,
const Type *    array = 0
[explicit]
 

Constructor.

This is the constructor for an object of type VectorNumeric. Use this to construct an empty (all elements 0) vector object of size sz. Explicit keyword prevents implicit conversion from a scalar to an VectorNumeric object

Parameters:
sz The size (length) of the vector to create.
array A pointer of Type.

template<class Type>
OSCAR::VectorNumeric< Type >::VectorNumeric const VectorNumeric< Type > &    rhs
 

Copy Constructor.

This is the copy constructor for an object of type VectorNumeric. Use this to construct an VectorNumeric object from an existing VectorNumeric object.

Parameters:
rhs An VectorNumeric object that will be used to initialize this new object.

template<class Type>
OSCAR::VectorNumeric< Type >::VectorNumeric   [protected]
 

Constructor.

Constructor. This does nothing. It is only used for stack allocation purposes in derived classes


Member Function Documentation

template<class Type>
Type OSCAR::VectorNumeric< Type >::Dot const VectorNumeric< Type > &    rhs const
 

Return the dot (inner) product between VectorNumeric object and the calling object.

This method returns performs the dot product between vectors. Return value is sum over all i of this.at(i)*rhs.at(i)

Returns:
Double containing the dot product

template<class Type>
Type OSCAR::VectorNumeric< Type >::GetAbsoluteValueSum   const
 

Get the absolute value of the sum of the elements of a vector.

This method is used to get the absolute value of the sum of the elements of a vector.

Returns:
The absolute value of the sum of the elements of a vector.

template<class Type>
double OSCAR::VectorNumeric< Type >::GetMagnitude unsigned int    fromIndex,
unsigned int    toIndex
const
 

Get the magnitude (2-norm) of a vector from start index up to ending index.

This method is used to get the magnitude (2-norm) of a vector on the range [a,b). This range includes a, but not b, which allows one to call a.GetMagnitude(0,a.GetSize());

Parameters:
fromIndex The starting index.
toIndex One past the ending index.
Returns:
The magnitude of the vector.

template<class Type>
double OSCAR::VectorNumeric< Type >::GetMagnitude   const
 

Get the the magnitude (2-norm) of a vector.

This method is used to get the magnitude (2-norm) of a vector.

Returns:
The magnitude of the vector.

template<class Type>
Type OSCAR::VectorNumeric< Type >::GetSum   const
 

Get the sum of the elements of a vector.

This method is used to get the sum of the elements of a vector.

Returns:
The sum of the elements of a vector.

template<class Type>
Type OSCAR::VectorNumeric< Type >::Max   const
 

Get the maximum value of the elements of a vector.

This method is used to get the maximum value of the elements of a vector.

Returns:
The maximum value of the elements of a vector.

template<class Type>
unsigned int OSCAR::VectorNumeric< Type >::MaxIndex   const
 

Get the the index where the max value occurs.

Returns:
The index of the vector that contains the max value.

template<class Type>
Type OSCAR::VectorNumeric< Type >::Min   const
 

Get the minimum value of the elements of a vector.

This method is used to get the minimum value of the elements of a vector.

Returns:
The minimum value of the elements of a vector.

template<class Type>
unsigned int OSCAR::VectorNumeric< Type >::MinIndex   const
 

Get the the index where the min value occurs.

Returns:
The index of the vector that contains the min value.

template<class Type>
double OSCAR::VectorNumeric< Type >::Norm   const
 

Get the 2-norm (magnitude) of an vector.

This method is another name for GetMagnitude().

Returns:
The norm(magnitude) of the vector.

template<class Type>
VectorNumeric& OSCAR::VectorNumeric< Type >::Normalize  
 

Normalize an vector.

This method is used to normalize an Vector to a unit vector and return a reference to itself. If the norm of the vector is 0, this method does nothing.

Returns:
A reference to the vector.

template<class Type>
Type OSCAR::VectorNumeric< Type >::NormSqr   const
 

Get the square of the 2-norm (magnitude) of an vector.

This method returns the sum(squares of elements in vector). It is faster than Norm() and GetMagnitude(), as it does not do the sqrt() operation.

Returns:
The norm(magnitude) of the vector.

template<class Type>
void OSCAR::VectorNumeric< Type >::Null  
 

Sets this vector to the null vector Sets all elements of the vector to zero.

template<class Type>
VectorNumeric<Type> OSCAR::VectorNumeric< Type >::operator * Type    rhs const
 

Overloaded * operator.

Overloaded * operator. This operator multiplies all elements of a VectorNumeric object by a scalar quantity.

Parameters:
rhs A value of type Type.
Returns:
The resulting VectorNumeric object.

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::operator *= const Type    rhs
 

Overloaded *= operator.

Overloaded *= operator. This operator multiplies all elements of a VectorNumeric object by a scalar quantity.

Parameters:
rhs A value of type Type.
Returns:
The resulting VectorNumeric object.

template<class Type>
VectorNumeric<Type> OSCAR::VectorNumeric< Type >::operator+ const VectorNumeric< Type > &    rhs const
 

Overloaded + operator.

Overloaded + operator. This operator adds a VectorNumeric object to the calling object. An error occurs if both the VectorNumeric objects are of different sizes.

Parameters:
rhs A VectorNumeric object to be added to the calling object.
Returns:
The resulting VectorNumeric object.
Exceptions:
vectorSizeMismatch vectorSizeMismatch Call GetError() for more information

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::operator+= const VectorNumeric< Type > &    rhs
 

Overloaded += operator.

Overloaded += operator. This operator adds a VectorNumeric object to the calling object.

Parameters:
rhs A VectorNumeric object.
Returns:
The resulting VectorNumeric object.

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::operator+= const Type    rhs
 

Overloaded += operator.

Overloaded += operator. This operator adds a scalar quantity to all the elements of a VectorNumeric object.

Parameters:
rhs A value of type Type.
Returns:
The resulting VectorNumeric object.

template<class Type>
VectorNumeric<Type> OSCAR::VectorNumeric< Type >::operator-   const
 

Overloaded - operator.

Overloaded - operator. This operator returns another VectorNumeric, where return[i] = -1*object[i]

Returns:
The resulting VectorNumeric object.

template<class Type>
VectorNumeric<Type> OSCAR::VectorNumeric< Type >::operator- const VectorNumeric< Type > &    rhs const
 

Overloaded - operator.

Overloaded - operator. This operator subtracts a VectorNumeric object from the calling VectorNumeric object. An error occurs if both the VectorNumeric objects are of different sizes.

Parameters:
rhs A VectorNumeric object to be subtracted from the calling object.
Returns:
The resulting VectorNumeric object.
Exceptions:
vectorSizeMismatch vectorSizeMismatch Call GetError() for more information

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::operator-= const VectorNumeric< Type > &    rhs
 

Overloaded -= operator.

Overloaded -= operator. This operator subtracts a VectorNumeric object from the calling object.

Parameters:
rhs A VectorNumeric object.
Returns:
The resulting VectorNumeric object.

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::operator-= const Type    rhs
 

Overloaded -= operator.

Overloaded -= operator. This operator subtracts a scalar quantity from all the elements of a VectorNumeric object.

Parameters:
rhs A value of type Type.
Returns:
The resulting VectorNumeric object.

template<class Type>
VectorNumeric<Type> OSCAR::VectorNumeric< Type >::operator/ Type    rhs const
 

Overloaded / operator.

Overloaded / operator. This operator multiplies all elements of a VectorNumeric object by a scalar quantity.

Parameters:
rhs A value of type Type.
Returns:
The resulting VectorNumeric object.

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::operator/= const Type    rhs
 

Overloaded /= operator.

Overloaded /= operator. This operator divides all elements of a VectorNumeric object by a scalar quantity.

Parameters:
rhs A value of type Type.
Returns:
The resulting VectorNumeric object.

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::operator= Type    rhs
 

Overloaded = operator.

Overloaded = operator. This assigns a value of Type to entire VectorNumeric object.

Parameters:
rhs A value of type Type.
Returns:
A reference to the object on the left hand side of the = operator.

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::operator= const VectorNumeric< Type > &    vectorToCopy
 

Assignment operator.

This is the Assignment operator for an object of type VectorNumeric. This operator will resize the calling object if the vector being copied is not of the same size.

Parameters:
vectorToCopy An VectorNumeric<Type> object that goes on the right hand side of the = operator.
Returns:
A reference to the object on the left hand side of the = operator.
See also:
Array<Type>::Copy(const Array<Type>& arrayToCopy)

template<class Type>
int OSCAR::VectorNumeric< Type >::operator== const VectorNumeric< Type > &    rhs const
 

Overloaded == operator.

Overloaded == operator. This operator checks to see if two VectorNumeric objects are equal or not.

Parameters:
rhs A VectorNumeric object.
Returns:
1 if both VectorNumerics are equal. Otherwise, a 0 is returned.

template<class Type>
void OSCAR::VectorNumeric< Type >::Orthog VectorNumeric< Type > &    rhs const
 

Orthogonalizes VectorNumeric object to the calling object.

This method modifies the argument to be orthogonal the calling object, i.e. this->Dot(rhs) =0.

Returns:
None

template<class Type>
VectorNumeric<Type> OSCAR::VectorNumeric< Type >::Project const VectorNumeric< Type > &    that const
 

Projection of the argument onto the calling object.

This method returns the projection of the argument onto the calling object

Returns:
VectorNumeric<type>

template<class Type>
bool OSCAR::VectorNumeric< Type >::quickSort Type *    pArr,
unsigned int    iSize,
bool    bAscending
[protected]
 

Sort a vector using quick sort.

This method is used to sort a vector using quick sort.

Parameters:
pArr Pointer to the array that is to be sorted.
iSize Size of the array.
bAscending If bAscending is True, then sort in ascending order, otherwise sort in descending order.
Returns:
True if no error, false otherwise.

template<class Type>
void OSCAR::VectorNumeric< Type >::quickSortRecursive Type *    pArr,
int    d,
int    h,
bool    bAscending
[protected]
 

Sort a vector recursively using quick sort.

This method is used to sort a vector recursively using quick sort.

Parameters:
pArr Pointer to the array that is to be sorted.
d 
h 
bAscending If bAscending is True, then sort in ascending order, otherwise sort in descending order.
Returns:
True if no error, false otherwise.

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::SortAscending  
 

Sort a vector in ascending order.

This method is used to sort a vector in ascending order.

Returns:
A VectorNumeric containing the sorted vector.

template<class Type>
VectorNumeric<Type>& OSCAR::VectorNumeric< Type >::SortDescending  
 

Sort a vector in descending order.

This method is used to sort a vector in descending order.

Returns:
A VectorNumeric containing the sorted vector.

template<class Type>
String OSCAR::VectorNumeric< Type >::ToFlatString   const
 

Serializes the vector to a String Convert a vector to a string representation. All elements are placed in the return string with. No carriage or special characters are returns are placed between the elements.

Returns:
A string of characters that holds the vector elements. Only alphanumerics are part of this string.

template<class Type>
void OSCAR::VectorNumeric< Type >::ToString char *    cmd
 

Output the VectorNumeric.

This method is used to output the VectorNumeric.

Parameters:
cmd Output stream argument.

template<class Type>
VectorNumeric OSCAR::VectorNumeric< Type >::Unit   const
 

Return a unit vector.

This method is used to return a normalized unit Vector. If the norm of the vector is 0, this method returns a copy of the calling vector.

Returns:
A reference to the vector.


The documentation for this class was generated from the following file:
RRG Homepage OSCAR Overview OSCAR Tutorials Simulations