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

A dense vector of objects of type T. More...

#include <nvectordense.h>

Inheritance diagram for regina::NVectorDense< T >:

regina::NVector< T >

List of all members.

Public Member Functions

 NVectorDense (unsigned newVectorSize)
 Creates a new vector.
 NVectorDense (unsigned newVectorSize, const T &initValue)
 Creates a new vector and initialises every element to the given value.
 NVectorDense (const NVector< T > &cloneMe)
 Creates a new vector that is a clone of the given vector.
 NVectorDense (const NVectorDense< T > &cloneMe)
 Creates a new vector that is a clone of the given vector.
virtual ~NVectorDense ()
 Destroys this vector.
virtual NVector< T > * clone () const
 Makes a newly allocated clone of this vector.
virtual unsigned size () const
 Returns the number of elements in the vector.
virtual const T & operator[] (unsigned index) const
 Returns the element at the given index in the vector.
virtual void setElement (unsigned index, const T &value)
 Sets the element at the given index in the vector to the given value.
virtual void operator= (const NVector< T > &cloneMe)
 Sets this vector equal to the given vector.
virtual void operator+= (const NVector< T > &other)
 Adds the given vector to this vector.
virtual void operator-= (const NVector< T > &other)
 Subtracts the given vector from this vector.
virtual void operator*= (const T &factor)
 Multiplies this vector by the given scalar.
virtual void negate ()
 Negates every element of this vector.
virtual void addCopies (const NVector< T > &other, const T &multiple)
 Adds the given multiple of the given vector to this vector.
virtual void subtractCopies (const NVector< T > &other, const T &multiple)
 Subtracts the given multiple of the given vector to this vector.

Protected Attributes

T * elements
 The internal array containing all vector elements.
unsigned vectorSize
 The size of the vector, possibly including zero elements.


Detailed Description

template<class T>
class regina::NVectorDense< T >

A dense vector of objects of type T.

The vector is represented as a simple array on the heap.

This vector class is flexible but slow; for a fast but inflexible vector class that is better suited for heavy computation, see NFastVector instead.

Precondition:
See the preconditions for NVector<T>.
Python:
Not present.

Constructor & Destructor Documentation

template<class T>
regina::NVectorDense< T >::NVectorDense ( unsigned  newVectorSize  )  [inline]

Creates a new vector.

Its elements will not be initialised.

Parameters:
newVectorSize the number of elements in the new vector; this must be strictly positive.

template<class T>
regina::NVectorDense< T >::NVectorDense ( unsigned  newVectorSize,
const T &  initValue 
) [inline]

Creates a new vector and initialises every element to the given value.

Parameters:
newVectorSize the number of elements in the new vector; this must be strictly positive.
initValue the value to assign to every element of the vector.

template<class T>
regina::NVectorDense< T >::NVectorDense ( const NVector< T > &  cloneMe  )  [inline]

Creates a new vector that is a clone of the given vector.

Parameters:
cloneMe the vector to clone.

template<class T>
regina::NVectorDense< T >::NVectorDense ( const NVectorDense< T > &  cloneMe  )  [inline]

Creates a new vector that is a clone of the given vector.

Parameters:
cloneMe the vector to clone.

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

Destroys this vector.


Member Function Documentation

template<class T>
virtual void regina::NVectorDense< T >::addCopies ( const NVector< T > &  other,
const T &  multiple 
) [inline, 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.

Implements regina::NVector< T >.

template<class T>
virtual NVector<T>* regina::NVectorDense< T >::clone (  )  const [inline, 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.

Implements regina::NVector< T >.

Reimplemented in regina::NAngleStructureVector, regina::NRay, regina::NNormalSurfaceVectorANStandard, regina::NNormalSurfaceVectorQuad, regina::NNormalSurfaceVectorQuadOct, and regina::NNormalSurfaceVectorStandard.

template<class T>
virtual void regina::NVectorDense< T >::negate (  )  [inline, virtual]

Negates every element of this vector.

Implements regina::NVector< T >.

Reimplemented in regina::NRay.

template<class T>
virtual void regina::NVectorDense< T >::operator*= ( const T &  factor  )  [inline, virtual]

Multiplies this vector by the given scalar.

Parameters:
factor the scalar with which this will be multiplied.

Implements regina::NVector< T >.

template<class T>
virtual void regina::NVectorDense< T >::operator+= ( const NVector< T > &  other  )  [inline, 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.

Implements regina::NVector< T >.

template<class T>
virtual void regina::NVectorDense< T >::operator-= ( const NVector< T > &  other  )  [inline, 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.

Implements regina::NVector< T >.

template<class T>
virtual void regina::NVectorDense< T >::operator= ( const NVector< T > &  cloneMe  )  [inline, 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.

Implements regina::NVector< T >.

template<class T>
virtual const T& regina::NVectorDense< T >::operator[] ( unsigned  index  )  const [inline, 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.

Implements regina::NVector< T >.

template<class T>
virtual void regina::NVectorDense< T >::setElement ( unsigned  index,
const T &  value 
) [inline, 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.

Implements regina::NVector< T >.

template<class T>
virtual unsigned regina::NVectorDense< T >::size (  )  const [inline, virtual]

Returns the number of elements in the vector.

Returns:
the vector size.

Implements regina::NVector< T >.

template<class T>
virtual void regina::NVectorDense< T >::subtractCopies ( const NVector< T > &  other,
const T &  multiple 
) [inline, 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.

Implements regina::NVector< T >.


Member Data Documentation

template<class T>
T* regina::NVectorDense< T >::elements [protected]

The internal array containing all vector elements.

template<class T>
unsigned regina::NVectorDense< T >::vectorSize [protected]

The size of the vector, possibly including zero elements.


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).