Regina Calculation Engine
Public Types | Public Member Functions | Friends | List of all members
regina::Laurent2< T > Class Template Reference

Represents a Laurent polynomial in the two variables x, y with coefficients of type T. More...

#include <maths/laurent2.h>

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

Public Types

typedef T Coefficient
 The type of each coefficient of the polynomial. More...
 

Public Member Functions

 Laurent2 ()=default
 Creates the zero polynomial. More...
 
 Laurent2 (long xExp, long yExp)
 Creates the polynomial x^d y^e for the given exponents d and e. More...
 
 Laurent2 (const Laurent2< T > &value)
 Creates a new copy of the given polynomial. More...
 
 Laurent2 (Laurent2< T > &&value) noexcept=default
 Moves the contents of the given polynomial to this new polynomial. More...
 
 Laurent2 (const Laurent2< T > &toShift, long xShift, long yShift)
 Creates a copy of the given polynomial with all terms multiplied by x^d y^e for some integers d and e. More...
 
template<typename U >
 Laurent2 (const Laurent2< U > &value)
 Creates a new copy of the given polynomial. More...
 
 Laurent2 (std::initializer_list< std::tuple< long, long, T >> coefficients)
 Creates a new polynomial from a hard-coded collection of non-zero coefficients. More...
 
void init ()
 Sets this to become the zero polynomial. More...
 
void init (long xExp, long yExp)
 Sets this to become the polynomial x^d y^e for the given exponents d and e. More...
 
bool isZero () const
 Returns whether this is the zero polynomial. More...
 
const T & operator() (long xExp, long yExp) const
 Returns the given coefficient of this polynomial. More...
 
void set (long xExp, long yExp, const T &value)
 Changes the given coefficient of this polynomial. More...
 
bool operator== (const Laurent2< T > &rhs) const
 Tests whether this and the given polynomial are equal. More...
 
bool operator!= (const Laurent2< T > &rhs) const
 Tests whether this and the given polynomial are not equal. More...
 
Laurent2operator= (const Laurent2< T > &value)
 Sets this to be a copy of the given polynomial. More...
 
template<typename U >
Laurent2operator= (const Laurent2< U > &value)
 Sets this to be a copy of the given polynomial. More...
 
Laurent2operator= (Laurent2< T > &&value) noexcept=default
 Moves the contents of the given polynomial to this polynomial. More...
 
void swap (Laurent2< T > &other)
 Swaps the contents of this and the given polynomial. More...
 
void negate ()
 Negates this polynomial. More...
 
Laurent2operator*= (const T &scalar)
 Multiplies this polynomial by the given constant. More...
 
Laurent2operator/= (const T &scalar)
 Divides this polynomial by the given constant. More...
 
Laurent2operator+= (const Laurent2< T > &other)
 Adds the given polynomial to this. More...
 
Laurent2operator-= (const Laurent2< T > &other)
 Subtracts the given polynomial from this. More...
 
Laurent2operator*= (const Laurent2< T > &other)
 Multiplies this by the given polynomial. More...
 
void writeTextShort (std::ostream &out, bool utf8=false, const char *varX=nullptr, const char *varY=nullptr) const
 Writes this polynomial to the given output stream, using the given variable names instead of x and y. More...
 
std::string str (const char *varX, const char *varY=nullptr) const
 Returns this polynomial as a human-readable string, using the given variable names instead of x and y. More...
 
std::string utf8 (const char *varX, const char *varY=nullptr) const
 Returns this polynomial as a human-readable string using unicode characters, using the given variable names instead of x and y. More...
 
template<typename U >
Laurent2< T > & operator= (const Laurent2< U > &other)
 
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...
 

Friends

class Link
 
template<typename U >
Laurent2< U > operator* (const Laurent2< U > &, const Laurent2< U > &)
 

Detailed Description

template<typename T>
class regina::Laurent2< T >

Represents a Laurent polynomial in the two variables x, y with coefficients of type T.

A Laurent polynomial differs from an ordinary polynomial in that it allows negative exponents (so, for example, you can represent a polynomial such as 2 + 3x^2 + y/x - 1/y^3).

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

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

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.

The underlying storage method for this class is sparse: only the non-zero coefficients are stored.

See also the class Laurent, which describes Laurent polynomials in just one variable.

Python
In Python, the class Laurent2 refers to the specific template class Laurent2<Integer>.

Member Function Documentation

◆ writeTextLong()

void regina::ShortOutput< Laurent2< T > , 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 files:

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