Regina Calculation Engine
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
regina::Ray Class Reference


A fast class for storing a ray rooted at the origin that passes through an integer point. More...

#include <maths/ray.h>

Inheritance diagram for regina::Ray:
regina::Vector< LargeInteger > regina::AngleStructureVector

Public Member Functions

 Ray (size_t length)
 Creates a new ray all of whose coordinates are initialised to zero. More...
 
 Ray (const Vector< LargeInteger > &cloneMe)
 Creates a new ray that is a clone of the given ray. More...
 
void scaleDown ()
 Scales this vector down by the greatest common divisor of all its elements. More...
 
void negate ()
 Negates every element of this vector. More...
 
size_t size () const
 Returns the number of elements in the vector. More...
 
const LargeIntegeroperator[] (size_t index) const
 Returns the element at the given index in the vector. More...
 
void setElement (size_t index, const LargeInteger &value)
 Sets the element at the given index in the vector to the given value. More...
 
bool operator== (const Vector< LargeInteger > &compare) const
 Determines if this vector is equal to the given vector. More...
 
void operator+= (const Vector< LargeInteger > &other)
 Adds the given vector to this vector. More...
 
void operator-= (const Vector< LargeInteger > &other)
 Subtracts the given vector from this vector. More...
 
void operator*= (const LargeInteger &factor)
 Multiplies this vector by the given scalar. More...
 
LargeInteger operator* (const Vector< LargeInteger > &other) const
 Calculates the dot product of this vector and the given vector. More...
 
LargeInteger norm () const
 Returns the norm of this vector. More...
 
LargeInteger elementSum () const
 Returns the sum of all elements of this vector. More...
 
void addCopies (const Vector< LargeInteger > &other, const LargeInteger &multiple)
 Adds the given multiple of the given vector to this vector. More...
 
void subtractCopies (const Vector< LargeInteger > &other, const LargeInteger &multiple)
 Subtracts the given multiple of the given vector to this vector. More...
 

Static Public Attributes

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

Protected Attributes

LargeIntegerelements
 The internal array containing all vector elements. More...
 
LargeIntegerend
 A pointer just beyond the end of the internal array. More...
 

Detailed Description


A fast class for storing a ray rooted at the origin that passes through an integer point.

Such a ray is a half-line beginning at the origin, and is represented by some integer point that it passes through. Positive scalar multiples of a ray are considered to represent the same ray.

This class is intended for serious computation, and as a result it has a streamlined implementation with no virtual methods. It can be subclassed, but since there are no virtual methods, type information must generally be known at compile time. Nevertheless, in many respects, different subclasses of Ray can happily interact with one another.

Warning
As of Regina 4.90, this class merges the old functionality of NFastRay and NRay from Regina 4.6. Since functions are no longer virtual, the old clone() method and intersect() function are gone completely. Instead you can just use the copy constructor and standard linear operators respectively.
Python
Not present.

Constructor & Destructor Documentation

◆ Ray() [1/2]

regina::Ray::Ray ( size_t  length)
inline

Creates a new ray all of whose coordinates are initialised to zero.

Parameters
lengththe number of elements in the new vector.

◆ Ray() [2/2]

regina::Ray::Ray ( const Vector< LargeInteger > &  cloneMe)
inline

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

Parameters
cloneMethe ray to clone.

Member Function Documentation

◆ addCopies()

void regina::Vector< LargeInteger >::addCopies ( const Vector< LargeInteger > &  other,
const LargeInteger multiple 
)
inlineinherited

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

This behaves correctly in the case where other is this.

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.

◆ elementSum()

LargeInteger regina::Vector< LargeInteger >::elementSum ( ) const
inlineinherited

Returns the sum of all elements of this vector.

Returns
the sum of the elements of this vector.

◆ negate()

void regina::Ray::negate ( )
inline

Negates every element of this vector.

This is an optimised implementation that overrides Vector<LargeInteger>::negate().

◆ norm()

LargeInteger regina::Vector< LargeInteger >::norm ( ) const
inlineinherited

Returns the norm of this vector.

This is the dot product of the vector with itself.

Returns
the norm of this vector.

◆ operator*()

LargeInteger regina::Vector< LargeInteger >::operator* ( const Vector< LargeInteger > &  other) const
inlineinherited

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

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.

◆ operator*=()

void regina::Vector< LargeInteger >::operator*= ( const LargeInteger factor)
inlineinherited

Multiplies this vector by the given scalar.

Parameters
factorthe scalar with which this will be multiplied.

◆ operator+=()

void regina::Vector< LargeInteger >::operator+= ( const Vector< LargeInteger > &  other)
inlineinherited

Adds the given vector to this vector.

This behaves correctly in the case where other is this.

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

◆ operator-=()

void regina::Vector< LargeInteger >::operator-= ( const Vector< LargeInteger > &  other)
inlineinherited

Subtracts the given vector from this vector.

This behaves correctly in the case where other is this.

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

◆ operator==()

bool regina::Vector< LargeInteger >::operator== ( const Vector< LargeInteger > &  compare) const
inlineinherited

Determines if this vector is equal to the given vector.

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.

◆ operator[]()

const LargeInteger & regina::Vector< LargeInteger >::operator[] ( size_t  index) const
inlineinherited

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.

◆ scaleDown()

void regina::Ray::scaleDown ( )

Scales this vector down by the greatest common divisor of all its elements.

The resulting vector will be the smallest multiple of the original that maintains integral entries, and these entries will have the same signs as the originals.

This routine thus reduces a ray to its smallest possible representation.

This routine poses no problem for vectors containing infinite elements; such elements are simply ignored and left at infinity.

◆ setElement()

void regina::Vector< LargeInteger >::setElement ( size_t  index,
const LargeInteger value 
)
inlineinherited

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.

◆ size()

size_t regina::Vector< LargeInteger >::size ( ) const
inlineinherited

Returns the number of elements in the vector.

Returns
the vector size.

◆ subtractCopies()

void regina::Vector< LargeInteger >::subtractCopies ( const Vector< LargeInteger > &  other,
const LargeInteger multiple 
)
inlineinherited

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

This behaves correctly in the case where other is this.

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.

Member Data Documentation

◆ elements

LargeInteger * regina::Vector< LargeInteger >::elements
protectedinherited

The internal array containing all vector elements.

◆ end

LargeInteger * regina::Vector< LargeInteger >::end
protectedinherited

A pointer just beyond the end of the internal array.

The size of the vector can be computed as (end - elements).

◆ minusOne

LargeInteger regina::Vector< LargeInteger >::minusOne
staticinherited

Negative one in the underlying number system.

This would be const if it weren't for the fact that some compilers don't like this. It should never be modified!

◆ one

LargeInteger regina::Vector< LargeInteger >::one
staticinherited

One in the underlying number system.

This would be const if it weren't for the fact that some compilers don't like this. It should never be modified!

◆ zero

LargeInteger regina::Vector< LargeInteger >::zero
staticinherited

Zero in the underlying number system.

This would be const if it weren't for the fact that some compilers don't like this. It should never be modified!


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

Copyright © 1999-2021, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).