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

Represents a finitely generated abelian group. More...

#include <algebra/abeliangroup.h>

Inheritance diagram for regina::AbelianGroup:
regina::ShortOutput< AbelianGroup, true > regina::TightEncodable< AbelianGroup > regina::Output< AbelianGroup, supportsUtf8 >

Public Member Functions

 AbelianGroup ()=default
 Creates a new trivial group. More...
 
 AbelianGroup (const AbelianGroup &)=default
 Creates a clone of the given group. More...
 
 AbelianGroup (AbelianGroup &&) noexcept=default
 Moves the contents of the given group to this new group. More...
 
 AbelianGroup (size_t rank)
 Creates a free abelian group of the given rank. More...
 
template<typename T >
 AbelianGroup (size_t rank, std::initializer_list< T > invFac)
 Creates a new group with the given rank and invariant factors. More...
 
template<typename Container >
 AbelianGroup (size_t rank, const Container &invFac)
 Creates a new group with the given rank and invariant factors. More...
 
 AbelianGroup (MatrixInt presentation)
 Creates the abelian group defined by the given presentation matrix. More...
 
 AbelianGroup (MatrixInt M, MatrixInt N)
 Creates an abelian group as the homology of a chain complex. More...
 
 AbelianGroup (MatrixInt M, MatrixInt N, const Integer &p)
 Creates an abelian group as the homology of a chain complex, using mod-p coefficients. More...
 
void addRank (long extraRank=1)
 Increments the rank of the group by the given integer. More...
 
void addTorsion (Integer degree)
 Adds the given torsion element to the group. More...
 
void addGroup (MatrixInt presentation)
 Adds the abelian group defined by the given presentation to this group. More...
 
void addGroup (const AbelianGroup &group)
 Adds the given abelian group to this group. More...
 
size_t rank () const
 Returns the rank of the group. More...
 
size_t torsionRank (const Integer &degree) const
 Returns the rank in the group of the torsion term of given degree. More...
 
size_t torsionRank (unsigned long degree) const
 Returns the rank in the group of the torsion term of given degree. More...
 
size_t countInvariantFactors () const
 Returns the number of invariant factors that describe the torsion elements of this group. More...
 
const IntegerinvariantFactor (size_t index) const
 Returns the given invariant factor describing the torsion elements of this group. More...
 
bool isTrivial () const
 Determines whether this is the trivial (zero) group. More...
 
bool isZ () const
 Determines whether this is the infinite cyclic group (Z). More...
 
bool isFree (size_t r) const
 Determines whether this is the free abelian group of the given rank. More...
 
bool isZn (size_t n) const
 Determines whether this is the non-trivial cyclic group on the given number of elements. More...
 
bool operator== (const AbelianGroup &other) const
 Determines whether this and the given abelian group have identical presentations (which means they are isomorphic). More...
 
bool operator!= (const AbelianGroup &other) const
 Determines whether this and the given abelian group have different presentations (which means they are non-isomorphic). More...
 
AbelianGroupoperator= (const AbelianGroup &)=default
 Sets this to be a clone of the given group. More...
 
AbelianGroupoperator= (AbelianGroup &&) noexcept=default
 Moves the contents of the given group to this group. More...
 
void swap (AbelianGroup &other) noexcept
 Swaps the contents of this and the given abelian group. More...
 
void tightEncode (std::ostream &out) const
 Writes the tight encoding of this abelian group to the given output stream. More...
 
void writeXMLData (std::ostream &out) const
 Writes a chunk of XML containing this abelian group. More...
 
void writeTextShort (std::ostream &out, bool utf8=false) const
 Writes a short text representation of this object to the given output stream. More...
 
void writeTextLong (std::ostream &out) const
 A default implementation for detailed output. More...
 
std::string str () const
 Returns a short text representation of this object. More...
 
std::string utf8 () const
 Returns a short text representation of this object using unicode characters. More...
 
std::string detail () const
 Returns a detailed text representation of this object. More...
 
std::string tightEncoding () const
 Returns the tight encoding of this object. More...
 

Static Public Member Functions

static AbelianGroup tightDecode (std::istream &input)
 Reconstructs an abelian group from its given tight encoding. More...
 
static AbelianGroup tightDecoding (const std::string &enc)
 Reconstructs an object of type T from its given tight encoding. More...
 

Protected Attributes

size_t rank_ { 0 }
 The rank of the group (the number of Z components). More...
 
