Regina Calculation Engine
|
Represents an element of a cyclotomic field. More...
#include <maths/cyclotomic.h>
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 () | |
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 Rational & | operator[] (size_t exp) const |
Returns an individual rational coefficient of the polynomial representation of this field element. More... | |
Rational & | operator[] (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... | |
Cyclotomic & | operator= (const Cyclotomic &value) |
Sets this to a copy of the given field element. More... | |
Cyclotomic & | operator= (Cyclotomic &&value) noexcept |
Moves the contents of the given field element to this field element. More... | |
Cyclotomic & | operator= (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... | |
Cyclotomic & | operator*= (const Rational &scalar) |
Multiplies this field element by the given rational. More... | |
Cyclotomic & | operator/= (const Rational &scalar) |
Divides this field element by the given rational. More... | |
Cyclotomic & | operator+= (const Cyclotomic &other) |
Adds the given field element to this. More... | |
Cyclotomic & | operator-= (const Cyclotomic &other) |
Subtracts the given field element from this. More... | |
Cyclotomic & | operator*= (const Cyclotomic &other) |
Multiplies this by the given field element. More... | |
Cyclotomic & | operator/= (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 &, const Cyclotomic &) |
Adds the two given cyclotomic field elements. More... | |
Cyclotomic | operator* (const Cyclotomic &, const Cyclotomic &) |
Multiplies the two given cyclotomic field elements. More... | |
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.
|
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.
|
inherited |
Returns a short text representation of this object.
This text should be human-readable, should fit on a single line, and should not end with a newline. Where possible, it should use plain ASCII characters.
str()
.
|
inherited |
Returns a short text representation of this object using unicode characters.
Like str(), this text should be human-readable, should fit on a single line, and should not end with a newline. In addition, it may use unicode characters to make the output more pleasant to read. This string will be encoded in UTF-8.
|
inlineinherited |
A default implementation for detailed output.
This routine simply calls T::writeTextShort() and appends a final newline.
out | the output stream to which to write. |