#include <nvector.h>
Inheritance diagram for regina::NVector< T >:
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. |
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.
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
.
virtual regina::NVector< T >::~NVector | ( | ) | [inline, virtual] |
Destroys the vector.
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.
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 >.
virtual unsigned regina::NVector< T >::size | ( | ) | const [pure virtual] |
Returns the number of elements in the vector.
Implemented in regina::NVectorDense< T >, regina::NVectorMatrixRow< T >, regina::NVectorMatrixCol< T >, regina::NVectorUnit< T >, and regina::NVectorDense< regina::NLargeInteger >.
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.
index
is between 0 and size()-1 inclusive.index | the vector index to examine. |
Implemented in regina::NVectorDense< T >, regina::NVectorMatrixRow< T >, regina::NVectorMatrixCol< T >, regina::NVectorUnit< T >, and regina::NVectorDense< regina::NLargeInteger >.
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.
index
is between 0 and size()-1 inclusive.index | the vector index to examine. | |
value | the new value to assign to the element. |
Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< regina::NLargeInteger >.
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.
compare | the vector with which this will be compared. |
true
if and only if the this and the given vector are equal. virtual void regina::NVector< T >::operator= | ( | const NVector< T > & | cloneMe | ) | [pure virtual] |
Sets this vector equal to the given vector.
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 >.
virtual void regina::NVector< T >::operator+= | ( | const NVector< T > & | other | ) | [pure virtual] |
Adds the given vector to this vector.
other | the vector to add to this vector. |
Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< regina::NLargeInteger >.
virtual void regina::NVector< T >::operator-= | ( | const NVector< T > & | other | ) | [pure virtual] |
Subtracts the given vector from this vector.
other | the vector to subtract from this vector. |
Implemented in regina::NVectorDense< T >, regina::NVectorMatrix< T >, regina::NVectorUnit< T >, and regina::NVectorDense< regina::NLargeInteger >.
virtual void regina::NVector< T >::operator *= | ( | const T & | factor | ) | [pure virtual] |
Multiplies this vector by the given scalar.
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 >.
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.
other | the vector with which this will be multiplied. |
Reimplemented in regina::NVectorUnit< 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 >.
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.
Reimplemented in regina::NVectorUnit< 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.
Reimplemented in regina::NVectorUnit< 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.
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 >.
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.
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 >.
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.
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. |
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.
out | the output stream to which to write. | |
vector | the vector to write. |