Regina Calculation Engine
Public Member Functions | Static Public Attributes
regina::NVector< T > Class Template Reference

A slow but flexible vector class of elements from a given ring T. More...

#include <nvector.h>

Inheritance diagram for regina::NVector< T >:
regina::NVectorDense< T > regina::NVectorMatrix< T > regina::NVectorUnit< T > regina::NVectorMatrixCol< T > regina::NVectorMatrixRow< T >

List of all members.

Public Member Functions

virtual ~NVector ()
 Destroys the vector.
virtual NVector< T > * clone () const =0
 Makes a newly allocated clone of this vector.
virtual unsigned size () const =0
 Returns the number of elements in the vector.
virtual const T & operator[] (unsigned index) const =0
 Returns the element at the given index in the vector.
virtual void setElement (unsigned index, const T &value)=0
 Sets the element at the given index in the vector to the given value.
virtual bool operator== (const NVector< T > &compare) const
 Determines if this vector is equal to the given vector.
virtual void operator= (const NVector< T > &cloneMe)=0
 Sets this vector equal to the given vector.
virtual void operator+= (const NVector< T > &other)=0
 Adds the given vector to this vector.
virtual void operator-= (const NVector< T > &other)=0
 Subtracts the given vector from this vector.
virtual void operator*= (const T &factor)=0
 Multiplies this vector by the given scalar.
virtual T operator* (const NVector< T > &other) const
 Calculates the dot product of this vector and the given vector.
virtual void negate ()=0
 Negates every element of this vector.
virtual T norm () const
 Returns the norm of this vector.
virtual T elementSum () const
 Returns the sum of all elements of this vector.
virtual void addCopies (const NVector< T > &other, const T &multiple)=0
 Adds the given multiple of the given vector to this vector.
virtual void subtractCopies (const NVector< T > &other, const T &multiple)=0
 Subtracts the given multiple of the given vector to this vector.
NVector< T > * makeLinComb (const T &myCoeff, const NVector< T > &you, const T &yourCoeff) const
 Returns a newly created vector that is a linear combination of this vector and another given vector.

Static Public Attributes

static T zero
 Zero in the underlying number system.
static T one
 One in the underlying number system.
static T minusOne
 Negative one in the underlying number system.

Detailed Description

template<class T>
class regina::NVector< T >

A slow but flexible vector class of elements from a given ring T.

Various mathematical vector operations are available.

This is a virtual base class for a variety of concrete implementations, allowing for memory-efficient representations of sparse, dense and other specialty vectors. Different vector subclasses based upon the same ring T can happily interact with each other.

The side-effect of this flexibility is that this vector class is slow (in particular, many functions are virtual). For a fast vector class better suited to heavy computation, see NFastVector instead.

This class and its subclasses are written with bulky types in mind (such as arbitrary precision integers), so creations and operations are kept to a minimum.

Precondition:
Type T has a copy constructor. That is, if a and b are of type T, then a can be initialised to the value of b using a(b).
Type T has a default constructor. That is, an object of type T can be declared with no arguments. No specific default value is required.
Type T allows for operators =, ==, +=, -= and *=.
Type T has a long integer constructor. That is, if a is of type T, then a can be initialised to a long integer l using a(l).
An element t of type T can be written to an output stream out using the standard expression out << t.
Python:
Not present.

Constructor & Destructor Documentation

template<class T>
virtual regina::NVector< T >::~NVector ( ) [inline, virtual]

Destroys the vector.


Member Function Documentation

template<class T>
virtual void regina::NVector< T >::addCopies ( const NVector< T > &  other,
const T &  multiple 
) [pure virtual]

Adds the given multiple of the given vector to this vector.

Precondition:
This and the given vector have the same size.
Parameters:
otherthe vector a multiple of which will be added to this vector.
multiplethe multiple of other to be added to this vector.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< NLargeInteger >.

template<class T>
virtual NVector<T>* regina::NVector< T >::clone ( ) const [pure virtual]
template<class T>
virtual T regina::NVector< T >::elementSum ( ) const [inline, virtual]

Returns the sum of all elements of this vector.

The default implementation simply runs through the elements adding each one in turn.

Returns:
the sum of the elements of this vector.

Reimplemented in regina::NVectorUnit< T >.

template<class T>
NVector<T>* regina::NVector< T >::makeLinComb ( const T &  myCoeff,
const NVector< T > &  you,
const T &  yourCoeff 
) const [inline]