std::vector< IntegerrevInvFactors_
 The invariant factors d0,...,dn as described in the AbelianGroup notes. More...
 

Detailed Description

Represents a finitely generated abelian group.

The torsion elements of the group are stored in terms of their invariant factors. For instance, Z_2+Z_3 will appear as Z_6, and Z_2+Z_2+Z_3 will appear as Z_2+Z_6.

In general the factors will appear as Z_d0+...+Z_dn, where the invariant factors di are all greater than 1 and satisfy d0|d1|...|dn. Note that this representation is unique.

This class implements C++ move semantics and adheres to the C++ Swappable requirement. It is designed to avoid deep copies wherever possible, even when passing or returning objects by value.

Todo:
Optimise (long-term): Look at using sparse matrices for storage of SNF and the like.

Constructor & Destructor Documentation

◆ AbelianGroup() [1/9]

regina::AbelianGroup::AbelianGroup ( )
default

Creates a new trivial group.

◆ AbelianGroup() [2/9]

regina::AbelianGroup::AbelianGroup ( const AbelianGroup )
default

Creates a clone of the given group.

◆ AbelianGroup() [3/9]

regina::AbelianGroup::AbelianGroup ( AbelianGroup &&  )
defaultnoexcept

Moves the contents of the given group to this new group.

This is a fast (constant time) operation.

The group that was passed will no longer be usable.

◆ AbelianGroup() [4/9]

regina::AbelianGroup::AbelianGroup ( size_t  rank)
inline

Creates a free abelian group of the given rank.

Parameters
rankthe rank of the new group.

◆ AbelianGroup() [5/9]

template<typename T >
regina::AbelianGroup::AbelianGroup ( size_t  rank,
std::initializer_list< T >  invFac 
)
inline

Creates a new group with the given rank and invariant factors.

Exceptions
InvalidArgumentThe invariant factors were not all greater than 1, and/or they did not satisfy the divisibily requirement (where each invariant factor must divide the one after it).
Python
Not present. Instead, use the constructor that takes the invariant factors as a Python list.
Template Parameters
Tan integer type, which may be a native C++ integer type or one of Regina's own integer types.
Parameters
rankthe rank of the new group (i.e., the number of copies of Z).
invFacthe list of invariant factors d0, d1, ..., as described in the class notes, where each invariant factor is greater than 1 and divides the invariant factor after it.

◆ AbelianGroup() [6/9]

template<typename Container >
regina::AbelianGroup::AbelianGroup ( size_t  rank,
const Container invFac 
)
inline

Creates a new group with the given rank and invariant factors.

Exceptions
InvalidArgumentThe invariant factors were not all greater than 1, and/or they did not satisfy the divisibily requirement (where each invariant factor must divide the one after it).
Template Parameters
Containera container or view that supports reverse iteration via rbegin(), rend(), that has an empty() function, and whose elements may be of a native C++ integer type or one of Regina's own integer types. A suitable example might be std::vector<int>.
Parameters
rankthe rank of the new group (i.e., the number of copies of Z).
invFacthe list of invariant factors d0, d1, ..., as described in the class notes, where each invariant factor is greater than 1 and divides the invariant factor after it.

◆ AbelianGroup() [7/9]

regina::AbelianGroup::AbelianGroup ( MatrixInt  presentation)

Creates the abelian group defined by the given presentation matrix.

Each column of the matrix represents a generator, and each row of the matrix represents a relation.

Parameters
presentationa presentation matrix for the new group.

◆ AbelianGroup() [8/9]

regina::AbelianGroup::AbelianGroup ( MatrixInt  M,
MatrixInt  N 
)

Creates an abelian group as the homology of a chain complex.

The abelian group is the kernel of M modulo the image of N.

The matrices should be thought of as acting on column vectors: this means that the product B×A applies the linear transformation A, then the linear transformation B. This is consistent (for example) with the convention that Regina uses for for multiplying permutations.

Precondition
M.columns() = N.rows(). This condition will be tested, and an exception will be thrown if it does not hold.
The product M×N = 0. This condition will not be tested (for efficiency reasons); this is left to the user/programmer to ensure.
Exceptions
InvalidArgumentThe number of columns in M does not match the number of rows in N.
Parameters
Mthe ‘right’ matrix in the chain complex; that is, the matrix that one takes the kernel of when computing homology.
Nthe ‘left’ matrix in the chain complex; that is, the matrix that one takes the image of when computing homology.

◆ AbelianGroup() [9/9]

