Regina Calculation Engine
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
regina::Cyclotomic Class Reference

Represents an element of a cyclotomic field. More...

#include <maths/cyclotomic.h>

Inheritance diagram for regina::Cyclotomic:
regina::ShortOutput< Cyclotomic, true > regina::Output< T, supportsUtf8 >

Public Types

typedef Rational Coefficient
 The type of each coefficient of the polynomial that is used to store a field element. More...
 

Public Member Functions

 Cyclotomic ()
 Creates an uninitialised field element. More...
 
 Cyclotomic (size_t field)
 Creates the zero element of the given cyclotomic field. More...
 
 Cyclotomic (size_t field, int value)
 Creates the given integer element within the given cyclotomic field. More...
 
 Cyclotomic (size_t field, const Rational &value)
 Creates the given rational element within the given cyclotomic field. More...
 
 Cyclotomic (const Cyclotomic &value)
 Creates a copy of the given field element, within the same cyclotomic field. More...
 
 Cyclotomic (Cyclotomic &&value) noexcept
 Moves the contents of the given field element to this new field element. More...
 
 Cyclotomic (size_t field, std::initializer_list< Rational > coefficients)
 Creates a new field element from a hard-coded sequence of coefficients. More...
 
 ~Cyclotomic ()
 Destroys this field element. More...
 
void init (size_t field)
 Initialises this to be the zero element of the given cyclotomic field. More...
 
size_t field () const
 Returns the order n of the underlying cyclotomic field to which this element belongs. More...
 
size_t degree () const
 Returns the degree of the polynomial that defines the underlying cyclotomic field. More...
 
const Rationaloperator[] (size_t exp) const
 Returns an individual rational coefficient of the polynomial representation of this field element. More...
 
Rationaloperator[] (size_t exp)
 Offers access to an individual rational coefficient of the polynomial representation of this field element. More...
 
Polynomial< Rational > * polynomial () const
 Returns the full polynomial representation of this field element. More...
 
std::complex< double > evaluate (size_t whichRoot=1) const
 Returns the value of this cyclotomic field element as a complex number. More...
 
bool operator== (const Cyclotomic &rhs) const
 Tests whether or not this and the given argument are the same element of the same cyclotomic field. More...
 
bool operator!= (const Cyclotomic &rhs) const
 Tests whether or not this and the given argument are the same element of the same cyclotomic field. More...
 
Cyclotomicoperator= (const Cyclotomic &value)
 Sets this to a copy of the given field element. More...
 
Cyclotomicoperator= (Cyclotomic &&value) noexcept
 Moves the contents of the given field element to this field element. More...
 
Cyclotomicoperator= (const Rational &scalar)
 Sets this field element to the given rational. More...
 
void negate ()
 Negates this field element. More...
 
void invert ()
 Inverts this field element. More...
 
Cyclotomic inverse () const
 Returns the inverse of this field element. More...
 
Cyclotomicoperator*= (const Rational &scalar)
 Multiplies this field element by the given rational. More...
 
Cyclotomicoperator/= (const Rational &scalar)
 Divides this field element by the given rational. More...
 
Cyclotomicoperator+= (const Cyclotomic &other)
 Adds the given field element to this. More...
 
Cyclotomicoperator-= (const Cyclotomic &other)
 Subtracts the given field element from this. More...
 
Cyclotomicoperator*= (const Cyclotomic &other)
 Multiplies this by the given field element. More...
 
Cyclotomicoperator/= (const Cyclotomic &other)
 Divides this by the given field element. More...
 
void writeTextShort (std::ostream &out, bool utf8=false, const char *variable=nullptr) const
 Writes this field element to the given output stream, using the given variable name instead of x. More...
 
std::string str (const char *variable) const
 Returns this field element as a human-readable string, using the given variable name instead of x. More...
 
std::string utf8 (const char *variable) const
 Returns this field element as a human-readable string using unicode characters, using the given variable name instead of x. 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...
 

Static Public Member Functions

static const Polynomial< Integer > & cyclotomic (size_t n)
 Returns the nth cyclotomic polynomial Φ_n. More...
 

Friends

Cyclotomic operator+ (const Cyclotomic &lhs, const Cyclotomic &rhs)
 Adds the two given cyclotomic field elements. More...
 
Cyclotomic operator- (const Cyclotomic &lhs, const Cyclotomic &rhs)
 Subtracts the two given cyclotomic field elements. More...
 
Cyclotomic operator* (const Cyclotomic &lhs, const Cyclotomic &rhs)
 Multiplies the two given cyclotomic field elements. More...
 

Detailed Description

Represents an element of a cyclotomic field.

The cyclotomic field of order n extends the rationals with a primitive nth root of unity. This is isomorphic to the polynomial field ℚ[x]/Φ_n, where Φ_n is the nth cyclotomic polynomial.

Using this isomorphism, each element of the cyclotomic field can be uniquely represented as a rational polynomial of degree strictly less than deg(Φ_n) = φ(n), where φ denotes Euler's totient function. This class stores field elements using such a polynomial representation, and does not store complex numbers directly. If you require the complex value of a field element (as a floating point approximation), you can call evaluate().

Each object of this class stores both the value of the field element and the order n of the underlying field. This means that you can freely work with elements of different fields simultaneously, though of course most operations (such as addition, multplication and so on) require all operands to belong to the same field.

This class requires that the order n is strictly positive.

This class is designed to avoid deep copies wherever possible. In particular, it supports C++11 move constructors and move assignment. Functions that take or return objects by value are designed to be just as efficient as working with references or pointers, and long chains of operators such as a = b * c + d do not make unwanted deep copies.

Although this class makes use of global data in its implementation, all of its methods are thread-safe.

Member Function Documentation

◆ writeTextLong()

void regina::ShortOutput< Cyclotomic , 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.
Parameters
outthe output stream to which to write.

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