CLN implements univariate polynomials (polynomials in one variable) over an
arbitrary ring. The indeterminate variable may be either unnamed (and will be
printed according to cl_default_print_flags.univpoly_varname, which
defaults to `x') or carry a given name. The base ring and the
indeterminate are explicitly part of every polynomial. CLN doesn't allow you to
(accidentally) mix elements of different polynomial rings, e.g.
(a^2+1) * (b^3-1) will result in a runtime error. (Ideally this should
return a multivariate polynomial, but they are not yet implemented in CLN.)
The classes of univariate polynomial rings are
Ring
cl_ring
<cl_ring.h>
|
|
Univariate polynomial ring
cl_univpoly_ring
<cl_univpoly.h>
|
+----------------+-------------------+
| | |
Complex polynomial ring | Modular integer polynomial ring
cl_univpoly_complex_ring | cl_univpoly_modint_ring
<cl_univpoly_complex.h> | <cl_univpoly_modint.h>
|
+----------------+
| |
Real polynomial ring |
cl_univpoly_real_ring |
<cl_univpoly_real.h> |
|
+----------------+
| |
Rational polynomial ring |
cl_univpoly_rational_ring |
<cl_univpoly_rational.h> |
|
+----------------+
|
Integer polynomial ring
cl_univpoly_integer_ring
<cl_univpoly_integer.h>
and the corresponding classes of univariate polynomials are
Univariate polynomial
cl_UP
<cl_univpoly.h>
|
+----------------+-------------------+
| | |
Complex polynomial | Modular integer polynomial
cl_UP_N | cl_UP_MI
<cl_univpoly_complex.h> | <cl_univpoly_modint.h>
|
+----------------+
| |
Real polynomial |
cl_UP_R |
<cl_univpoly_real.h> |
|
+----------------+
| |
Rational polynomial |
cl_UP_RA |
<cl_univpoly_rational.h> |
|
+----------------+
|
Integer polynomial
cl_UP_I
<cl_univpoly_integer.h>
Univariate polynomial rings are constructed using the functions
cl_univpoly_ring cl_find_univpoly_ring (const cl_ring& R)
cl_univpoly_ring cl_find_univpoly_ring (const cl_ring& R, const cl_symbol& varname)
R may be an arbitrary ring. This function takes care of finding out
about special cases of R, such as the rings of complex numbers,
real numbers, rational numbers, integers, or modular integer rings.
There is a cache table of rings, indexed by R and varname.
This ensures that two calls of this function with the same arguments will
return the same polynomial ring.
cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring& R)
cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring& R, const cl_symbol& varname)
cl_univpoly_real_ring cl_find_univpoly_ring (const cl_real_ring& R)
cl_univpoly_real_ring cl_find_univpoly_ring (const cl_real_ring& R, const cl_symbol& varname)
cl_univpoly_rational_ring cl_find_univpoly_ring (const cl_rational_ring& R)
cl_univpoly_rational_ring cl_find_univpoly_ring (const cl_rational_ring& R, const cl_symbol& varname)
cl_univpoly_integer_ring cl_find_univpoly_ring (const cl_integer_ring& R)
cl_univpoly_integer_ring cl_find_univpoly_ring (const cl_integer_ring& R, const cl_symbol& varname)
cl_univpoly_modint_ring cl_find_univpoly_ring (const cl_modint_ring& R)
cl_univpoly_modint_ring cl_find_univpoly_ring (const cl_modint_ring& R, const cl_symbol& varname)
cl_find_univpoly_ring,
only the return type is more specific, according to the base ring's type.
Given a univariate polynomial ring R, the following members can be used.
cl_ring R->basering
cl_UP R->zero()
0 in R, a polynomial of degree -1.
cl_UP R->one()
1 in R, a polynomial of degree <= 0.
cl_UP R->canonhom (const cl_I& x)
x in R, a polynomial of degree <= 0.
cl_UP R->monomial (const cl_ring_element& x, uintL e)
x * X^e, where X is the
indeterminate.
cl_UP R->create (sintL degree)
-1. After creating the polynomial, you should put in the coefficients,
using the set_coeff member function, and then call the finalize
member function.
The following are the only destructive operations on univariate polynomials.
void set_coeff (cl_UP& x, uintL index, const cl_ring_element& y)
X^index in x to be y.
After changing a polynomial and before applying any "normal" operation on it,
you should call its finalize member function.
void finalize (cl_UP& x)
The following operations are defined on univariate polynomials.
cl_univpoly_ring x.ring ()
x belongs.
cl_UP operator+ (const cl_UP&, const cl_UP&)
cl_UP operator- (const cl_UP&, const cl_UP&)
cl_UP operator- (const cl_UP&)
cl_UP operator* (const cl_UP&, const cl_UP&)
cl_UP square (const cl_UP&)
cl_UP expt_pos (const cl_UP& x, const cl_I& y)
y must be > 0. Returns x^y.
bool operator== (const cl_UP&, const cl_UP&)
bool operator!= (const cl_UP&, const cl_UP&)
cl_boolean zerop (const cl_UP& x)
x is 0 in R.
sintL degree (const cl_UP& x)
-1.
cl_ring_element coeff (const cl_UP& x, uintL index)
X^index in the polynomial x.
cl_ring_element x (const cl_ring_element& y)
x is a polynomial and y belongs to the base ring,
then `x(y)' returns the value of the substitution of y into
x.
cl_UP deriv (const cl_UP& x)
x with respect to the
indeterminate X.
The following output functions are defined (see also the chapter on input/output).
void fprint (cl_ostream stream, const cl_UP& x)
cl_ostream operator<< (cl_ostream stream, const cl_UP& x)
x on the stream. The output may
depend on the global printer settings in the variable
cl_default_print_flags.
The following functions return special polynomials.
cl_UP_I cl_tschebychev (sintL n)
cl_UP_I cl_hermite (sintL n)
cl_UP_RA cl_legendre (sintL n)
cl_UP_I cl_laguerre (sintL n)
Information how to derive the differential equation satisfied by each
of these polynomials from their definition can be found in the
doc/polynomial/ directory.
Go to the first, previous, next, last section, table of contents.