regina::AbelianGroup::AbelianGroup ( MatrixInt  M,
MatrixInt  N,
const Integer p 
)

Creates an abelian group as the homology of a chain complex, using mod-p coefficients.

The abelian group is the kernel of M modulo the image of N.

The matrices should be thought of as acting on column vectors: this means that the product B×A applies the linear transformation A, then the linear transformation B. This is consistent (for example) with the convention that Regina uses for for multiplying permutations.

Precondition
M.columns() = N.rows(). This condition will be tested, and an exception will be thrown if it does not hold.
The product M×N = 0. This condition will not be tested (for efficiency reasons); this is left to the user/programmer to ensure.
Exceptions
InvalidArgumentThe number of columns in M does not match the number of rows in N.
Parameters
Mthe ‘right’ matrix in the chain complex; that is, the matrix that one takes the kernel of when computing homology.
Nthe ‘left’ matrix in the chain complex; that is, the matrix that one takes the image of when computing homology.
pthe modulus, which may be any Integer. Zero is interpreted as a request for integer coefficents, which will give the same result as the AbelianGroup(MatrixInt, MatrixInt) constructor.
Author
Ryan Budney

Member Function Documentation

◆ addGroup() [1/2]

void regina::AbelianGroup::addGroup ( const AbelianGroup group)

Adds the given abelian group to this group.

Parameters
groupthe group to add to this one.

◆ addGroup() [2/2]

void regina::AbelianGroup::addGroup ( MatrixInt  presentation)

Adds the abelian group defined by the given presentation to this group.

Note that this routine might be slow since calculating the new invariant factors is not trivial.

Parameters
presentationa presentation matrix for the group to be added to this group, where each column represents a generator and each row a relation.

◆ addRank()

void regina::AbelianGroup::addRank ( long  extraRank = 1)
inline

Increments the rank of the group by the given integer.

This integer may be positive, negative or zero.

Precondition
The current rank plus the given integer is non-negative. In other words, if we are subtracting rank then we are not trying to subtract more rank than the group actually has.
Parameters
extraRankthe extra rank to add; this defaults to 1.

◆ addTorsion()

void regina::AbelianGroup::addTorsion ( Integer  degree)

Adds the given torsion element to the group.

As of Regina 7.0, this routine is much faster than it used to be. In particular, if you have many torsion elements to add, it is now efficient just to call addTorsion() for each new torsion element, one at a time.

In this routine we add a single copy of Z_d, where d is the given degree.

Parameters
degreethe degree of the new torsion element; this must be strictly positive.

◆ countInvariantFactors()

size_t regina::AbelianGroup::countInvariantFactors ( ) const
inline

Returns the number of invariant factors that describe the torsion elements of this group.

See the AbelianGroup class notes for further details.

Returns
the number of invariant factors.

◆ detail()

std::string regina::Output< AbelianGroup , supportsUtf8 >::detail ( ) const
inherited

Returns a detailed text representation of this object.

This text may span many lines, and should provide the user with all the information they could want. It should be human-readable, should not contain extremely long lines (which cause problems for users reading the output in a terminal), and should end with a final newline. There are no restrictions on the underlying character set.

Returns
a detailed text representation of this object.

◆ invariantFactor()

const Integer & regina::AbelianGroup::invariantFactor ( size_t  index) const
inline

Returns the given invariant factor describing the torsion elements of this group.

See the AbelianGroup class notes for further details.

If the invariant factors are d0|d1|...|dn, this routine will return di where i is the value of parameter index.

Parameters
indexthe index of the invariant factor to return; this must be between 0 and countInvariantFactors()-1 inclusive.
Returns
the requested invariant factor.

◆ isFree()

bool regina::AbelianGroup::isFree ( size_t  r) const
inline

Determines whether this is the free abelian group of the given rank.

Parameters
rthe rank of the free abelian group that we are testing for.
Returns
true if and only if this is the free abelian group of rank r.

◆ isTrivial()

bool regina::AbelianGroup::isTrivial ( ) const
inline

Determines whether this is the trivial (zero) group.

Returns
true if and only if this is the trivial group.

◆ isZ()

bool regina::AbelianGroup::isZ ( ) const
inline

Determines whether this is the infinite cyclic group (Z).

Returns
true if and only if this is the infinite cyclic group.

◆ isZn()

bool regina::AbelianGroup::isZn ( size_t  n) const
inline

Determines whether this is the non-trivial cyclic group on the given number of elements.

