#include <ngrouppresentation.h>
Public Member Functions | |
NGroupExpression () | |
The terms that make up this expression. | |
NGroupExpression (const NGroupExpression &cloneMe) | |
Creates a new expression that is a clone of the given expression. | |
std::list< NGroupExpressionTerm > & | getTerms () |
Returns the list of terms in this expression. | |
const std::list < NGroupExpressionTerm > & | getTerms () const |
Returns a constant reference to the list of terms in this expression. | |
unsigned long | getNumberOfTerms () const |
Returns the number of terms in this expression. | |
NGroupExpressionTerm & | getTerm (unsigned long index) |
Returns the term at the given index in this expression. | |
const NGroupExpressionTerm & | getTerm (unsigned long index) const |
Returns a constant reference to the term at the given index in this expression. | |
unsigned long | getGenerator (unsigned long index) const |
Returns the generator corresonding to the term at the given index in this expression. | |
long | getExponent (unsigned long index) const |
Returns the exponent corresonding to the term at the given index in this expression. | |
void | addTermFirst (const NGroupExpressionTerm &term) |
Adds the given term to the beginning of this expression. | |
void | addTermFirst (unsigned long generator, long exponent) |
Adds the given term to the beginning of this expression. | |
void | addTermLast (const NGroupExpressionTerm &term) |
Adds the given term to the end of this expression. | |
void | addTermLast (unsigned long generator, long exponent) |
Adds the given term to the end of this expression. | |
NGroupExpression * | inverse () const |
Returns a newly created expression that is the inverse of this expression. | |
NGroupExpression * | power (long exponent) const |
Returns a newly created expression that is this expression raised to the given power. | |
bool | simplify (bool cyclic=false) |
Simplifies this expression. | |
bool | substitute (unsigned long generator, const NGroupExpression &expansion, bool cyclic=false) |
Replaces every occurrence of the given generator with the given substite expression. | |
void | writeXMLData (std::ostream &out) const |
Writes a chunk of XML containing this expression. | |
void | writeToFile (NFile &out) const |
Writes this expression to the given old-style binary file. | |
virtual void | writeTextShort (std::ostream &out) const |
The text representation will be of the form g2^4 g13^-5 g4 . | |
Static Public Member Functions | |
static NGroupExpression * | readFromFile (NFile &in) |
Reads an expression from the given old-style binary file. |
An expression is represented as a sequence of powers of generators all of which are multiplied in order. Each power of a generator corresponds to an individual NGroupExpressionTerm.
For instance, the expression g1^2 g3^-1 g6
contains the three terms g1^2
, g3^-1
and g6^1
in that order.
regina::NGroupExpression::NGroupExpression | ( | ) | [inline] |
The terms that make up this expression.
Creates a new expression with no terms.
regina::NGroupExpression::NGroupExpression | ( | const NGroupExpression & | cloneMe | ) | [inline] |
Creates a new expression that is a clone of the given expression.
cloneMe | the expression to clone. |
std::list< NGroupExpressionTerm > & regina::NGroupExpression::getTerms | ( | ) | [inline] |
Returns the list of terms in this expression.
These are the actual terms stored internally; any modifications made to this list will show up in the expression itself.
const std::list< NGroupExpressionTerm > & regina::NGroupExpression::getTerms | ( | ) | const [inline] |
Returns a constant reference to the list of terms in this expression.
unsigned long regina::NGroupExpression::getNumberOfTerms | ( | ) | const [inline] |
Returns the number of terms in this expression.
NGroupExpressionTerm& regina::NGroupExpression::getTerm | ( | unsigned long | index | ) |
Returns the term at the given index in this expression.
Index 0 represents the first term, index 1 represents the second term and so on.
index | the index of the term to return; this must be between 0 and getNumberOfTerms()-1 inclusive. |
const NGroupExpressionTerm& regina::NGroupExpression::getTerm | ( | unsigned long | index | ) | const |
Returns a constant reference to the term at the given index in this expression.
Index 0 represents the first term, index 1 represents the second term and so on.
index | the index of the term to return; this must be between 0 and getNumberOfTerms()-1 inclusive. |
unsigned long regina::NGroupExpression::getGenerator | ( | unsigned long | index | ) | const [inline] |
Returns the generator corresonding to the term at the given index in this expression.
Index 0 represents the first term, index 1 represents the second term and so on.
index | the index of the term to return; this must be between 0 and getNumberOfTerms()-1 inclusive. |
long regina::NGroupExpression::getExponent | ( | unsigned long | index | ) | const [inline] |
Returns the exponent corresonding to the term at the given index in this expression.
Index 0 represents the first term, index 1 represents the second term and so on.
index | the index of the term to return; this must be between 0 and getNumberOfTerms()-1 inclusive. |
void regina::NGroupExpression::addTermFirst | ( | const NGroupExpressionTerm & | term | ) | [inline] |
Adds the given term to the beginning of this expression.
term | the term to add. |
void regina::NGroupExpression::addTermFirst | ( | unsigned long | generator, | |
long | exponent | |||
) | [inline] |
Adds the given term to the beginning of this expression.
generator | the number of the generator corresponding to the new term. | |
exponent | the exponent to which the given generator is raised. |
void regina::NGroupExpression::addTermLast | ( | const NGroupExpressionTerm & | term | ) | [inline] |
Adds the given term to the end of this expression.
term | the term to add. |
void regina::NGroupExpression::addTermLast | ( | unsigned long | generator, | |
long | exponent | |||
) | [inline] |
Adds the given term to the end of this expression.
generator | the number of the generator corresponding to the new term. | |
exponent | the exponent to which the given generator is raised. |
NGroupExpression* regina::NGroupExpression::inverse | ( | ) | const |
Returns a newly created expression that is the inverse of this expression.
The terms will be reversed and the exponents negated.
NGroupExpression* regina::NGroupExpression::power | ( | long | exponent | ) | const |
Returns a newly created expression that is this expression raised to the given power.
Note that the given exponent may be positive, zero or negative.
exponent | the power to which this expression should be raised. |
bool regina::NGroupExpression::simplify | ( | bool | cyclic = false |
) |
Simplifies this expression.
Adjacent powers of the same generator will be combined, and terms with an exponent of zero will be removed. Note that it is not assumed that the underlying group is abelian.
You may declare that the expression is cyclic, in which case it is assumed that terms may be moved from the back to the front and vice versa. Thus expression g1 g2 g1 g2 g1
simplifies to g1^2 g2 g1 g2
if it is cyclic, but does not simplify at all if it is not cyclic.
cyclic | true if and only if the expression may be assumed to be cyclic. |
true
if and only if this expression was changed. bool regina::NGroupExpression::substitute | ( | unsigned long | generator, | |
const NGroupExpression & | expansion, | |||
bool | cyclic = false | |||
) |
Replaces every occurrence of the given generator with the given substite expression.
If the given generator was found, the expression will be simplified once the substitution is complete.
generator | the generator to be replaced. | |
expansion | the substitute expression that will replace every occurrence of the given generator. | |
cyclic | true if and only if the expression may be assumed to be cyclic; see simplify() for further details. |
true
if and only if any substitutions were made. void regina::NGroupExpression::writeXMLData | ( | std::ostream & | out | ) | const |
Writes a chunk of XML containing this expression.
out | the output stream to which the XML should be written. |
void regina::NGroupExpression::writeToFile | ( | NFile & | out | ) | const |
Writes this expression to the given old-style binary file.
out | the file to which to write. |
static NGroupExpression* regina::NGroupExpression::readFromFile | ( | NFile & | in | ) | [static] |
Reads an expression from the given old-style binary file.
The expression will be newly allocated, and responsibility for its destruction lies with the caller of this routine.
in | the file from which to read. |
virtual void regina::NGroupExpression::writeTextShort | ( | std::ostream & | out | ) | const [virtual] |