regina::Polynomial< T > Class Template Reference
Mathematical Support

Represents a single-variable polynomial with coefficients of type T. More...

`#include <maths/polynomial.h>`

Inheritance diagram for regina::Polynomial< T >:

## Public Member Functions

| Polynomial ()
| Creates the zero polynomial. More...
| Polynomial (size_t degree)
| Creates the polynomial `x^d` for the given degree d. More...
| Polynomial (const Polynomial< T > &value)
| Creates a new copy of the given polynomial. More...
template<typename U >
| Polynomial (const Polynomial< U > &value)
| Creates a new copy of the given polynomial. More...
template<typename iterator >
| Polynomial (iterator begin, iterator end)
| Creates a new polynomial from the given sequence of coefficients. More...
| ~Polynomial ()
| Destroys this polynomial. More...
void | init ()
| Sets this to become the zero polynomial. More...
void | init (size_t degree)
| Sets this to become the polynomial `x^d` for the given degree d. More...
template<typename iterator >
void | init (iterator begin, iterator end)
| Sets this to become the polynomial described by the given sequence of coefficients. More...
size_t | degree () const
| Returns the degree of this polynomial. More...
bool | isZero () const
| Returns whether this is the zero polynomial. More...
bool | isMonic () const
| Returns whether this polynomial is monic. More...
const T & | leading () const
| Returns the leading coefficient of this polynomial. More...
const T & | operator[] (size_t exp) const
| Returns the given coefficient of this polynomial. More...
void | set (size_t exp, const T &value)
| Changes the given coefficient of this polynomial. More...
bool | operator== (const Polynomial< T > &rhs) const
| Tests whether this and the given polynomial are equal. More...
bool | operator!= (const Polynomial< T > &rhs) const
| Tests whether this and the given polynomial are not equal. More...
Polynomial & | operator= (const Polynomial< T > &value)
| Sets this to be a copy of the given polynomial. More...
template<typename U >
Polynomial & | operator= (const Polynomial< U > &value)
| Sets this to be a copy of the given polynomial. More...
void | swap (Polynomial< T > &other)
| Swaps the contents of this and the given polynomial. More...
Polynomial & | operator*= (const T &scalar)
| Multiplies this polynomial by the given constant. More...
Polynomial & | operator/= (const T &scalar)
| Divides this polynomial by the given constant. More...
Polynomial & | operator+= (const Polynomial< T > &other)
| Adds the given polynomial to this. More...
Polynomial & | operator-= (const Polynomial< T > &other)
| Subtracts the given polynomial from this. More...
Polynomial & | operator*= (const Polynomial< T > &other)
| Multiplies this by the given polynomial. More...
Polynomial & | operator/= (const Polynomial< T > &other)
| Divides this by the given polynomial. More...
void | divisionAlg (const Polynomial< T > &divisor, Polynomial< T > &quotient, Polynomial< T > &remainder) const
| Divides this by the given divisor, and extracts both the quotient and the remainder. More...
template<typename U >
void | gcdWithCoeffs (const Polynomial< U > &other, Polynomial< T > &gcd, Polynomial< T > &u, Polynomial< T > &v) const
| Calculates the greatest common divisor of this and the given polynomial, and finds a linear combination of these polynomials that gives this gcd. More...
void | writeTextShort (std::ostream &out, bool utf8=false, const char *variable=0) const
| Writes this polynomial to the given output stream, using the given variable name instead of `x`. More...
std::string | str (const char *variable) const
| Returns this polynomial as a human-readable string, using the given variable name instead of `x`. More...
std::string | utf8 (const char *variable) const
| Returns this polynomial as a human-readable string using unicode characters, using the given variable name instead of `x`. More...
template<typename U >
Polynomial< T > & | operator= (const Polynomial< U > &value)
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...

## Detailed Description

### template<typename T>
class regina::Polynomial< T >

Represents a single-variable polynomial with coefficients of type T.

All exponents in the polynomial must be non-negative (so you can represent `2+3x` but not `1+1/x`).

The type T must represent a ring with no zero divisors. In particular, it must:

- support basic arithmetic operations;
- support assignments of the form `x = int` and tests of the form `x == int` and `x < int`;
- have a default constructor that assigns an explicit value of zero.

This means that Regina's numerical types such as Integer and Rational are supported, but native data types such as int and long are not (since they have no zero-initialising default constructor).

The underlying storage method for this class is dense (i.e., all coefficients are explicitly stored, including zero coefficients).

Python:\n In Python, the class Polynomial refers to the specific
  template class Polynomial<Rational>.

## Member Function Documentation

## detail()

std::string regina::Output< Polynomial< T > , 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.

## str()

std::string regina::Output< Polynomial< T > , supportsUtf8 >::str | ( |  | ) | const

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.

Python:\n In addition to str(), this is also used as the
  Python "stringification" function `__str__()`.

Returns
  a short text representation of this object.

## utf8()

std::string regina::Output< Polynomial< T > , supportsUtf8 >::utf8 | ( |  | ) | const

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.

Returns
  a short text representation of this object.

## writeTextLong()

void regina::ShortOutput< Polynomial< T > , supportsUtf8 >::writeTextLong | ( | std::ostream & | out | ) | const

inline inherited

A default implementation for detailed output.

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

Python:\n Not present.

Parameters

  out | the output stream to which to write.

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

- maths/polynomial.h

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