As a special case, if n = 0 then this routine will test for the infinite cyclic group (i.e., it will behave the same as isZ()). If n = 1, then this routine will test for the trivial group (i.e., it will behave the same as isTrivial()).

Parameters
nthe number of elements of the cyclic group in question.
Returns
true if and only if this is the cyclic group Z_n.

◆ operator!=()

bool regina::AbelianGroup::operator!= ( const AbelianGroup other) const
inline

Determines whether this and the given abelian group have different presentations (which means they are non-isomorphic).

Since the AbelianGroup class stores only the invariants required to identify the isomorphism type, two groups will compare as equal if and only if they are isomorphic. This is in contrast to the comparisons for GroupPresentation (which tests for identical generators and relations), or for MarkedAbelianGroup (which tests for identical chain complex presentations).

Parameters
otherthe group with which this should be compared.
Returns
true if and only if the two groups have different presentations (i.e., they are non-isomorphic).

◆ operator=() [1/2]

AbelianGroup & regina::AbelianGroup::operator= ( AbelianGroup &&  )
defaultnoexcept

Moves the contents of the given group to this group.

This is a fast (constant time) operation.

The group that was passed will no longer be usable.

Returns
a reference to this group.

◆ operator=() [2/2]

AbelianGroup & regina::AbelianGroup::operator= ( const AbelianGroup )
default

Sets this to be a clone of the given group.

Returns
a reference to this group.

◆ operator==()

bool regina::AbelianGroup::operator== ( const AbelianGroup other) const
inline

Determines whether this and the given abelian group have identical presentations (which means they are isomorphic).

Since the AbelianGroup class stores only the invariants required to identify the isomorphism type, two groups will compare as equal if and only if they are isomorphic. This is in contrast to the comparisons for GroupPresentation (which tests for identical generators and relations), or for MarkedAbelianGroup (which tests for identical chain complex presentations).

Parameters
otherthe group with which this should be compared.
Returns
true if and only if the two groups have identical presentations (i.e., they are isomorphic).

◆ rank()

size_t regina::AbelianGroup::rank ( ) const
inline

Returns the rank of the group.

This is the number of included copies of Z.

Equivalently, the rank is the maximum number of linearly independent elements, and it indicates the size of the largest free abelian subgroup. The rank effectively ignores all torsion elements.

Warning
SnapPy users should be aware that SnapPy defines rank differently. Specifically, SnapPy's AbelianGroup.rank() computation includes torsion factors also.
Returns
the number of included copies of Z.

◆ str()

std::string regina::Output< AbelianGroup , supportsUtf8 >::str ( ) const
inherited

Returns a short text representation of this object.

This text should be human-readable, should use plain ASCII characters where possible, and should not contain any newlines.

Within these limits, this short text ouptut should be as information-rich as possible, since in most cases this forms the basis for the Python __str__() and __repr__() functions.

Python
The Python "stringification" function __str__() will use precisely this function, and for most classes the Python __repr__() function will incorporate this into its output.
Returns
a short text representation of this object.

◆ swap()

void regina::AbelianGroup::swap ( AbelianGroup other)
inlinenoexcept

Swaps the contents of this and the given abelian group.

Parameters
otherthe group whose contents should be swapped with this.

◆ tightDecode()

static AbelianGroup regina::AbelianGroup::tightDecode ( std::istream &  input)
static

Reconstructs an abelian group from its given tight encoding.

See the page on tight encodings for details.

The tight encoding will be read from the given input stream. If the input stream contains leading whitespace then it will be treated as an invalid encoding (i.e., this routine will throw an exception). The input routine may contain further data: if this routine is successful then the input stream will be left positioned immediately after the encoding, without skipping any trailing whitespace.

Exceptions
InvalidInputThe given input stream does not begin with a tight encoding of an abelian group.
Python
Not present. Use tightDecoding() instead, which takes a string as its argument.
Parameters
inputan input stream that begins with the tight encoding for an abelian group.
Returns
the abelian group represented by the given tight encoding.

◆ tightDecoding()

static AbelianGroup regina::TightEncodable< AbelianGroup >::tightDecoding ( const std::string &  enc)
inlinestaticinherited

Reconstructs an object of type T from its given tight encoding.

See the page on tight encodings for details.

The tight encoding should be given as a string. If this string contains leading whitespace or any trailing characters at all (including trailing whitespace), then it will be treated as an invalid encoding (i.e., this routine will throw an exception).

