regina::NVector< T > Class Template Reference
[Mathematical Support]

A vector 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::NRay regina::NVectorMatrixCol< T > regina::NVectorMatrixRow< T > regina::NAngleStructureVector regina::NNormalSurfaceVector regina::NNormalSurfaceVectorANStandard regina::NNormalSurfaceVectorMirrored regina::NNormalSurfaceVectorStandard regina::NNormalSurfaceVectorQuad 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.

Friends

std::ostream & operator<< (std::ostream &out, const NVector< T > &vector)
 Writes the given vector to the given output stream.

Detailed Description

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

A vector 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 efficient representations of sparse, dense and other specialty vectors. Different vector subclasses based upon the same ring T can happily interact with each other.

This class and its subclasses are written with bulky types in mind (such as arbitrary precision integers), so that a minimum of new objects need to be created and a minimum of operations are performed.

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:
other the vector a multiple of which will be added to this vector.
multiple the multiple of other to be added to this vector.

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

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

Makes a newly allocated clone of this vector.

The clone will be of the same subclass of NVector as this vector.

Returns:
a clone of this vector.

Implemented in regina::NAngleStructureVector, regina::NRay, regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, regina::NNormalSurfaceVectorANStandard, regina::NNormalSurfaceVectorQuad, regina::NNormalSurfaceVectorStandard, and regina::NVectorDense< regina::NLargeInteger >.

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:
myCoeff the coefficient of this vector in the linear combination.
you the other vector to combine with this.
yourCoeff the coefficient of you in the linear combination.

template<class T>
virtual void regina::NVector< T >::negate (  )  [pure virtual]

Negates every element of this vector.

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

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:
other the 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:
factor the scalar with which this will be multiplied.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< regina::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:
other the vector to add to this vector.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< regina::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:
other the vector to subtract from this vector.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< regina::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:
cloneMe the vector whose value shall be assigned to this vector.

Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< regina::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:
compare the 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:
index the 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< regina::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:
index the vector index to examine.
value the 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< regina::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< regina::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:
other the vector a multiple of which will be subtracted from this vector.
multiple the multiple of other to be subtracted from this vector.

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


Friends And Related Function Documentation

template<class T>
std::ostream& operator<< ( std::ostream &  out,
const NVector< T > &  vector 
) [friend]

Writes the given vector to the given output stream.

The vector will be written on a single line with elements separated by a single space. No newline will be written.

Python:
Not present.
Parameters:
out the output stream to which to write.
vector the vector to write.
Returns:
a reference to out.


The documentation for this class was generated from the following file:
Copyright © 1999-2006, 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).