62 result += term *
power( sv_x1, expx2 ) *
f;
67 result +=
power( sv_x2,
i.exp() ) * term *
power( sv_x1, expx2 ) *
i.coeff();
86 result +=
power( sv_x2,
i.exp() ) *
i.coeff();
94 result += swapvar_between1(
i.coeff() ) *
power( f.
mvar(),
i.exp() );
143 result += swapvar_between1(
i.coeff() ) *
power( sv_x1,
i.exp() );
147 return swapvar_between1( f );
152 result += swapvar_rec1(
i.coeff() ) *
power( f.
mvar(),
i.exp() );
170 ASSERT( x1.
level() > 0 && x2.
level() > 0,
"cannot swap algebraic Variables" );
178 sv_x1 = x2; sv_x2 = x1;
182 sv_x1 = x1; sv_x2 = x2;
197 ASSERT( x1.
level() > 0 && x2.
level() > 0,
"cannot swap algebraic variables" );
204 sv_x1 = x2; sv_x2 = x1;
208 sv_x1 = x1; sv_x2 = x2;
212 return swapvar_between1( f );
215 return swapvar_rec1( f );
243 else if ( x == sv_x1 )
249 result +=
power( sv_x2,
i.exp() ) *
i.coeff();
299 if ( (n = f.
level()) > 0 )
319 else if ( (n = f.
level()) == 1 )
323 int * vars =
new int[ n+1 ];
325 for ( i = 0; i <
n; i++ ) vars[i] = 0;
333 for ( i = 1; i <
n; i++ )
334 if ( vars[i] != 0 ) m++;
355 else if ( (n = f.
level()) == 1 )
359 int * vars =
new int[ n+1 ];
361 for ( i = 0; i <=
n; i++ ) vars[i] = 0;
369 for ( i = n; i > 0; i-- )
370 if ( vars[i] != 0 ) result *=
Variable( i );
409 ASSERT( exp == 0,
"illegal result, do not know what variable to use" );
424 result +=
power( x, exp ) * coeff;
471 if ( degs[level] < deg )
506 degs =
new int[level+1];
562 else if ( f.
mvar() < v1 )
564 else if ( f.
mvar() == v1 )
566 else if ( f.
mvar() > v2 )
685 ASSERT (n >= 0,
"cannot left shift by negative number");
693 result +=
i.coeff()*
power (x,
i.exp()*
n);
CanonicalForm getVars(const CanonicalForm &f)
CanonicalForm getVars ( const CanonicalForm & f )
CanonicalForm reduce(const CanonicalForm &f, const CanonicalForm &M)
polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of...
factory's class for variables
const CanonicalForm CFMap CFMap int &both_non_zero int n
CanonicalForm replacevar(const CanonicalForm &f, const Variable &x1, const Variable &x2)
CanonicalForm replacevar ( const CanonicalForm & f, const Variable & x1, const Variable & x2 ) ...
int * degrees(const CanonicalForm &f, int *degs)
int * degrees ( const CanonicalForm & f, int * degs )
bool hasFirstAlgVar(const CanonicalForm &f, Variable &a)
check if poly f contains an algebraic variable a
CanonicalForm apply(const CanonicalForm &f, void(*mf)(CanonicalForm &, int &))
CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) ) ...
int totaldegree(const CanonicalForm &f)
int totaldegree ( const CanonicalForm & f )
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
static CanonicalForm replacevar_between(const CanonicalForm &f)
replacevar_between() - replace occurences of sv_x1 in f with sv_x2.
Iterators for CanonicalForm's.
static void degreesRec(const CanonicalForm &f, int *degs)
static void degreesRec ( const CanonicalForm & f, int * degs )
int getNumVars(const CanonicalForm &f)
int getNumVars ( const CanonicalForm & f )
static void swapvar_between(const CanonicalForm &f, CanonicalForm &result, const CanonicalForm &term, int expx2)
static void swapvar_between ( const CanonicalForm & f, CanonicalForm & result, const CanonicalForm & ...
CanonicalForm swapvar(const CanonicalForm &f, const Variable &x1, const Variable &x2)
swapvar() - swap variables x1 and x2 in f.
class to iterate through CanonicalForm's
const Variable & v
< [in] a sqrfree bivariate poly
CanonicalForm mapdomain(const CanonicalForm &f, CanonicalForm(*mf)(const CanonicalForm &))
CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) ) ...
static void swapvar_rec(const CanonicalForm &f, CanonicalForm &result, const CanonicalForm &term)
swapvar_between() - swap occurences of sv_x1 and sv_x2 in f.
CF_NO_INLINE int exp() const
get the current exponent
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
static Variable sv_x1
static Variable sv_x1, sv_x2;
static void fillVarsRec(const CanonicalForm &f, int *vars)
static void fillVarsRec ( const CanonicalForm & f, int * vars )
#define ASSERT(expression, message)
CanonicalForm leftShift(const CanonicalForm &F, int n)
left shift the main variable of F by n