Returns a newly created vector that is a linear combination of this vector and another given vector.

The vector returned will be myCoeff * this + yourCoeff * you.

The new vector will initially be created by cloning this vector, which will thus determine its specific NVector subclass.

Parameters:
myCoeffthe coefficient of this vector in the linear combination.
youthe other vector to combine with this.
yourCoeffthe coefficient of you in the linear combination.
template<class T>
virtual void regina::NVector< T >::negate ( ) [pure virtual]
template<class T>
virtual T regina::NVector< T >::norm ( ) const [inline, virtual]

Returns the norm of this vector.

This is the dot product of the vector with itself. The default implementation simply runs through the elements squaring each one in turn.

Returns:
the norm of this vector.

Reimplemented in regina::NVectorUnit< T >.

template<class T>
virtual T regina::NVector< T >::operator* ( const NVector< T > &  other) const [inline, virtual]

Calculates the dot product of this vector and the given vector.

The default implementation simply runs through the two vectors multiplying elements in pairs.

Precondition:
This and the given vector have the same size.
Parameters:
otherthe vector with which this will be multiplied.
Returns:
the dot product of this and the given vector.

Reimplemented in regina::NVectorUnit< T >.

template<class T>
virtual void regina::NVector< T >::operator*= ( const T &  factor) [pure virtual]

Multiplies this vector by the given scalar.

Parameters:
factorthe scalar with which this will be multiplied.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< NLargeInteger >.

template<class T>
virtual void regina::NVector< T >::operator+= ( const NVector< T > &  other) [pure virtual]

Adds the given vector to this vector.

Precondition:
This and the given vector have the same size.
Parameters:
otherthe vector to add to this vector.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< NLargeInteger >.

template<class T>
virtual void regina::NVector< T >::operator-= ( const NVector< T > &  other) [pure virtual]

Subtracts the given vector from this vector.

Precondition:
This and the given vector have the same size.
Parameters:
otherthe vector to subtract from this vector.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< NLargeInteger >.

template<class T>
virtual void regina::NVector< T >::operator= ( const NVector< T > &  cloneMe) [pure virtual]

Sets this vector equal to the given vector.

Precondition:
This and the given vector have the same size.
Parameters:
cloneMethe vector whose value shall be assigned to this vector.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< NLargeInteger >.

template<class T>
virtual bool regina::NVector< T >::operator== ( const NVector< T > &  compare) const [inline, virtual]

Determines if this vector is equal to the given vector.

The default implementation simply compares elements one at a time.

Precondition:
This and the given vector have the same size.
Parameters:
comparethe vector with which this will be compared.
Returns:
true if and only if the this and the given vector are equal.
template<class T>
virtual const T& regina::NVector< T >::operator[] ( unsigned  index) const [pure virtual]

Returns the element at the given index in the vector.

A constant reference to the element is returned; the element may not be altered.

Precondition:
index is between 0 and size()-1 inclusive.
Parameters:
indexthe vector index to examine.
Returns:
the vector element at the given index.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrixRow< T >, regina::NVectorMatrixCol< T >, regina::NVectorUnit< T >, and regina::NVectorDense< NLargeInteger >.

template<class T>
virtual void regina::NVector< T >::setElement ( unsigned  index,
const T &  value 
) [pure virtual]

Sets the element at the given index in the vector to the given value.

Precondition:
index is between 0 and size()-1 inclusive.
Parameters:
indexthe vector index to examine.
valuethe new value to assign to the element.
Returns:
the vector element at the given index.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< NLargeInteger >.

template<class T>
virtual unsigned regina::NVector< T >::size ( ) const [pure virtual]

Returns the number of elements in the vector.

Returns:
the vector size.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrixRow< T >, regina::NVectorMatrixCol< T >, regina::NVectorUnit< T >, and regina::NVectorDense< NLargeInteger >.

template<class T>
virtual void regina::NVector< T >::subtractCopies ( const NVector< T > &  other,
const T &  multiple 
) [pure virtual]

Subtracts the given multiple of the given vector to this vector.

Precondition:
This and the given vector have the same size.
Parameters:
otherthe vector a multiple of which will be subtracted from this vector.
multiplethe multiple of other to be subtracted from this vector.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< NLargeInteger >.


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

Copyright © 1999-2009, Ben Burton
This software is released under the GNU General Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).