|
realroot_doc 0.1.1
|
#include <tensor_eenv.hpp>
Definition at line 9 of file tensor_eenv.hpp.
| eenv | ( | ) | [inline] |
constructors
Definition at line 72 of file tensor_eenv.hpp.
Referenced by eenv::common(), and eenv::eenv().
: data(0) {};
| eenv | ( | const sparse::monomial_seq< C, O > & | mpl | ) | [inline] |
Definition at line 435 of file tensor_eenv_fcts.hpp.
References vd::d, eenv::eenv(), mmx::tensor::mescan(), vd::n, mmx::nbvar(), eenv::nvr(), eenv::szs(), and eenv::vrs().
{
int nvr = nbvar (mpol);
vd lenv[nvr];
int last = -1;
typename sparse::monomial_seq < C, O >::const_iterator it;
for (it = mpol.begin (); it != mpol.end (); mescan (last, lenv, *it++)) ;
if ( last == -1 )
{
nvr = 1; int szs = 1;
new (this) eenv(1,&szs,0);
return;
};
int c = last;
nvr = 0;
do
{
c = lenv[c].n;
nvr++;
}
while (c != last);
int vrs[nvr];
int szs[nvr];
c = last;
int k = 0;
do
{
vrs[k] = c;
szs[k] = lenv[c].d + 1;
c = lenv[c].n;
lenv[vrs[k]].n = -1;
lenv[vrs[k]].d = 0;
k++;
}
while (c != last);
new (this) eenv (nvr, szs, vrs );
};
| eenv | ( | int * | data | ) |
| eenv | ( | int | nvr_, |
| int const * | szs_ = 0, |
||
| int const * | vrs_ = 0, |
||
| int * | mem = 0 |
||
| ) | [inline] |
create an allocated but uninitialized environement sizes and names given by szs_ and vrs_
Definition at line 151 of file tensor_eenv_fcts.hpp.
References eenv::construct().
| ~eenv | ( | ) | [inline] |
| int * alloc | ( | int | nvr_ | ) | [inline] |
Definition at line 33 of file tensor_eenv_fcts.hpp.
References eenv::data, and eenv::msz().
Referenced by eenv::cdup(), and eenv::construct().
| eenv & cdup | ( | ) | [inline] |
Definition at line 95 of file tensor_eenv_fcts.hpp.
References eenv::alloc(), eenv::copy(), eenv::data, eenv::msz(), and eenv::nvr().
Referenced by eenv::szs().
Definition at line 211 of file tensor_eenv_fcts.hpp.
References eenv::cstr(), eenv::eenv(), eenv::hasvar(), mmx::max(), eenv::mrgvrs(), eenv::nvr(), eenv::szs(), and eenv::vrs().
Referenced by mmx::tensor::add(), and mmx::tensor::sub().
{
if ( a == b ) return eenv(a);
int v, lva, lvb;
eenv oenv (mrgvrs (a, b));
const int *ovr = oenv.vrs ();
const int *aszs = a.szs ();
const int *bszs = b.szs ();
int *oszs = oenv.szs ();
for (v = 0; v < oenv.nvr (); v++)
{
if (a.hasvar (lva, ovr[v]))
{
if (b.hasvar (lvb, ovr[v]))
{
oszs[v] = std::max(aszs[lva], bszs[lvb]);
}
else
oszs[v] = aszs[lva];
}
else
{
if (b.hasvar (lvb, ovr[v]))
oszs[v] = bszs[lvb];
else
std::cout << "erreur dans common\n";
};
};
oenv.cstr ();
return oenv;
};
| void construct | ( | int | nvr_, |
| int const * | szs_, | ||
| int const * | vrs_, | ||
| int * | mem | ||
| ) | [inline] |
Definition at line 40 of file tensor_eenv_fcts.hpp.
References eenv::alloc(), eenv::copy(), eenv::cstr(), eenv::data, eenv::msz(), and eenv::nvr().
Referenced by eenv::eenv().
{
#ifdef EENV_DEBUG
std::cout << "eenv::construct begin\n";
std::cout <<nvr_<<" "<<mem<<" "<<msz (nvr_)<<std::endl;
#endif
data = (mem==0)?alloc(nvr_):mem;
data[0] = 1;
data[1] = nvr_;
if (vrs_)
{
std::pair<int,int> tmp[ nvr_ ];
for ( int i = 0; i < nvr_; i ++ ) {
tmp[i].first = vrs_[i];
tmp[i].second = szs_[i];
}
std::sort(tmp,tmp+nvr_);
for ( int i = 0; i < nvr(); i ++ ) {
data[2+nvr()+i] = tmp[i].first; // vrs()[i] = tmp[i].first;
data[2+i] = tmp[i].second; // szs()[i] = tmp[i].second;
};
cstr ();
}
else
if (szs_)
{
std::copy (szs_, szs_ + nvr_, data+2); //szs();
cstr ();
/*gcc-bug for (int v = 0; v < nvr (); vrs()[v] = v ++ ); */
for (int v = 0; v < nvr () ; data[2+nvr()+v] = v, v++ ) ;
};
};
Definition at line 85 of file tensor_eenv_fcts.hpp.
References eenv::data, and eenv::dealloc().
Referenced by eenv::cdup(), eenv::construct(), eenv::mrgvrs(), and eenv::operator=().
{
// std::cout<<"copy"<<std::endl;
e.dealloc ();
e.data = b.data;
if (e.data)
e.data[0]++;
return e;
};
| void cstr | ( | ) | [inline] |
Definition at line 117 of file tensor_eenv_fcts.hpp.
References eenv::data, eenv::nvr(), and eenv::szs_data().
Referenced by eenv::common(), eenv::construct(), eenv::diff(), eenv::mul(), and eenv::rewrite().
{
#ifdef EENV_DEBUG
std::cout << "eenv::cstr()" << std::endl;
#endif
int i, s = 2+2*nvr()+1;//* _st(str());
const int *_sz(szs_data()); //data+2
for ( i = nvr()-2, data[s+nvr()-1] = 1; i >= -1; data[s+i]=_sz[i+1]*data[s+i+1], i-- ) ;
#ifdef EENV_DEBUG
std::cout << (*this) << std::endl;
#endif
// std::cout << "esz= " << _st[-1] << std::endl;
};
| void cvrs | ( | ) |
| void dealloc | ( | ) | [inline] |
Definition at line 83 of file tensor_eenv_fcts.hpp.
References eenv::data.
Referenced by eenv::copy(), eenv::new_copy(), and eenv::~eenv().
Definition at line 270 of file tensor_eenv_fcts.hpp.
References eenv::cstr(), mmx::max(), eenv::new_copy(), and eenv::szs().
Referenced by mmx::tensor::diff().
{
// const int * bszs = b.szs();
eenv oenv; eenv::new_copy(oenv,b);
int *oszs = oenv.szs();
oszs[lv] = std::max (oszs[lv] - 1, 1);
oenv.cstr ();
return oenv;
};
Definition at line 366 of file tensor_eenv_fcts.hpp.
References eenv::hasvar(), eenv::nvr(), eenv::szs(), and eenv::vrs().
Referenced by mmx::tensor::rewrite().
{
int nszs[o.nvr ()];
const int * ovrs = o.vrs();
const int * oszs = o.szs ();
const int * iszs = i.szs ();
int lv;
for (int v = 0; v < o.nvr (); v++)
if (i.hasvar (lv, ovrs[v]))
nszs[v] = oszs[v] - iszs[lv] + 1;
else
nszs[v] = oszs[v];
eenv tmp(o.nvr (), nszs, o.vrs ());
// std::cout << " tmp = " << tmp << std::endl;
return tmp;
};
Definition at line 74 of file tensor_eenv_fcts.hpp.
References eenv::data, and eenv::nvr().
Referenced by eenv::equiv(), eenv::operator!=(), monomials< C >::operator==(), eenv::operator==(), and mmx::tensor::realloc().
{
if (a.data == b.data) return true;
for (int i = 1; i < 2 + 2 * a.nvr (); i++)
if (a.data[i] != b.data[i]) return false;
return true;
};
Definition at line 474 of file tensor_eenv_fcts.hpp.
References eenv::equal().
{
return equal(a,b);
};
| bool hasvar | ( | int & | lv, |
| int | gv | ||
| ) | const [inline] |
return true if gv is in the variable set lv is the corresponding local name.
Definition at line 131 of file tensor_eenv_fcts.hpp.
References eenv::nvr(), and eenv::vrs().
Referenced by eenv::common(), eenv::elevation(), eenv::mul(), eenv::subset(), mmx::tensor::varindex(), and eenv::vmap().
{
int g, d, m;
const int * _vr = vrs();
if ((gv < _vr[0]) || (gv > _vr[(d=nvr())-1])) return false;
if ( gv == _vr[g = 0] ) { lv = 0; return true; };
if ( gv == _vr[d=nvr()-1]) { lv = nvr()-1; return true;};
do
{
m = (g + d) / 2;
if ( _vr[m] == gv ) { lv = m; return true; };
if ( _vr[m] < gv ) g = m; else d = m;
}
while (d - g > 1);
return false;
};
| int localv | ( | int | i | ) | const [inline] |
Definition at line 61 of file tensor_eenv.hpp.
Referenced by mmx::tensor::face(), mmx::tensor::slice(), and mmx::tensor::split().
{ return i; };
| int mnvr | ( | ) | const [inline] |
Definition at line 162 of file tensor_eenv_fcts.hpp.
References eenv::copy(), eenv::nvr(), and eenv::vrs().
Referenced by eenv::common(), and eenv::mul().
{
unsigned c = 0;
int va, vb;
int prv = (int) (-1);
int anvr = a.nvr ();
int bnvr = b.nvr ();
const int * avr = a.vrs();
const int * bvr = b.vrs() ;
//const eenv::vr_t * agvr = a.gvr ();
// const eenv::vr_t * bgvr = b.gvr ();
int tmp[anvr + bnvr];
c = va = vb = 0;
do
{
if ( avr[va] <= bvr[vb] )
{
if ( avr[va] != prv ) tmp[c++] = prv = avr[va];
va++;
continue;
};
if ( bvr[vb] < avr[va] )
{
if ( bvr[vb] != prv ) tmp[c++] = prv = bvr[vb];
vb++;
continue;
};
}
while (va < anvr && vb < bnvr);
if (va < anvr) for (; va < anvr; va++)
if ( avr[va] != prv ) tmp[c++] = avr[va];
if (vb < bnvr) for (; vb < bnvr; vb++)
if ( bvr[vb] != prv ) tmp[c++] = bvr[vb];
eenv oenv (c);
std::copy(tmp,tmp+oenv.nvr(),oenv.vrs());
return oenv;
};
| int msz | ( | int | nvr_ | ) | [inline, static] |
Definition at line 28 of file tensor_eenv_fcts.hpp.
Referenced by eenv::new_copy().
{ return 1 + 1 + nvr_ + nvr_ + nvr_ + 1 + 2 * nvr_; };
| int msz | ( | ) | const [inline] |
memory size used by the eenv representation in bytes.
Definition at line 29 of file tensor_eenv_fcts.hpp.
References eenv::nvr().
Referenced by eenv::alloc(), eenv::cdup(), and eenv::construct().
Definition at line 246 of file tensor_eenv_fcts.hpp.
References eenv::cstr(), eenv::hasvar(), eenv::mrgvrs(), eenv::nvr(), eenv::szs(), and eenv::vrs().
Referenced by mmx::tensor::conv().
{
int v, lva, lvb;
eenv oenv (mrgvrs (a, b));
// std::cout << " mrgvrs = " << oenv << std::endl;
int *oszs = oenv.szs ();
const int *ovrs = oenv.vrs ();
const int *aszs = a.szs ();
const int *bszs = b.szs ();
for (v = 0; v < oenv.nvr (); v++)
{
oszs[v] = 0;
if (a.hasvar (lva, ovrs[v]))
oszs[v] += aszs[lva] - 1;
if (b.hasvar (lvb, ovrs[v]))
oszs[v] += bszs[lvb] - 1;
oszs[v]++;
};
oenv.cstr ();
return oenv;
};
| int mxvr | ( | ) | const [inline] |
Definition at line 67 of file tensor_eenv.hpp.
References eenv::nvr(), and eenv::vrs().
Referenced by mmx::tensor::convert(), mmx::tensor::print(), and mmx::tensor::print_flatten().
Definition at line 108 of file tensor_eenv_fcts.hpp.
References eenv::data, eenv::dealloc(), eenv::msz(), and eenv::sz().
Referenced by eenv::diff().
| int nvr | ( | ) | const [inline] |
number of variables
Definition at line 9 of file tensor_eenv_fcts.hpp.
References eenv::data.
Referenced by mmx::tensor::binoms(), eenv::cdup(), eenv::common(), eenv::construct(), mmx::tensor::convertb2m(), mmx::tensor::convertm2b(), eenv::cstr(), eenv::eenv(), eenv::elevation(), eenv::equal(), mmx::tensor::face_env(), eenv::hasvar(), mmx::tensor::hevalm(), mmx::tensor::levalb(), mmx::tensor::levalm(), mmx::tensor::mpolfill(), eenv::mrgvrs(), eenv::msz(), eenv::mul(), eenv::mxvr(), monomials< C >::nbvar(), monomials< C >::nvr(), eenv::oaddress(), mmx::tensor::operator<<(), mmx::tensor::restrict(), eenv::rewrite(), mmx::tensor::scale(), eenv::str(), eenv::subset(), mmx::tensor::uscale(), eenv::vmap(), eenv::vridx(), eenv::vrs(), and mmx::tensor::vswap().
{ return data[1]; };
| bool oaddress | ( | const eenv & | oenv, |
| unsigned * | osupp, | ||
| const eenv & | ienv, | ||
| unsigned * | isupp = 0, |
||
| unsigned | nsp = 0 |
||
| ) | [inline, static] |
addresses translation from environment i to environment o
Definition at line 295 of file tensor_eenv_fcts.hpp.
References eenv::nvr(), eenv::st(), eenv::str(), eenv::sz(), and eenv::vmap().
Referenced by mmx::tensor::add(), mmx::tensor::conv(), mmx::tensor::extend(), monomials< C >::operator==(), mmx::tensor::sub(), mmx::tensor::waddm(), and mmx::tensor::wsubm().
{
// std::cout << oenv << std::endl;
// std::cout << ienv << std::endl;
int v;
unsigned c;
int vmap_[ienv.nvr ()];
unsigned addi, addo;
if (!vmap (vmap_, oenv, ienv))
return false;
if (isupp)
for (c = 0; c < nsp; osupp[c] = addo, c++)
for (addi = isupp[c], addo = 0, v = ienv.nvr () - 1; addi;
addi /= ienv.sz (v), v--)
addo += (addi % ienv.sz (v)) * oenv.st (vmap_[v]);
else
{
const int *istr = ienv.str ();
const int *ostr = oenv.str ();
osupp[0] = 0;
for (v = 0; v < ienv.nvr (); v++)
for (int j = 0; j < istr[-1]; j += istr[v - 1])
for (int i = j + istr[v]; i < j + istr[v - 1]; i += istr[v])
osupp[i] = osupp[i - istr[v]] + ostr[vmap_[v]];
};
return true;
};
| bool operator!= | ( | const eenv & | a | ) | const [inline] |
Definition at line 361 of file tensor_eenv_fcts.hpp.
References eenv::equal().
{
return !eenv::equal (*this, e);
};
| bool operator< | ( | const eenv & | b | ) | const [inline] |
Definition at line 31 of file tensor_eenv_fcts.hpp.
References eenv::sz().
{ return sz () < b.sz (); };
Definition at line 161 of file tensor_eenv_fcts.hpp.
References eenv::copy().
{ return copy (*this, e); };
| bool operator== | ( | const eenv & | a | ) | const [inline] |
Definition at line 356 of file tensor_eenv_fcts.hpp.
References eenv::equal().
{
return eenv::equal (*this, e);
};
Definition at line 480 of file tensor_eenv_fcts.hpp.
References eenv::cstr(), eenv::nvr(), eenv::szs(), and eenv::vmap().
| int st | ( | int | v | ) | const [inline] |
return the stride for variable v
Definition at line 24 of file tensor_eenv_fcts.hpp.
References eenv::str().
Referenced by mmx::tensor::m_diff(), and eenv::oaddress().
{ return str ()[v]; };
| const int * str | ( | ) | const [inline] |
point to an array representing the stride for each variable
Definition at line 22 of file tensor_eenv_fcts.hpp.
References eenv::nvr(), and eenv::vrs().
| int * str | ( | ) | [inline] |
Definition at line 21 of file tensor_eenv_fcts.hpp.
References eenv::nvr(), and eenv::vrs().
Referenced by mmx::tensor::bdiff(), mmx::tensor::binoms(), mmx::tensor::brestrictLR(), mmx::tensor::brestrictRL(), mmx::tensor::bsplit(), mmx::tensor::bsplit2(), mmx::tensor::convertb2m(), mmx::tensor::convertm2b(), mmx::tensor::hevalm(), mmx::tensor::levalb(), mmx::tensor::levalm(), mmx::tensor::lface(), mmx::tensor::maxs(), mmx::tensor::mdiff(), mmx::tensor::mins(), mmx::tensor::mpolfill(), eenv::oaddress(), mmx::tensor::operator<<(), mmx::tensor::rface(), mmx::tensor::scale(), mmx::tensor::slice(), eenv::st(), monomials< C >::str(), eenv::sz(), mmx::tensor::uscale(), and mmx::tensor::vswap().
Definition at line 344 of file tensor_eenv_fcts.hpp.
References eenv::hasvar(), eenv::nvr(), eenv::szs(), and eenv::vrs().
Referenced by mmx::tensor::waddm(), and mmx::tensor::wsubm().
{
const int *avrs = a.vrs ();
const int *aszs = a.szs ();
const int *bszs = b.szs ();
int lv;
for (int i = 0; i < a.nvr (); i++)
if ((!b.hasvar (lv, avrs[i])) || aszs[i] > bszs[lv])
return false;
return true;
};
| void swap | ( | eenv & | e | ) | [inline] |
Definition at line 7 of file tensor_eenv_fcts.hpp.
References eenv::data.
| int sz | ( | ) | const [inline] |
return the total number of coefficients of the dense representation
Definition at line 16 of file tensor_eenv_fcts.hpp.
References eenv::str().
Referenced by mmx::tensor::bdiff(), mmx::tensor::binoms(), mmx::tensor::convertb2m(), mmx::tensor::convertm2b(), mmx::tensor::degree(), monomials< C >::esz(), mmx::tensor::eval(), mmx::tensor::hevalm(), mmx::tensor::ibinoms(), mmx::tensor::levalb(), mmx::tensor::levalm(), mmx::tensor::lface(), mmx::tensor::m_diff(), mmx::tensor::mdiff(), eenv::new_copy(), eenv::oaddress(), eenv::operator<(), mmx::tensor::operator<<(), mmx::tensor::rface(), mmx::tensor::scale(), monomials< C >::size(), mmx::tensor::slice(), and mmx::tensor::uscale().
{ return str ()[-1]; };
| int sz | ( | int | v | ) | const [inline] |
return the order for variable v
Definition at line 15 of file tensor_eenv_fcts.hpp.
References eenv::szs().
{ return szs ()[v]; };
| int * szs | ( | ) | [inline] |
Definition at line 12 of file tensor_eenv_fcts.hpp.
References eenv::cdup(), and eenv::data.
Referenced by mmx::tensor::bdiff(), mmx::tensor::binoms(), eenv::common(), mmx::tensor::convertb2m(), mmx::tensor::convertm2b(), mmx::tensor::degree(), eenv::diff(), eenv::eenv(), eenv::elevation(), mmx::tensor::face_env(), mmx::tensor::hevalm(), mmx::tensor::levalb(), mmx::tensor::levalm(), mmx::tensor::maxs(), mmx::tensor::mins(), eenv::mul(), mmx::tensor::operator<<(), eenv::rewrite(), mmx::tensor::scale(), eenv::subset(), eenv::sz(), monomials< C >::szs(), mmx::tensor::uscale(), eenv::vrs(), and mmx::tensor::vswap().
{ return cdup ().data + 2; };
| const int * szs | ( | ) | const [inline] |
point to an array representing the order for each variable
Definition at line 11 of file tensor_eenv_fcts.hpp.
References eenv::data.
{ return data + 2; };
| int * szs_data | ( | ) | [inline] |
Definition at line 13 of file tensor_eenv_fcts.hpp.
References eenv::data.
Referenced by eenv::cstr().
{ return data + 2; };
variable names translation from environment i to environment o
Definition at line 280 of file tensor_eenv_fcts.hpp.
References eenv::hasvar(), eenv::nvr(), and eenv::vr().
Referenced by eenv::oaddress(), and eenv::rewrite().
{
for (int v = 0; v < i.nvr (); v++)
{
int lv;
if (!o.hasvar (lv, i.vr (v)))
{
return false;
};
vmap[v] = lv;
};
return true;
};
| int vr | ( | int | lv | ) | const [inline] |
return the global id for variable lv
Definition at line 26 of file tensor_eenv_fcts.hpp.
References eenv::vrs().
Referenced by eenv::vmap().
{ return vrs ()[v]; };
| int vridx | ( | int | i | ) | const [inline] |
Definition at line 62 of file tensor_eenv.hpp.
References eenv::nvr(), and eenv::vrs().
Referenced by mmx::tensor::restrict().
| int * vrs | ( | ) | [inline] |
Definition at line 18 of file tensor_eenv_fcts.hpp.
References eenv::nvr(), and eenv::szs().
Referenced by eenv::common(), eenv::eenv(), eenv::elevation(), mmx::tensor::face_env(), eenv::hasvar(), eenv::mnvr(), mmx::tensor::mpolfill(), eenv::mrgvrs(), eenv::mul(), eenv::mxvr(), mmx::tensor::operator<<(), eenv::str(), eenv::subset(), eenv::vr(), eenv::vridx(), and monomials< C >::vrs().
| const int * vrs | ( | ) | const [inline] |
point to an array representing the global id for each variable
Definition at line 19 of file tensor_eenv_fcts.hpp.
References eenv::nvr(), and eenv::szs().
| void vswap | ( | int * | perm | ) |
Referenced by mmx::tensor::vswap().
| std::ostream& operator<< | ( | std::ostream & | o, |
| const eenv & | env | ||
| ) | [friend] |
Definition at line 325 of file tensor_eenv_fcts.hpp.
{
out << "*eenv*\n";
out << "\tpos: " << env.data << "\n";
out << "\tref: " << env.data[0] << "\n";
out << "\tnvr: " << env.nvr() << "\n";
out << "\tesz: " << env.sz () << "\n";
out << "\tszs: ";
vct::print (env.szs (), env.nvr (), 1, out);
out << "\n";
out << "\tvrs: ";
vct::print (env.vrs (), env.nvr (), 1, out);
out << "\n";
out << "\tstr: ";
vct::print (env.str (), env.nvr (), 1, out);
return out;
};
| int* data |
Definition at line 37 of file tensor_eenv.hpp.
Referenced by eenv::alloc(), eenv::cdup(), eenv::construct(), eenv::copy(), eenv::cstr(), eenv::dealloc(), eenv::eenv(), eenv::equal(), eenv::new_copy(), eenv::nvr(), mmx::tensor::operator<<(), eenv::swap(), eenv::szs(), and eenv::szs_data().