1 #ifndef realroot_SBDSLV_EENV_C
2 #define realroot_SBDSLV_EENV_C
28 inline int eenv::msz (
int nvr_) {
return 1 + 1 + nvr_ + nvr_ + nvr_ + 1 + 2 * nvr_; };
44 std::cout <<
"eenv::construct begin\n";
45 std::cout <<nvr_<<
" "<<mem<<
" "<<
msz (nvr_)<<std::endl;
52 std::pair<int,int> *tmp =
new std::pair<int,int>[ nvr_ ];
53 for (
int i = 0; i < nvr_; i ++ ) {
54 tmp[i].first = vrs_[i];
55 tmp[i].second = szs_[i];
57 std::sort(tmp,tmp+nvr_);
58 for (
int i = 0; i <
nvr(); i ++ ) {
60 data[2+i] = tmp[i].second;
70 for (
int v = 0; v <
nvr () ;
data[2+
nvr()+v] = v, v++ ) ;
78 for (
int i = 1; i < 2 + 2 * a.
nvr (); i++)
79 if (a.
data[i] != b.
data[i])
return false;
111 unsigned sz = b.
msz();
113 for(
unsigned i=0;i<
sz;i++) e.
data[i]=b.
data[i];
120 std::cout <<
"eenv::cstr()" << std::endl;
122 int i, s = 2+2*
nvr()+1;
124 for ( i =
nvr()-2,
data[s+
nvr()-1] = 1; i >= -1;
data[s+i]=_sz[i+1]*
data[s+i+1], i-- ) ;
126 std::cout << (*this) << std::endl;
134 const int * _vr =
vrs();
135 if ((gv < _vr[0]) || (gv > _vr[(d=
nvr())-1]))
return false;
136 if ( gv == _vr[g = 0] ) { lv = 0;
return true; };
137 if ( gv == _vr[d=
nvr()-1]) { lv =
nvr()-1;
return true;};
141 if ( _vr[m] == gv ) { lv = m;
return true; };
142 if ( _vr[m] < gv ) g = m;
else d = m;
151 inline eenv::eenv (
int nvr_,
int const *szs_,
int const *vrs_,
int *mem)
152 :data(new int[msz(nvr_)])
167 int prv = (int) (-1);
170 const int * avr = a.
vrs();
171 const int * bvr = b.
vrs() ;
175 int tmp[anvr + bnvr];
181 if ( avr[va] <= bvr[vb] )
183 if ( avr[va] != prv ) tmp[c++] = prv = avr[va];
188 if ( bvr[vb] < avr[va] )
190 if ( bvr[vb] != prv ) tmp[c++] = prv = bvr[vb];
195 while (va < anvr && vb < bnvr);
197 if (va < anvr)
for (; va < anvr; va++)
198 if ( avr[va] != prv ) tmp[c++] = avr[va];
200 if (vb < bnvr)
for (; vb < bnvr; vb++)
201 if ( bvr[vb] != prv ) tmp[c++] = bvr[vb];
213 if ( a == b )
return eenv(a);
217 const int *ovr = oenv.
vrs ();
218 const int *aszs = a.
szs ();
219 const int *bszs = b.
szs ();
220 int *oszs = oenv.
szs ();
222 for (v = 0; v < oenv.
nvr (); v++)
224 if (a.
hasvar (lva, ovr[v]))
226 if (b.
hasvar (lvb, ovr[v]))
228 oszs[v] =
std::max(aszs[lva], bszs[lvb]);
235 if (b.
hasvar (lvb, ovr[v]))
238 std::cout <<
"erreur dans common\n";
252 int *oszs = oenv.
szs ();
253 const int *ovrs = oenv.
vrs ();
254 const int *aszs = a.
szs ();
255 const int *bszs = b.
szs ();
257 for (v = 0; v < oenv.
nvr (); v++)
260 if (a.
hasvar (lva, ovrs[v]))
261 oszs[v] += aszs[lva] - 1;
262 if (b.
hasvar (lvb, ovrs[v]))
263 oszs[v] += bszs[lvb] - 1;
274 int *oszs = oenv.
szs();
275 oszs[lv] =
std::max (oszs[lv] - 1, 1);
282 for (
int v = 0; v < i.
nvr (); v++)
296 const eenv & ienv,
unsigned *isupp,
unsigned nsp)
302 int vmap_[ienv.
nvr ()];
304 if (!
vmap (vmap_, oenv, ienv))
307 for (c = 0; c < nsp; osupp[
c] = addo, c++)
308 for (addi = isupp[c], addo = 0, v = ienv.
nvr () - 1; addi;
309 addi /= ienv.
sz (v), v--)
310 addo += (addi % ienv.
sz (v)) * oenv.
st (vmap_[v]);
313 const int *istr = ienv.
str ();
314 const int *ostr = oenv.
str ();
316 for (v = 0; v < ienv.
nvr (); v++)
317 for (
int j = 0; j < istr[-1]; j += istr[v - 1])
318 for (
int i = j + istr[v]; i < j + istr[v - 1]; i += istr[v])
319 osupp[i] = osupp[i - istr[v]] + ostr[vmap_[v]];
328 out <<
"\tpos: " << env.
data <<
"\n";
329 out <<
"\tref: " << env.
data[0] <<
"\n";
330 out <<
"\tnvr: " << env.
nvr() <<
"\n";
331 out <<
"\tesz: " << env.
sz () <<
"\n";
346 const int *avrs = a.
vrs ();
347 const int *aszs = a.
szs ();
348 const int *bszs = b.
szs ();
350 for (
int i = 0; i < a.
nvr (); i++)
351 if ((!b.
hasvar (lv, avrs[i])) || aszs[i] > bszs[lv])
369 const int * ovrs = o.
vrs();
370 const int * oszs = o.
szs ();
371 const int * iszs = i.
szs ();
373 for (
int v = 0; v < o.
nvr (); v++)
374 if (i.
hasvar (lv, ovrs[v]))
375 nszs[v] = oszs[v] - iszs[lv] + 1;
396 o <<
"vd(" << vd_.
n <<
", " << vd_.
d <<
")";
400 template <
class MONOM >
void mescan (
int &last,
vd * vdeg,
const MONOM & m)
402 for (
unsigned i = 0; i < m.size (); i++)
407 vdeg[i].
d =
std::max ((
int) m[i], vdeg[i].d);
412 vdeg[i].
n = vdeg[last].
n;
434 template <
class C,
class O >
440 typename sparse::monomial_seq < C, O >::const_iterator it;
441 for (it = mpol.begin (); it != mpol.end ();
mescan (last, lenv, *it++)) ;
444 nvr = 1;
int szs = 1;
445 new (
this)
eenv(1,&szs,0);
464 szs[k] = lenv[
c].
d + 1;
471 new (
this)
eenv (nvr, szs, vrs );
482 int vmap_[ o.
nvr() ];
483 if ( !
vmap( vmap_, o, i ) ) { std::cerr <<
"vmap error(rewrite)\n"; exit(1); };
485 for (
int v = 0; v < o.
nvr(); v ++ ) tmp.
szs()[v] = 1;
486 for (
int v = 0; v < i.
nvr(); v ++ ) tmp.
szs()[vmap_[v]] = i.
szs()[v];
static eenv mul(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:246
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
Definition: tensor_eenv_fcts.hpp:429
const C & b
Definition: Interval_glue.hpp:25
int d
Definition: tensor_eenv_fcts.hpp:388
bool operator==(const eenv &a) const
Definition: tensor_eenv_fcts.hpp:356
int * szs()
Definition: tensor_eenv_fcts.hpp:12
Definition: tensor_eenv_fcts.hpp:386
static bool equal(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:74
MP swap(const MP &P, int var_i, int var_j)
Definition: sparse_monomials.hpp:988
static eenv elevation(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:366
static bool equiv(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:474
void construct(int nvr_, int const *szs_, int const *vrs_, int *mem)
Definition: tensor_eenv_fcts.hpp:40
eenv()
constructors
Definition: tensor_eenv.hpp:72
static bool subset(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:344
void dealloc()
Definition: tensor_eenv_fcts.hpp:83
static eenv common(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:211
int * vrs()
Definition: tensor_eenv_fcts.hpp:18
std::ostream & operator<<(std::ostream &o, const bernstein< C > &mpl)
Definition: tensor_bernstein_fcts.hpp:253
int * str()
Definition: tensor_eenv_fcts.hpp:21
Definition: tensor_eenv.hpp:9
void swap(eenv &e)
Definition: tensor_eenv_fcts.hpp:7
void mescan(int &last, vd *vdeg, const MONOM &m)
Definition: tensor_eenv_fcts.hpp:400
static eenv rewrite(const eenv &o, const eenv &i)
Definition: tensor_eenv_fcts.hpp:480
int vr(int lv) const
return the global id for variable lv
Definition: tensor_eenv_fcts.hpp:26
int * szs_data()
Definition: tensor_eenv_fcts.hpp:13
int nvr() const
number of variables
Definition: tensor_eenv_fcts.hpp:9
int * alloc(int nvr_)
Definition: tensor_eenv_fcts.hpp:33
TMPL void copy(Polynomial &r, const Polynomial &a)
Copy of a in r.
Definition: sparse_monomials.hpp:613
eenv & cdup()
Definition: tensor_eenv_fcts.hpp:95
vd()
Definition: tensor_eenv_fcts.hpp:389
static eenv diff(const eenv &b, int lv)
Definition: tensor_eenv_fcts.hpp:270
void cstr()
Definition: tensor_eenv_fcts.hpp:117
int sz() const
return the total number of coefficients of the dense representation
Definition: tensor_eenv_fcts.hpp:16
void print(const A *p, unsigned n, int st=1, std::ostream &o=std::cout)
Definition: tensor_vctops.hpp:206
int n
Definition: tensor_eenv_fcts.hpp:388
static bool vmap(int *vmap, const eenv &o, const eenv &i)
variable names translation from environment i to environment o
Definition: tensor_eenv_fcts.hpp:280
bool operator!=(const eenv &a) const
Definition: tensor_eenv_fcts.hpp:361
int initial
Definition: tensor_eenv_fcts.hpp:430
int name
Definition: tensor_eenv_fcts.hpp:430
static eenv & copy(eenv &e, const eenv &b)
Definition: tensor_eenv_fcts.hpp:85
static eenv mrgvrs(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:162
int * data
Definition: tensor_eenv.hpp:37
const C & c
Definition: Interval_glue.hpp:45
eenv & operator=(const eenv &e)
Definition: tensor_eenv_fcts.hpp:161
int st(int v) const
return the stride for variable v
Definition: tensor_eenv_fcts.hpp:24
bool operator<(const eenv &b) const
Definition: tensor_eenv_fcts.hpp:31
static void new_copy(eenv &e, const eenv &b)
Definition: tensor_eenv_fcts.hpp:108
TMPL int nbvar(const Polynomial &mp)
Definition: polynomial_fcts.hpp:43
int msz() const
memory size used by the eenv representation in bytes.
Definition: tensor_eenv_fcts.hpp:29
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
static int msz(int nvr_)
Definition: tensor_eenv_fcts.hpp:28
bool operator<(const oulala &b) const
Definition: tensor_eenv_fcts.hpp:431
~eenv()
Definition: tensor_eenv_fcts.hpp:149