1 #ifndef realroot_MPOLDSE_MONOMIAL_C
2 #define realroot_MPOLDSE_MONOMIAL_C
10 #ifndef MMX_WITH_PLUS_SIGN
11 #define MMX_WITH_PLUS_SIGN
17 #endif //MMX_WITH_PLUS_SIGN
21 template <
class C >
inline
24 int *szs =
new int, *vrs=
new int;
27 env =
eenv(1, szs, vrs);
31 template <
class C >
inline
37 template <
class C >
inline
43 template <
class C >
inline
46 int *szs =
new int, *vrs=
new int;
49 env =
eenv(1, szs, vrs);
54 template <
class C >
inline
58 int *szs =
new int, *vrs=
new int;
61 env =
eenv(1, szs, vrs);
66 template <
class C >
inline
69 env =
eenv(nvr, szs, vrs);
72 template <
class C >
inline
74 {
int szs = 1;
new (
this)
monomials (1, &szs); data[0] = x; }
86 template <
class C >
inline
88 template <
class C >
inline
91 if (mpl.
env != nenv) {
108 unsigned *oadd =
new unsigned[esz ()];
110 for (
int i = 0; i < esz (); i++)
111 if (data[i] != mpl[oadd[i]])
121 std::ostream & operator<< (std::ostream & o, const monomials < C > &mpl)
123 o <<
"monomials object:\n";
124 o <<
"\t(addresses) o: " << &mpl <<
" e: " << mpl.env.data <<
"d: " << mpl.
125 begin () << std::endl;
126 o <<
"\t(eenv)" << mpl.env << std::endl;
130 o <<
":object monomials\n";
133 template <
class Result,
class Coeff,
class Parameters >
inline
140 template <
class Result,
class Coeff,
class Parameters >
inline
147 template <
class Result,
class Coeff,
class Parameters >
inline
153 template <
class Result,
class Coeff,
class Parameters >
inline
156 subs0m( result, monoms.
begin (), monoms.
env, parameters );
162 if ( mpl.
env != nenv )
164 unsigned *oadd =
new unsigned[mpl.
esz ()];
174 template <
class X,
class Y >
178 unsigned *oadd =
new unsigned[mplb.
esz ()];
184 template <
class X,
class C >
inline void
189 template <
class C >
inline void
194 template <
class C >
void
199 template <
class C >
inline
206 template <
class C >
inline
209 if ( &r == &a ) {
add(r,b);
return; };
210 if ( &r == &b ) {
add(r,a);
return; };
219 template <
class C >
inline
222 if ( &r == &a ) {
sub(r,b);
return; };
233 template <
class C >
inline void
237 template <
class X,
class Y >
241 unsigned *oadd =
new unsigned[mplb.
esz ()];
247 template <
class X,
class Y >
inline
254 template <
class X,
class C >
inline void
259 template <
class C ,
class X>
inline
282 template <
class X,
class Y,
class Z >
inline
288 template <
class C >
inline
294 template <
class C >
inline void
299 template <
class C >
inline void
304 template<
class OSTREAM,
class C> OSTREAM&
308 exponent_t tmp (mpl.
env.
mxvr()+1);
309 const int *szs = mpl.
szs ();
310 const int *vrs = mpl.
vrs ();
311 bool notfirst =
false;
312 for (
int i = 0; i < mpl.
size(); i++)
316 for (a = i, v = mpl.
nvr () - 1; a; a /= szs[v], v--)
317 tmp[vrs[v]] = a % szs[v];
318 std::ostringstream sm;
319 print(sm, monom_t (mpl[i], tmp),
Var);
321 if ( sm.str()[0]!=
'-' && sm.str()[0]!=
'+' && notfirst) {
324 os<<sm.str().c_str();
327 if(!notfirst) os <<
"0";
331 template<
class SYNTAX,
class C>
void
335 exponent_t tmp (mpl.
env.
mxvr()+1);
336 const int *szs = mpl.
szs ();
337 const int *vrs = mpl.
vrs ();
338 for (
int i = 0; i < mpl.
size(); i++)
342 for (a = i, v = mpl.
nvr () - 1; a; a /= szs[v], v--)
343 tmp[vrs[v]] = a % szs[v];
346 for(
int i=0;i<mpl.
env.
mxvr()+1;i++)
353 template<
class Coeff>
inline int
356 for(
int i=0;i<p.
nbvar();i++) d+= *(p.
env.
szs()+i)-1;
360 template<
class Coeff>
inline int
362 return p.
env.
sz(v)-1;
366 template<
class Coeff>
inline int
371 template<
class Coeff>
inline void
379 template <
class X,
class O>
391 template <
class C,
class O>
398 template <
class C,
class O>
void
400 typedef typename sparse::monomial_seq< C, O>::monom_t monom_t;
401 typedef typename monom_t::container_t container_t;
403 container_t tmp (mpl.
env.
mxvr()+1);
404 const int *szs = mpl.
szs ();
405 const int *vrs = mpl.
vrs ();
406 for (
int i = 0; i < mpl.
size(); i++)
410 for (a = i, v = mpl.
nvr () - 1; a; a /= szs[v], v--)
411 tmp[vrs[v]] = a % szs[v];
412 add(pol, monom_t (mpl[i], tmp));
429 const int * eszs = e.
szs();
430 const int * evrs = e.
vrs();
431 const int envr = e.
nvr();
435 for (
int v = 0; v < envr; v ++ )
if ( v != lv ) { szs[
c] = eszs[v]; vrs[c++] = evrs[v]; };
436 return eenv(c,szs,vrs);
439 template<
class C>
inline
445 template<
class C>
inline
452 template<
class C>
inline
463 template<
class C>
inline
469 template<
class C>
inline
478 template<
class C>
inline
486 for (i = 0; i < nvr() ; ++i)
488 std::cout<<
"entry:" <<deg[i] << std::endl;
489 if (deg[i] >= sszs[ vvrs[i] ] || deg[i]<0 )
return C(0);
490 pos += deg[i]*sstr[ vvrs[i] ];
499 std::vector<int> ind = std::vector<int>( f.
nvr() );
502 int * vars = f.
vrs();
503 int * sstr = f.
str();
504 int * sszs = f.
szs() ;
508 for ( s = sszs[v], j = 0; j <= s-2; j++ )
509 for( k = s-2; k >= j; k-- )
510 f.
data[sstr[v]*k+ pos ] +=
511 t*f.
data[ sstr[v]*(1+k)+ pos ];
514 for (i = 0; i < f.
nvr() ; ++i)
522 if (ind[i] < sszs[i])
525 pos -= sszs[i]*sstr[i];
536 std::vector<int> ind = std::vector<int>( f.
nvr() );
539 int * vars = f.
vrs();
540 int * sstr = f.
str();
541 int * sszs = f.
szs() ;
547 for( k = sszs[v]-1; k !=-1; --k )
550 tmp += f.
data[sstr[v]*k + pos];
551 f.
data[sstr[v]*k + pos] = 0 ;
556 for (i = 0; i < f.
nvr() ; ++i)
564 if (ind[i] < sszs[i])
567 pos -= sszs[i]*sstr[i];
579 std::vector<int> ind = std::vector<int>( f.
nvr() );
582 int * vars = f.
vrs();
583 int * sstr = f.
str();
584 int * sszs = f.
szs();
589 for ( s = 0 ; s <= l/2; s++ )
593 for (i = 0; i < f.
nvr() ; ++i)
601 if (ind[i] < sszs[i])
604 pos -= sszs[i]*sstr[i];
615 std::vector<int> ind = std::vector<int>( f.
nvr() );
618 int * vars = f.
vrs();
619 int * sstr = f.
str();
620 int * sszs = f.
szs();
624 for ( s = 0 ; s < sszs[v]; ++s )
625 f.
data[sstr[v]*s+pos] *=
pow(t,s) ;
628 for (i = 0; i < f.
nvr() ; ++i)
636 if (ind[i] < sszs[i])
639 pos -= sszs[i]*sstr[i];
650 int * sszs = f.
szs() ;
651 int * sstr = f.
str() ;
653 for ( p = 0, k = 0; k < sszs[v]; k++, p += sstr[v] )
656 for ( i = 0; i < f.
size(); i += sstr[v-1] )
657 for ( j = i; j < i + sstr[v]; j ++ )
658 if ( f.
data[j+p] < mm[k] ) mm[k] = f.
data[j+p];
667 int * sszs = f.
szs() ;
668 int * sstr = f.
str() ;
670 for ( p = 0, k = 0; k < sszs[v]; k++, p += sstr[v] )
673 for ( i = 0; i < f.
size(); i += sstr[v-1] )
674 for ( j = i; j < i + sstr[v]; j ++ )
675 if ( f.
data[j+p] > mm[k] ) mm[k] = f.
data[j+p];
685 for (
int i=0; i< f.
nvr(); ++i)
int * str()
Definition: tensor_monomials.hpp:77
void print_flatten(SYNTAX &out, const monomials< C > &mpl, const variables &Var=monom< C >::var)
Definition: tensor_monomials_fcts.hpp:332
void ipsub(A *a, unsigned *aadd, unsigned nadd, const B *b)
Definition: tensor_vctops.hpp:170
void hevalm(R &result, const C *data, const eenv &env, const P &p)
Definition: tensor_eenv_loops.hpp:45
static bool oaddress(const eenv &oenv, unsigned *osupp, const eenv &ienv, unsigned *isupp=0, unsigned nsp=0)
addresses translation from environment i to environment o
Definition: tensor_eenv_fcts.hpp:295
void scdiv(A *a, const B &b, unsigned n, int s=1)
Definition: tensor_vctops.hpp:116
T pow(const T &a, int i)
Definition: binomials.hpp:12
void fill(C *a, unsigned n, int s, const C &x)
Definition: tensor_vctops.hpp:152
const C & b
Definition: Interval_glue.hpp:25
void waddm(monomials< X > &mpla, const monomials< Y > &mplb)
Definition: tensor_monomials_fcts.hpp:175
TMPL X
Definition: polynomial_operators.hpp:148
void add(bernstein< C > &mpl, const C &c)
Definition: tensor_bernstein_fcts.hpp:53
void swap(monomials< C > &a)
Definition: tensor_monomials.hpp:88
int * szs()
Definition: tensor_eenv_fcts.hpp:12
void subs0(Result *result, const bernstein< Coeff > &controls, const Parameters ¶meters)
Definition: tensor_bernstein_fcts.hpp:216
static bool equal(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:74
void clear(monomials< C > &monoms)
Definition: tensor_monomials_fcts.hpp:87
MP swap(const MP &P, int var_i, int var_j)
Definition: sparse_monomials.hpp:988
bool with_plus_sign(const ZZ &c)
Definition: GMP.hpp:62
void mul(bernstein< C > &r, const bernstein< C > &a, const bernstein< C > &b)
Definition: tensor_bernstein_fcts.hpp:142
int leading_variable(const monomials< Coeff > &p)
Definition: tensor_monomials_fcts.hpp:367
void ipadd(A *a, unsigned *aadd, unsigned nadd, const B *b)
Definition: tensor_vctops.hpp:164
static bool subset(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:344
int size() const
Definition: tensor_monomials.hpp:72
static eenv common(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:211
int * vrs()
Definition: tensor_eenv_fcts.hpp:18
void slice(C *dst, const eenv &a, const C *src, int v, int n)
Definition: tensor_eenv_loops.hpp:525
Definition: tensor_eenv.hpp:9
int localv(int i) const
Definition: tensor_eenv.hpp:61
int degree(const bernstein< C > &p)
Definition: tensor_bernstein.hpp:73
int * vrs()
Definition: tensor_monomials.hpp:76
eenv face_env(const eenv &e, int lv)
Definition: tensor_monomials_fcts.hpp:428
void eval(Result &result, const bernstein< Coeff > &controls, const Parameters ¶meters)
Definition: tensor_bernstein_fcts.hpp:195
void mdiff(C *dst, const eenv &a, C const *const src, const eenv &esrc, int v)
Definition: tensor_eenv_loops.hpp:348
void sub(bernstein< C > &r, const bernstein< C > &a)
Definition: tensor_bernstein_fcts.hpp:105
vector_type data
Definition: tensor_monomials.hpp:32
tensor::eenv eenv
Definition: tensor_convert.hpp:12
void contraction(monomials< C > &f, const C &t, const int &v)
Compute f (a*var[v])
Definition: tensor_monomials_fcts.hpp:613
C * begin()
Definition: tensor_monomials.hpp:47
int nvr() const
number of variables
Definition: tensor_eenv_fcts.hpp:9
int nbvar() const
Definition: tensor_monomials.hpp:73
C * end()
Definition: tensor_monomials.hpp:48
std::vector< C > vector_type
Definition: tensor_monomials.hpp:21
void icopy(A *a, unsigned *aadd, unsigned nadd, const B *b)
Definition: tensor_vctops.hpp:158
const C entry(std::vector< int > deg)
Definition: tensor_monomials_fcts.hpp:479
Dynamic exponent.
Definition: dynamicexp.hpp:25
UPOL convert(const MPOL &p, unsigned v)
Definition: tensor_convert.hpp:73
void rename_var(monomials< C > &f, const int &v, const int &n)
Definition: tensor_monomials_fcts.hpp:681
Definition: tensor_monomials.hpp:18
TMPL void face(Polynomial &r, const Polynomial &p, int v, int f)
Definition: polynomial_fcts.hpp:188
TMPL syntactic flatten(const MONOMIAL &v)
Definition: monomial_glue.hpp:36
void print(OSTREAM &o, const bernstein< C > &mpl)
Definition: tensor_bernstein_fcts.hpp:298
static eenv diff(const eenv &b, int lv)
Definition: tensor_eenv_fcts.hpp:270
void set_variable(monomials< C > &f, C t, int v)
Compute f (x_v=t)
Definition: tensor_monomials_fcts.hpp:534
void heval(Result &result, const monomials< Coeff > &monoms, const Parameters ¶meters)
Definition: tensor_monomials_fcts.hpp:148
int sz() const
return the total number of coefficients of the dense representation
Definition: tensor_eenv_fcts.hpp:16
void maxs(OutputIterator _maxs_, const C *data, const eenv &env, int v)
Definition: tensor_eenv_loops.hpp:106
void wsubm(monomials< X > &mpla, const monomials< Y > &mplb)
Definition: tensor_monomials_fcts.hpp:238
void levalm(R &result, const C *data, const eenv &env, const P &p)
Definition: tensor_eenv_loops.hpp:20
int nvr() const
Definition: tensor_monomials.hpp:74
TMPL Polynomial diff(const Polynomial &p, int v)
Definition: tensor_bernstein.hpp:79
int esz() const
Definition: tensor_monomials.hpp:71
void mpolfill(C *data, const sparse::monomial_seq< X, O > &mpol, const eenv &env)
Definition: tensor_eenv_loops.hpp:541
void shift(monomials< C > &f, const C &t, const int &v)
Compute f (var[v]+t)
Definition: tensor_monomials_fcts.hpp:497
int * szs()
Definition: tensor_monomials.hpp:75
const C & c
Definition: Interval_glue.hpp:45
void reciprocal(monomials< C > &f, const int &v)
Compute f (1/var[v])
Definition: tensor_monomials_fcts.hpp:577
void islice(monomials< C > &f, const monomials< C > &src, int v, int i)
Definition: tensor_monomials_fcts.hpp:464
double C
Definition: solver_mv_fatarcs.cpp:16
int Var(const T &v)
Definition: sign_variation.hpp:161
void lface(bernstein< C > &f, const bernstein< C > &src, int v)
Definition: tensor_bernstein_fcts.hpp:354
Monomial class.
Definition: monomial.hpp:62
void extend(monomials< C > &mpl, const eenv &nenv)
Definition: tensor_monomials_fcts.hpp:160
bool varindex(int &lv, const monomials< C > &mpl, int gv)
Definition: tensor_monomials_fcts.hpp:99
void horner(O &o, C const *const c, unsigned n, const I &i, int s=1)
Definition: tensor_vctops.hpp:420
void div(bernstein< C > &r, const bernstein< C > &a, const C &c)
Definition: tensor_bernstein_fcts.hpp:178
Interval< T, r > max(const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:135
bool hasvar(int &lv, int gv) const
Definition: tensor_eenv_fcts.hpp:131
void conv(MPLBASE0 &r, const MPLBASE1 &a)
Definition: tensor_convert.hpp:62
void rface(bernstein< C > &f, const bernstein< C > &src, int v)
Definition: tensor_bernstein_fcts.hpp:361
Definition: variables.hpp:65
void realloc(monomials< C > &mpl, const eenv &nenv)
Definition: tensor_monomials_fcts.hpp:77
int mxvr() const
Definition: tensor_eenv.hpp:67
eenv env
Definition: tensor_monomials.hpp:31
void scmul(A *a, const B &b, unsigned n, int s=1)
Definition: tensor_vctops.hpp:98
void mins(OutputIterator _mins_, const C *data, const eenv &env, int v)
Definition: tensor_eenv_loops.hpp:123
OS & print(OS &os, const R &v)
Output function for general vectors: [v1, v2, ...].
Definition: array.hpp:39
#define assert(expr, msg)
Definition: shared_object.hpp:57