My Project
|
simple structural algorithms. More...
#include "config.h"
#include "cf_assert.h"
#include "canonicalform.h"
#include "variable.h"
#include "cf_iter.h"
Go to the source code of this file.
Variables | |
STATIC_INST_VAR Variable | sv_x1 |
static Variable sv_x1, sv_x2; More... | |
STATIC_INST_VAR Variable | sv_x2 |
simple structural algorithms.
A 'structural' algorithm is an algorithm which gives structural information on polynomials in contrast to a 'mathematical' algorithm which calculates some mathematical function.
Compare these functions with the functions in cf_algorithm.cc, which are mathematical algorithms.
Header file: canonicalform.h
Definition in file cf_ops.cc.
CanonicalForm apply | ( | const CanonicalForm & | f, |
void(*)(CanonicalForm &, int &) | mf | ||
) |
CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) )
apply() - apply mf to terms of f.
Calls mf( f[i], i ) for each term f[i]*x^i of f and builds a new term from the result. If f is in a coefficient domain, mf( f, i ) should result in an i == 0, since otherwise it is not clear which variable to use for the resulting term.
An example:
Then apply( f, diff ) is differentiation of f with respect to the main variable of f.
Definition at line 402 of file cf_ops.cc.
int * degrees | ( | const CanonicalForm & | f, |
int * | degs | ||
) |
int * degrees ( const CanonicalForm & f, int * degs )
degress() - return the degrees of all polynomial variables in f.
Returns 0 if f is in a coefficient domain, the degrees of f in all its polynomial variables in an array of int otherwise:
degrees( f, 0 )[i] = degree( f, Variable(i) )
If degs is not the zero pointer the degrees are stored in this array. In this case degs should be larger than the level of f. If degs is the zero pointer, an array of sufficient size is allocated automatically.
Definition at line 493 of file cf_ops.cc.
|
static |
static void degreesRec ( const CanonicalForm & f, int * degs )
degreesRec() - recursively get degrees of f.
Used by degrees().
Definition at line 463 of file cf_ops.cc.
|
static |
static void fillVarsRec ( const CanonicalForm & f, int * vars )
fillVarsRec - fill array describing occurences of variables in f.
Only polynomial variables are looked up. The information is stored in the arrary vars. vars should be large enough to hold all information, i.e. larger than the level of f.
Used by getVars() and getNumVars().
Definition at line 296 of file cf_ops.cc.
int getNumVars | ( | const CanonicalForm & | f | ) |
int getNumVars ( const CanonicalForm & f )
getNumVars() - get number of polynomial variables in f.
Definition at line 314 of file cf_ops.cc.
CanonicalForm getVars | ( | const CanonicalForm & | f | ) |
CanonicalForm getVars ( const CanonicalForm & f )
getVars() - get polynomial variables of f.
Return the product of all of them, 1 if there are not any.
Definition at line 350 of file cf_ops.cc.
bool hasFirstAlgVar | ( | const CanonicalForm & | f, |
Variable & | a | ||
) |
check if poly f contains an algebraic variable a
Definition at line 679 of file cf_ops.cc.
CanonicalForm leftShift | ( | const CanonicalForm & | F, |
int | n | ||
) |
left shift the main variable of F by n
Definition at line 697 of file cf_ops.cc.
CanonicalForm mapdomain | ( | const CanonicalForm & | f, |
CanonicalForm(*)(const CanonicalForm &) | mf | ||
) |
CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) )
mapdomain() - map all coefficients of f through mf.
Recursively descends down through f to the coefficients which are in a coefficient domain mapping each such coefficient through mf and returns the result.
Definition at line 440 of file cf_ops.cc.
CanonicalForm reduce | ( | const CanonicalForm & | f, |
const CanonicalForm & | M | ||
) |
polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of f are reduced modulo M
Definition at line 660 of file cf_ops.cc.
CanonicalForm replacevar | ( | const CanonicalForm & | f, |
const Variable & | x1, | ||
const Variable & | x2 | ||
) |
CanonicalForm replacevar ( const CanonicalForm & f, const Variable & x1, const Variable & x2 )
replacevar() - replace all occurences of x1 in f by x2.
In contrast to swapvar(), x1 may be an algebraic variable, but x2 must be a polynomial variable.
Definition at line 271 of file cf_ops.cc.
|
static |
replacevar_between() - replace occurences of sv_x1 in f with sv_x2.
This is allmost the same as swapvar_between() except that sv_x1 may be an algebraic variable, so we have to test on 'f.inBaseDomain()' instead of 'f.inCoeffDomain()' in the beginning.
Used by: replacevar()
Definition at line 233 of file cf_ops.cc.
int size | ( | const CanonicalForm & | f | ) |
int size ( const CanonicalForm & f )
size() - return number of monomials in f which are in an coefficient domain.
Returns one if f is in an coefficient domain.
Definition at line 627 of file cf_ops.cc.
int size | ( | const CanonicalForm & | f, |
const Variable & | v | ||
) |
int size ( const CanonicalForm & f, const Variable & v )
size() - count number of monomials of f with level higher or equal than level of v.
Returns one if f is in an base domain.
Definition at line 600 of file cf_ops.cc.
int size_maxexp | ( | const CanonicalForm & | f, |
int & | maxexp | ||
) |
CanonicalForm swapvar | ( | const CanonicalForm & | f, |
const Variable & | x1, | ||
const Variable & | x2 | ||
) |
swapvar() - swap variables x1 and x2 in f.
Returns the image of f under the map which maps x1 to x2 and x2 to x1. This is done quite efficiently because it is used really often. x1 and x2 should be polynomial variables.
Definition at line 168 of file cf_ops.cc.
|
static |
static void swapvar_between ( const CanonicalForm & f, CanonicalForm & result, const CanonicalForm & term, int expx2 )
swapvar_between() - replace occurences of sv_x1 in f with sv_x2.
If Psi denotes the map which maps sv_x1 to sv_x2, this function returns
result + Psi(f) * term * sv_x1^expx2
Used by: swapvar()
Definition at line 58 of file cf_ops.cc.
|
static |
swapvar_between() - swap occurences of sv_x1 and sv_x2 in f.
If Psi denotes the map which swaps sv_x1 and sv_x2, this function returns
result + Psi(f) * term
Used by: swapvar()
Definition at line 113 of file cf_ops.cc.
int totaldegree | ( | const CanonicalForm & | f | ) |
int totaldegree ( const CanonicalForm & f )
totaldegree() - return the total degree of f.
If f is zero, return -1. If f is in a coefficient domain, return 0. Otherwise return the total degree of f in all polynomial variables.
Definition at line 523 of file cf_ops.cc.
int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 )
totaldegree() - return the total degree of f as a polynomial in the polynomial variables between v1 and v2 (inclusively).
If f is zero, return -1. If f is in a coefficient domain, return 0. Also, return 0 if v1 > v2. Otherwise, take f to be a polynomial in the polynomial variables between v1 and v2 and return its total degree.
Definition at line 554 of file cf_ops.cc.
STATIC_INST_VAR Variable sv_x1 |
static Variable sv_x1, sv_x2;
sv_x1, sv_x2 - variables to swap by swapvar() and replacevar.
These variables are initialized by swapvar() such that sv_x1 < sv_x2. They are used by swapvar_between() and swapvar_rec() to swap variables efficiently. Furthermore, sv_x1 and sv_x2 are used by replacevar() and replacevar_between().
STATIC_INST_VAR Variable sv_x2 |