Exceptions
InvalidArgumentThe given string is not a tight encoding of an object of type T.
Parameters
encthe tight encoding for an object of type T.
Returns
the object represented by the given tight encoding.

◆ tightEncode()

void regina::AbelianGroup::tightEncode ( std::ostream &  out) const
inline

Writes the tight encoding of this abelian group to the given output stream.

See the page on tight encodings for details.

Python
Not present. Use tightEncoding() instead, which returns a string.
Parameters
outthe output stream to which the encoded string will be written.

◆ tightEncoding()

std::string regina::TightEncodable< AbelianGroup >::tightEncoding ( ) const
inlineinherited

Returns the tight encoding of this object.

See the page on tight encodings for details.

Exceptions
FailedPreconditionThis may be thrown for some classes T if the object is in an invalid state. If this is possible, then a more detailed explanation of "invalid" can be found in the class documentation for T, under the member function T::tightEncode(). See FacetPairing::tightEncode() for an example of this.
Returns
the resulting encoded string.

◆ torsionRank() [1/2]

size_t regina::AbelianGroup::torsionRank ( const Integer degree) const

Returns the rank in the group of the torsion term of given degree.

If the given degree is d, this routine will return the largest m for which mZ_d is a subgroup of this group.

For instance, if this group is Z_6+Z_12, the torsion term of degree 2 has rank 2 (one occurrence in Z_6 and one in Z_12), and the torsion term of degree 4 has rank 1 (one occurrence in Z_12).

Precondition
The given degree is at least 2.
Parameters
degreethe degree of the torsion term to query.
Returns
the rank in the group of the given torsion term.

◆ torsionRank() [2/2]

size_t regina::AbelianGroup::torsionRank ( unsigned long  degree) const
inline

Returns the rank in the group of the torsion term of given degree.

If the given degree is d, this routine will return the largest m for which mZ_d is a subgroup of this group.

For instance, if this group is Z_6+Z_12, the torsion term of degree 2 has rank 2 (one occurrence in Z_6 and one in Z_12), and the torsion term of degree 4 has rank 1 (one occurrence in Z_12).

Precondition
The given degree is at least 2.
Parameters
degreethe degree of the torsion term to query.
Returns
the rank in the group of the given torsion term.

◆ utf8()

std::string regina::Output< AbelianGroup , supportsUtf8 >::utf8 ( ) const
inherited

Returns a short text representation of this object using unicode characters.

Like str(), this text should be human-readable, should not contain any newlines, and (within these constraints) should be as information-rich as is reasonable.

Unlike str(), this function may use unicode characters to make the output more pleasant to read. The string that is returned will be encoded in UTF-8.

Returns
a short text representation of this object.

◆ writeTextLong()

void regina::ShortOutput< AbelianGroup , supportsUtf8 >::writeTextLong ( std::ostream &  out) const
inlineinherited

A default implementation for detailed output.

This routine simply calls T::writeTextShort() and appends a final newline.

Python
Not present. Instead you can call detail() from the subclass T, which returns this output as a string.
Parameters
outthe output stream to which to write.

◆ writeTextShort()

void regina::AbelianGroup::writeTextShort ( std::ostream &  out,
bool  utf8 = false 
) const

Writes a short text representation of this object to the given output stream.

The text representation will be of the form 3 Z + 4 Z_2 + Z_120. The torsion elements will be written in terms of the invariant factors of the group, as described in the AbelianGroup notes.

Python
Not present. Use str() or utf8() instead.
Parameters
outthe output stream to which to write.
utf8if true, then richer unicode characters will be used to make the output more pleasant to read. In particular, the output will use subscript digits and the blackboard bold Z.

◆ writeXMLData()

void regina::AbelianGroup::writeXMLData ( std::ostream &  out) const

Writes a chunk of XML containing this abelian group.

Python
The argument out should be an open Python file object.
Parameters
outthe output stream to which the XML should be written.

Member Data Documentation

◆ rank_

size_t regina::AbelianGroup::rank_ { 0 }
protected

The rank of the group (the number of Z components).

◆ revInvFactors_

std::vector<Integer> regina::AbelianGroup::revInvFactors_
protected

The invariant factors d0,...,dn as described in the AbelianGroup notes.

These are stored in reverse order, since addTorsion() always extends the vector on the d0 end. Note that we cannot use std::deque (which does support pushing to the front), since older gcc versions do not have a noexcept std::deque move constructor.


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

Copyright © 1999-2023, 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).