realroot_doc 0.1.1
mmx::tensor Namespace Reference

namespace for representation of polynomials as dense tensor product. More...

Classes

Typedefs

Functions


Detailed Description

namespace for representation of polynomials as dense tensor product.


Typedef Documentation

typedef tensor::eenv eenv

Definition at line 12 of file tensor_convert.hpp.


Function Documentation

void mmx::tensor::add ( bernstein< C > &  mpl,
const C &  c 
)

Definition at line 53 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), monomials< C >::esz(), and scadd().

Referenced by add(), convert(), and sub().

  {
    vct::scadd (mpl.begin (), c, mpl.esz (), 1);
  };
void mmx::tensor::add ( bernstein< C > &  r,
const bernstein< C > &  a,
const C &  c 
)

Definition at line 59 of file tensor_bernstein_fcts.hpp.

References add(), monomials< C >::begin(), monomials< C >::env, monomials< C >::esz(), and scadd().

  {
    if (r.env != a.env)
      add (r = a, c);
    else
      vct::scadd (r.begin (), a.begin (), c, r.esz (), 1);
  };
void mmx::tensor::add ( bernstein< C > &  r,
const C &  c,
const bernstein< C > &  a 
)

Definition at line 68 of file tensor_bernstein_fcts.hpp.

References add().

                                                                  {
    add(r,a,c);
  }
void mmx::tensor::add ( bernstein< C > &  r,
const bernstein< C > &  a 
)

Definition at line 81 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), eenv::common(), monomials< C >::env, monomials< C >::esz(), mmx::vctops::padd(), and rewrite().

  {
    eenv cm(eenv::common(r.env,a.env));
    if ( r.env != cm ) { rewrite(r,cm); };
    if ( a.env == cm ) 
      {
        vct::padd (r.begin (), a.begin (), r.esz (), 1, 1); 
      }
    else 
      {
        bernstein<C> tmp(a);
        rewrite(tmp,cm);
        vct::padd (r.begin (), tmp.begin (), r.esz (), 1, 1);
      };
  };
void mmx::tensor::add ( bernstein< C > &  r,
const bernstein< C > &  a,
const bernstein< C > &  b 
)

Definition at line 99 of file tensor_bernstein_fcts.hpp.

References add().

                                                                             {
  add (r=a, b);
}
void mmx::tensor::add ( monomials< X > &  r,
const monomials< X > &  a,
const C &  c 
) [inline]

Definition at line 186 of file tensor_monomials_fcts.hpp.

References add().

                                                                  {
    add(r=a,c);
  }
void mmx::tensor::add ( monomials< C > &  a,
const C &  x 
) [inline]

Definition at line 191 of file tensor_monomials_fcts.hpp.

                                        {
    a[0] += x;
  }
void mmx::tensor::add ( monomials< C > &  r,
const C &  c,
const monomials< C > &  a 
)

Definition at line 196 of file tensor_monomials_fcts.hpp.

References add().

                                                                  {
    add(r,a,c);
  }
void mmx::tensor::add ( monomials< C > &  r,
const monomials< C > &  a 
) [inline]

Definition at line 201 of file tensor_monomials_fcts.hpp.

References eenv::common(), monomials< C >::env, extend(), and waddm().

  {
    extend (r, eenv::common (r.env, a.env));
    waddm (r, a);
  }
void mmx::tensor::add ( monomials< C > &  r,
const monomials< C > &  a,
const monomials< C > &  b 
) [inline]

Definition at line 208 of file tensor_monomials_fcts.hpp.

References add(), monomials< C >::begin(), eenv::common(), monomials< C >::env, monomials< C >::esz(), mmx::vct::icopy(), mmx::vct::ipadd(), mmx::max(), eenv::oaddress(), and realloc().

  {
    if ( &r == &a  ) {  add(r,b);  return;  };
    if ( &r  == &b ) {  add(r,a); return; };
    realloc(r,eenv::common(a.env,b.env));
    unsigned *oadd = new unsigned[std::max(a.esz (),b.esz())];
    eenv::oaddress (r.env, oadd,a.env, 0, 0);
    vct::icopy(r.begin(),oadd,a.esz(),a.begin());
    eenv::oaddress(r.env,oadd,b.env,0,0);
    vct::ipadd (r.begin (), oadd,b.esz (), b.begin ());
  };
void mmx::tensor::assign ( monomials< C > &  monoms,
const bernstein< C > &  controls 
)

Definition at line 267 of file tensor_bernstein_fcts.hpp.

References convertb2m().

Referenced by approx(), hevalm(), levalb(), and mpolfill().

  {
    monoms = controls;
    tensor::convertb2m(monoms);
  };
static void mmx::tensor::bdiff ( C *  dst,
const eenv &  a,
C const *const  src,
int  v 
) [static]

Definition at line 360 of file tensor_eenv_loops.hpp.

References eenv::str(), eenv::sz(), and eenv::szs().

Referenced by diff().

  {
    const int   ssz  = a.sz ();
    const int * sszs = a.szs();
    const int * sstr = a.str();
    int rst = sstr[v-1]-sstr[v];
    //    unsigned i;
    C * ed; const C * es;
    for ( ed = dst, es = src; es < src+ssz; ed += rst, es += sstr[v-1] )
      {
        C * fd; const C * fs;
        for ( fs = es, fd = ed; fs < es + sstr[v]; fs++, fd ++ )
          {
            C * dp; const C * p;
            for ( p = fs, dp = fd; p < fs+rst; p += sstr[v], dp += sstr[v] )
              *dp = (*(p+sstr[v])-*p)*(sszs[v]-1);
          };
      };
  }
void mmx::tensor::binoms ( C *  data,
const eenv &  env,
binomials< C > &  binms 
)

Definition at line 170 of file tensor_eenv_loops.hpp.

References mmx::vct::copy(), eenv::nvr(), mmx::vct::pmul(), eenv::str(), eenv::sz(), and eenv::szs().

  {
    const int *estr = env.str ();
    const int *eszs = env.szs ();
    const int envr = env.nvr ();
    const int esz = env.sz ();
    const C *bins = binms[eszs[envr - 1] - 1];
    for (C * pdata = data; pdata < data + esz; pdata += estr[envr - 2])
      vct::copy (pdata, bins, eszs[envr - 1]);
    for (int v = 0; v < envr - 1; v++)
      {
        bins = binms[eszs[v] - 1];
        //      int k = 0;
        for (int i = 0; i < esz; i += estr[v - 1])
          for (int j = 0; j < estr[v]; j++)
            vct::pmul (data + i + j, bins, eszs[v], estr[v], 1);
      };
  };
void mmx::tensor::binoms ( bernstein< C > &  mpl) [inline]

Definition at line 9 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::env.

Referenced by elevate(), and ibinoms().

                              {
    binoms( mpl.begin(), mpl.env, binomials<C>::default_ ) ;
  }
void mmx::tensor::brestrict ( C *  src,
const eenv &  env,
int  v,
const T &  a,
const T &  b 
) [inline]

Definition at line 484 of file tensor_eenv_loops.hpp.

References brestrictLR().

Referenced by restrict().

  {
    brestrictLR   ( src, env, v, T(1-a), a, T((b-a)/(T(1)-a)), T((T(1)-b)/(T(1)-a)) );
  };
void mmx::tensor::brestrict_uloop ( C *  r,
C *  rlast,
int  st,
const T &  a,
const T &  b 
) [inline]

Definition at line 438 of file tensor_eenv_loops.hpp.

Referenced by brestrictLR(), and brestrictRL().

  {
    C * er, * p;
    for ( er = rlast - st ; er != r; er -= st )
      for ( p = r; p != er; p += st )
        *p = (a**p+b**(p+st));
  };
void mmx::tensor::brestrictLR ( C *  s,
const eenv &  env,
int  v,
const T &  a,
const T &  b,
const T &  c,
const T &  d 
) [inline]

Definition at line 449 of file tensor_eenv_loops.hpp.

References brestrict_uloop(), and eenv::str().

Referenced by brestrict().

  {
    //    std::cout << a << " " << b << std::endl;
    //    std::cout << c << " " << d << std::endl;
    //    const int *sszs = env.szs ();
    const int *sstr = env.str ();
    //    int i, j, k;
    for ( C * es = s; es != s + sstr[-1]; es += sstr[v-1] )
      for ( C * fs = es; fs != es + sstr[v]; fs ++ )
        {
          brestrict_uloop(fs,fs+sstr[v-1],sstr[v],a,b);
          brestrict_uloop(fs+sstr[v-1]-sstr[v],fs-sstr[v],-sstr[v],c,d);
        };
  };
void mmx::tensor::brestrictRL ( C *  s,
const eenv &  env,
int  v,
const T &  a,
const T &  b,
const T &  c,
const T &  d 
) [inline]

Definition at line 465 of file tensor_eenv_loops.hpp.

References brestrict_uloop(), and eenv::str().

  {
    //    std::cout << a << " " << b << std::endl;
    //    std::cout << c << " " << d << std::endl;
   
    

    //    const int *sszs = env.szs ();
    const int *sstr = env.str ();
    //    int i, j, k;
    for ( C * es = s; es != s + sstr[-1]; es += sstr[v-1] )
      for ( C * fs = es; fs != es + sstr[v]; fs ++ )
        {
          brestrict_uloop(fs+sstr[v-1]-sstr[v],fs-sstr[v],-sstr[v],c,d);        
          brestrict_uloop(fs,fs+sstr[v-1],sstr[v],a,b);
        };
  };
void mmx::tensor::bsplit ( C *  l,
C *  r,
const eenv &  env,
const T &  t,
int  v 
) [inline]

Definition at line 394 of file tensor_eenv_loops.hpp.

References bsplit_uloop(), and eenv::str().

Referenced by split().

  {
    //  const int *sszs = env.szs ();
    const int *sstr = env.str ();
    //  int i, j, k;
    C *er,*el;
    for ( el = l, er = r; el != l + sstr[-1]; el += sstr[v-1], er += sstr[v-1] )
      {
        C *fr,*fl;
        for ( fl = el, fr = er; fl != el + sstr[v]; fl++, fr++ )
          bsplit_uloop(fr,fr+sstr[v-1],fl,t,sstr[v]) ;
      };
  };
void mmx::tensor::bsplit2 ( C *  l,
C *  r,
const eenv &  env,
int  v 
)

Definition at line 423 of file tensor_eenv_loops.hpp.

References bsplit2_uloop(), and eenv::str().

Referenced by split().

  {
    //    const int *sszs = env.szs ();
    const int *sstr = env.str ();
    C *er,*el;
    for ( el = l, er = r; el != l + sstr[-1]; el += sstr[v-1], er += sstr[v-1] )
      {
        C *fr,*fl;
        for ( fl = el, fr = er; fl != el + sstr[v]; fl++, fr++ )
          bsplit2_uloop(fr,fr+sstr[v-1],fl,sstr[v]);
      };
  };
void mmx::tensor::bsplit2_uloop ( C *  r,
C *  rlast,
C *  l,
int  st 
) [inline]

Definition at line 410 of file tensor_eenv_loops.hpp.

Referenced by bsplit2().

  {
    C * er, * p;
    for ( er = rlast - st ; er != r; er -= st, l += st )
      {
        *l = *r;
        for ( p = r; p != er; p += st )
          *p = (*p+*(p+st))/C(2);
      };
    *l = *r;
  };
void mmx::tensor::bsplit_uloop ( C *  r,
C *  rlast,
C *  l,
const T &  t,
int  st 
) [inline]

Definition at line 381 of file tensor_eenv_loops.hpp.

Referenced by bsplit().

  {
    C * er, * p;
    for ( er = rlast - st ; er != r; er -= st, l += st )
      {
        *l = *r;
        for ( p = r; p != er; p += st )
          *p = (1.0-t)**p+t**(p+st);
      };
    *l = *r;
  };
void mmx::tensor::casteljau ( bernstein< C > &  a,
bernstein< C > &  b,
const C &  t,
int  v 
)

Definition at line 222 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), monomials< C >::env, and realloc().

Referenced by casteljau().

{
  if (a.env != b.env)
    realloc (a, b.env);
  casteljau (a.begin (), b.begin (), t, v);
};
void mmx::tensor::casteljau ( bernstein< C > &  left,
bernstein< C > &  right,
const bernstein< C > &  source,
const C &  t,
int  v 
)

Definition at line 230 of file tensor_bernstein_fcts.hpp.

References casteljau().

{
  casteljau (left, right = source, t, v);
};
void mmx::tensor::casteljau ( bernstein< C > &  a,
bernstein< C > &  b,
int  v 
)

Definition at line 238 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), casteljau(), monomials< C >::env, and realloc().

  {
    if (a.env != b.env)
      realloc (a, b.env);
    casteljau (a.begin (), b.begin (), v);
  };
void mmx::tensor::casteljau ( bernstein< C > &  left,
bernstein< C > &  right,
const bernstein< C > &  source,
int  v 
)

Definition at line 246 of file tensor_bernstein_fcts.hpp.

References casteljau().

  {
    casteljau (left, right = source, v);
  };
void mmx::tensor::cfdump ( std::ostream &  o,
const bernstein< C > &  mpl 
)

Definition at line 283 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::end().

  {
    for (const C * a = mpl.begin (); a != mpl.end (); o << " " << *a++){}
  };
void mmx::tensor::clear ( monomials< C > &  mpl,
const eenv &  nenv 
) [inline]

Definition at line 90 of file tensor_monomials_fcts.hpp.

References clear(), monomials< C >::env, and monomials< C >::swap().

  {
    if (mpl.env != nenv) {
      monomials < C > tmp (nenv, C (0));
      mpl.swap (tmp);
    } else 
      clear(mpl);
  };
void mmx::tensor::clear ( monomials< C > &  monoms) [inline]

Definition at line 88 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), monomials< C >::end(), and mmx::vct::fill().

Referenced by clear(), conv(), diff(), mcrossp(), mdotp(), mmul(), pmmul(), and spmmul().

{ std::fill(monoms.begin(),monoms.end(),C(0)); };
void mmx::tensor::coefficients ( Seq< U > &  r,
const bernstein< C > &  p,
int  v 
)

Definition at line 84 of file tensor_bernstein.hpp.

                                                                                    {

  }
void mmx::tensor::contraction ( monomials< C > &  f,
const C &  t,
const int &  v 
)

Compute f (a*var[v])

Definition at line 614 of file tensor_monomials_fcts.hpp.

References monomials< C >::data, monomials< C >::nvr(), mmx::pow(), monomials< C >::str(), monomials< C >::szs(), and monomials< C >::vrs().

Referenced by box_rep< POL >::contract_box(), and box_rep< POL >::restrict().

    {
        std::vector<int> ind = std::vector<int>( f.nvr() );
        int s,i,pos =0;
        
        int * vars = f.vrs();
        int * sstr = f.str();
        int * sszs = f.szs();
        
       for (;;) 
       {
           for ( s = 0 ; s < sszs[v]; ++s )
               f.data[sstr[v]*s+pos] *= pow(t,s) ;

           // next row
           for (i = 0; i < f.nvr() ; ++i) 
           {
               if ( vars[i] != v )
               {
                   ind[i] += 1;
                   pos += sstr[i];
               } else continue;

               if (ind[i] < sszs[i])
                   break;
               ind[i] = 0;
               pos -= sszs[i]*sstr[i];
           }
           if (i == f.nvr() )
               break;
       }
   };
void conv ( MPLBASE0 &  r,
const MPLBASE1 &  a 
)

Definition at line 62 of file tensor_convert.hpp.

Referenced by conv(), elevate(), and mul().

                                         { 
    MPLBASE0 tmp;
    r.swap (tmp);
    conv (r, tmp, a);
  };
void mmx::tensor::conv ( MPLBASE0 &  r,
const MPLBASE1 &  a,
const MPLBASE2 &  b 
)

Definition at line 33 of file tensor_convert.hpp.

References clear(), conv(), eenv::mul(), and eenv::oaddress().

  {
    if (&a == &r) { conv (r, b); return; };
    if (&b == &r) { conv (r, a); return; };
    clear (r, eenv::mul (a.env, b.env));

    unsigned *oa = new unsigned[a.esz () + b.esz ()];
    unsigned *ob = oa + a.esz ();

    eenv::oaddress (r.env, oa, a.env);
    eenv::oaddress (r.env, ob, b.env);
    
    typedef typename MPLBASE0::value_type rreal;
    typedef typename MPLBASE1::value_type areal;
    typedef typename MPLBASE2::value_type breal;
    
    unsigned *ea;
    unsigned *eb;
    rreal * pr = r.begin();
    const areal * pa;
    const breal * pb;
    
    for (ea = oa, pa = a.begin (); ea != oa + a.esz (); ea++, pa++)
      for (eb = ob, pb = b.begin (); eb != ob + b.esz ();
           pr[*ea + *eb++] += (*pa) * (*pb++) ) ;
    delete[]oa;
  };
void mmx::tensor::convert ( monomials< C > &  mpl,
const sparse::monomial_seq< C, O > &  imp 
)

Definition at line 393 of file tensor_monomials_fcts.hpp.

  {
    mpl. ~ monomials < C > ();
    new (&mpl) monomials<C>(imp);
  };
void mmx::tensor::convert ( sparse::monomial_seq< C, O > &  pol,
const monomials< C > &  mpl 
)

Definition at line 400 of file tensor_monomials_fcts.hpp.

References add(), monomials< C >::env, eenv::mxvr(), monomials< C >::nvr(), monomials< C >::size(), monomials< C >::szs(), and monomials< C >::vrs().

                                                                       {
    typedef typename sparse::monomial_seq< C, O>::monom_t monom_t;
    typedef typename monom_t::container_t container_t;
    add(pol,C(0));
    container_t tmp (mpl.env.mxvr()+1);
    const int *szs = mpl.szs ();
    const int *vrs = mpl.vrs ();
    for (int i = 0; i < mpl.size(); i++)
      if (mpl[i] != 0)
        {
          int a, v;
          for (a = i, v = mpl.nvr () - 1; a; a /= szs[v], v--)
          tmp[vrs[v]] = a % szs[v];
          add(pol, monom_t (mpl[i], tmp));
        };
  }
UPOL mmx::tensor::convert ( const MPOL &  p,
unsigned  v 
)

Convert a multivariate polynomial to univariate one, formally by substuting all the variables but the variable of index ind by 1.

Definition at line 73 of file tensor_convert.hpp.

References degree(), mmx::N(), mmx::rep(), and slice().

Referenced by mprint().

  {
    unsigned N = degree(p,v)+1;
    UPOL r(N, AsSize());
    for(unsigned i =0; i<N;i++) { slice(r[i].rep(),p.rep(),v,i); }
    return r;
  }
void mmx::tensor::convertb2m ( C *  bzc,
unsigned  sz,
int  st,
binomials< C > &  binom 
) [inline]

Definition at line 240 of file tensor_eenv_loops.hpp.

References mmx::vctops::pmul().

                                                                       {
    int i,k;
    for ( i = st; i != st*int(sz); i += st )
    for ( k = (sz-1)*st; k != i-st; k -= st )
      bzc[k] -= bzc[k-st];
    vct::pmul(bzc,binom[sz-1],sz,st,1);
  };
void mmx::tensor::convertb2m ( C *  data,
const eenv &  e,
binomials< C > &  bins,
int  v 
)

Convert a multivariate polynomial data in the bernstein basis to the tensor basis along the @ variable

Definition at line 289 of file tensor_eenv_loops.hpp.

References convertb2m(), eenv::str(), eenv::sz(), and eenv::szs().

  {
    const int *esz = e.szs ();
    const int *est = e.str ();
    int i, j;
    for (i = 0; i < e.sz (); i += est[v - 1])
      for (j = i; j < i + est[v];
           convertb2m (data + j, esz[v], est[v], bins), j++) ;
  };
void mmx::tensor::convertb2m ( C *  data,
const eenv &  env,
binomials< C > &  bins 
)

Convert a multivariate polynomial data in the bernstein basis to the tensor basis

Definition at line 301 of file tensor_eenv_loops.hpp.

References convertb2m(), and eenv::nvr().

  {
    for (int v = 0; v < env.nvr (); convertb2m (data, env, bins, v++)) ;
  };
void mmx::tensor::convertb2m ( monomials< C > &  mpl) [inline]

Definition at line 26 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::env.

Referenced by assign(), convertb2m(), mmx::flatten(), and print().

                                     { 
    convertb2m (mpl.begin (), mpl.env, binomials < C >::default_); 
  }
void mmx::tensor::convertm2b ( C *  bzc,
unsigned  sz,
int  st,
binomials< C > &  binoms 
) [inline]

Definition at line 250 of file tensor_eenv_loops.hpp.

                                                                        {
    C tmp[sz];
    const C * bin;
    unsigned i,k,p,l;
    
    for ( p = 0, i = 0; i < sz; i++, p += st ) 
      { tmp[i] = bzc[p]; bzc[p] = C(0); };
    for ( p = 0, i = 0; i < sz; i++, p += st )
      for ( bin = binoms[sz-i-1], l = p, k = 0; k < sz-i; k++, l += st )
        bzc[l] += tmp[i]*bin[k];
    bin = binoms[sz-1];
    for ( i = 0, l = 0; i < sz; i ++, l += st  )
      bzc[l] /= bin[i];
  };
void mmx::tensor::convertm2b ( C *  data,
const eenv &  e,
binomials< C > &  bins,
int  v 
)

Convert a multivariate polynomial data in the tensors basis into the bernstein basis along the @ variable.

Definition at line 269 of file tensor_eenv_loops.hpp.

References convertm2b(), eenv::str(), eenv::sz(), and eenv::szs().

  {
    const int *esz = e.szs ();
    const int *est = e.str ();
    int i, j;
    for (i = 0; i < e.sz (); i += est[v - 1])
      for (j = i; j < i + est[v]; convertm2b (data + j, esz[v], est[v], bins), j++) ;
  };
void mmx::tensor::convertm2b ( C *  data,
const eenv &  env,
binomials< C > &  bins 
)

Convert a multivariate polynomial data in the tensors basis into the bernstein basis

Definition at line 280 of file tensor_eenv_loops.hpp.

References convertm2b(), and eenv::nvr().

  {
    for (int v = 0; v < env.nvr (); convertm2b (data, env, bins, v++)) ;
  };
void mmx::tensor::convertm2b ( bernstein< C > &  mpl,
const V &  bx 
) [inline]

Definition at line 36 of file tensor_bernstein_fcts.hpp.

References convertm2b(), and restrict().

                                                 {
    convertm2b (mpl);
    for(unsigned i=0;i<bx.size();i+=2)
      restrict(mpl,i/2,bx[i],bx[i+1]);
  };
void mmx::tensor::convertm2b ( bernstein< C > &  mpl) [inline]

Definition at line 31 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::env.

Referenced by mmx::let::assign(), bernstein< C >::bernstein(), convertm2b(), mmx::realroot::fill_data(), and solver< Ring, Bspline >::first_root().

                                    {
    convertm2b (mpl.begin (), mpl.env, binomials < C >::default_);
  };
void mmx::tensor::decasteljau ( real_t *  r,
unsigned  sz,
const value_t &  t,
int  str = 1 
)

Definition at line 67 of file tensor_eenv_loops.hpp.

Referenced by eval(), and levalb().

  {
    real_t *er, *p;
      for ( er = r + (sz-1)*str; er != r; er -= str )
        for ( p = r; p != er; p += str )
          *p = real_t(value_t(1)-t)* *p+t**(p+str);
  };  
int mmx::tensor::degree ( const monomials< Coeff > &  p,
int  v 
) [inline]

Definition at line 362 of file tensor_monomials_fcts.hpp.

References monomials< C >::env, and eenv::sz().

                                           {
    return p.env.sz(v)-1;
  }
int mmx::tensor::degree ( const bernstein< C > &  p,
int  v 
) [inline]

Definition at line 76 of file tensor_bernstein.hpp.

References degree().

{return degree((const monomials<C>&)p,v);}
int mmx::tensor::degree ( const bernstein< C > &  p) [inline]

Definition at line 73 of file tensor_bernstein.hpp.

Referenced by convert(), and degree().

{return degree((const monomials<C>&)p);}
int mmx::tensor::degree ( const monomials< Coeff > &  p) [inline]

Definition at line 355 of file tensor_monomials_fcts.hpp.

References monomials< C >::env, monomials< C >::nbvar(), and eenv::szs().

                                    {
    int d=0;
    for(int i=0;i<p.nbvar();i++) d+= *(p.env.szs()+i)-1;
    return d;
  }
void mmx::tensor::diff ( monomials< Coeff > &  res,
const monomials< Coeff > &  src,
int  v 
) [inline]

Definition at line 373 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), clear(), eenv::diff(), monomials< C >::env, and mdiff().

                                                                    {
    clear( res, eenv::diff(src.env,v));
    //    mdiff( res.begin(), res.env, src.begin(), src.env, v );
    mdiff( res.begin(), res.env, src.begin(), src.env,  v );
  }
void mmx::tensor::diff ( C *  b,
const C *  a,
unsigned  sz,
int  sb,
int  sa 
) [inline]

Definition at line 311 of file tensor_eenv_loops.hpp.

References assert.

  {
    assert(sa==sb);
    for ( unsigned i = 1; i < sz; i ++ ) { b[(i-1)*sb] = i*a[i]; };
    //    for ( unsigned i = 1, a += sa; i < sz; *b = *a*i++, b += sb, a += sa ) ; 
  };
void mmx::tensor::diff ( C *  b,
C *  e,
C const *  a,
int  s 
) [inline]

Definition at line 319 of file tensor_eenv_loops.hpp.

  { 
    unsigned i;
    for ( i = 1, a += s; b != e; *b = *a*i++, b += s, a += s ) ;
  };
void mmx::tensor::diff ( C *  b,
C *  e,
C const *  a 
) [inline]

Definition at line 326 of file tensor_eenv_loops.hpp.

  { 
    for ( int i = 1; b != e; *b++ = *(++a)*i++ ) ;
  };
void mmx::tensor::diff ( bernstein< C > &  res,
const bernstein< C > &  src,
int  v 
) [inline]

Definition at line 315 of file tensor_bernstein_fcts.hpp.

References bdiff(), monomials< C >::begin(), clear(), eenv::diff(), and monomials< C >::env.

  {
    clear( res, eenv::diff(src.env,v) );
    bdiff( res.begin(), src.env, src.begin(), v );
  };
bernstein<C> mmx::tensor::diff ( const bernstein< C > &  p,
int  v 
)

Definition at line 79 of file tensor_bernstein.hpp.

References Polynomial.

Referenced by m_diff().

  {
    Polynomial dp(p);   diff(dp,p,v);   return dp;
  }
void mmx::tensor::div ( bernstein< C > &  r,
const bernstein< C > &  a,
const C &  c 
) [inline]

Definition at line 178 of file tensor_bernstein_fcts.hpp.

Referenced by div().

                                                               {
  div(r=a,c);
}
void mmx::tensor::div ( monomials< C > &  r,
const C &  c 
)

Definition at line 271 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), monomials< C >::esz(), and mmx::vctops::scdiv().

  {
    vct::scdiv (r.begin (), c, r.esz (), 1);
  };
void mmx::tensor::div ( monomials< C > &  r,
const monomials< C > &  a,
const C &  c 
) [inline]

Definition at line 301 of file tensor_monomials_fcts.hpp.

References div().

                                                                 {
    div(r=a,c);
  }
void mmx::tensor::elevate ( bernstein< C > &  r,
const eenv &  elev 
)

Definition at line 43 of file tensor_bernstein_fcts.hpp.

References binoms(), conv(), scale(), and uscale().

Referenced by rewrite().

  {
    bernstein < C > tmp (elev);
    tensor::binoms (tmp);
    scale (r);
    tensor::conv(r, tmp);
    uscale (r);
  };
void mmx::tensor::eval ( Coeff &  result,
const bernstein< Coeff > &  controls,
const Coeff &  v 
) [inline]

Definition at line 201 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), mmx::sparse::copy(), decasteljau(), monomials< C >::end(), monomials< C >::env, and eenv::sz().

{
  Coeff tmp[controls.env.sz()];
  std::copy (controls.begin(), controls.end(), tmp);
  decasteljau (tmp , controls.env.sz(), v, 1);
  result=tmp[0];
};
void mmx::tensor::eval ( Result &  result,
const bernstein< Coeff > &  controls,
const Parameters &  parameters,
unsigned  n 
) [inline]

Definition at line 210 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), monomials< C >::env, and levalb().

                                                                                                               { 
  //assert(parameters.size()<n);
  levalb( result, controls.begin (), controls.env, parameters ); 
};
void mmx::tensor::eval ( Result &  result,
const bernstein< Coeff > &  controls,
const Parameters &  parameters 
) [inline]

Definition at line 195 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), monomials< C >::env, and levalb().

Referenced by approx().

{
  levalb (result, controls.begin (), controls.env,parameters);
};
void mmx::tensor::eval ( Result &  result,
const monomials< Coeff > &  monoms,
const Parameters &  parameters 
) [inline]

Definition at line 135 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), mmx::upoldse_::horner(), and monomials< C >::size().

  { 
    //    if (monoms.nbvar()==1)
    vct::horner(result, monoms.begin (), monoms.size(), parameters, 1); 
    // levalm( result, monoms.begin (), monoms.env, parameters ); 
  };
void mmx::tensor::eval ( Result &  result,
const monomials< Coeff > &  monoms,
const Parameters &  parameters,
unsigned  n 
) [inline]

Definition at line 142 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), monomials< C >::env, and levalm().

  { 
      //assert(parameters.size()<n);
    levalm( result, monoms.begin (), monoms.env, parameters ); 
  };
void mmx::tensor::extend ( monomials< C > &  mpl,
const eenv &  nenv 
)

Definition at line 161 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), monomials< C >::env, monomials< C >::esz(), mmx::vct::icopy(), eenv::oaddress(), and monomials< C >::swap().

Referenced by add(), and sub().

  {
    if ( mpl.env != nenv )
      {
        unsigned *oadd = new unsigned[mpl.esz ()];
        eenv::oaddress (nenv, oadd, mpl.env, 0, 0);
        monomials < C > tmp (nenv);
        vct::icopy (tmp.begin (), oadd, mpl.esz (), mpl.begin ());
        delete[]oadd;
        mpl.swap (tmp);
      };
  };
void mmx::tensor::face ( monomials< C > &  f,
const monomials< C > &  src,
int  v,
int  n 
) [inline]

Definition at line 454 of file tensor_monomials_fcts.hpp.

References assert, monomials< C >::env, face_env(), lface(), eenv::localv(), realloc(), and rface().

{
  assert(n==0||n==1);
  eenv fenv(face_env(src.env,src.env.localv(v)));
  if ( f.env != fenv ) realloc( f, fenv );
  if ( n ) rface( f, src, src.env.localv(v)  );
  else     lface( f, src, src.env.localv(v)  );
};
void mmx::tensor::face ( polynomial< C, with< Rep, Ord > > &  r,
const polynomial< C, with< Rep, Ord > > &  p,
int  v,
int  f 
)
void mmx::tensor::face ( bernstein< C > &  f,
const bernstein< C > &  src,
int  v,
int  n 
) [inline]

Definition at line 366 of file tensor_bernstein_fcts.hpp.

References assert, monomials< C >::env, face_env(), lface(), eenv::localv(), realloc(), and rface().

{
  assert(n==0||n==1);
  eenv fenv(face_env(src.env,src.env.localv(v)));
  if ( f.env != fenv ) realloc( f, fenv );
  if ( n ) rface( f, src, src.env.localv(v) );
  else     lface( f, src, src.env.localv(v) );
};
eenv mmx::tensor::face_env ( const eenv &  e,
int  lv 
) [inline]

Definition at line 429 of file tensor_monomials_fcts.hpp.

References eenv::nvr(), eenv::szs(), and eenv::vrs().

Referenced by face().

                                              {
  const int * eszs = e.szs();
  const int * evrs = e.vrs();
  const int   envr = e.nvr();
  int szs[ envr ];
  int vrs[ envr ];
  int c = 0;
  for ( int v = 0; v < envr; v ++ ) if ( v != lv ) { szs[c] = eszs[v]; vrs[c++] = evrs[v]; };//evrs[v]; };
  return eenv(c,szs,vrs);
}
void mmx::tensor::heval ( Result &  result,
const monomials< Coeff > &  monoms,
const Parameters &  parameters 
) [inline]

Definition at line 149 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), monomials< C >::env, and hevalm().

Referenced by box_rep< C >::max_eval().

  { 
    hevalm( result, monoms.begin (), monoms.env, parameters ); 
  };
void mmx::tensor::hevalm ( R &  result,
const C *  data,
const eenv &  env,
const P &  p 
)

Definition at line 43 of file tensor_eenv_loops.hpp.

References assign(), mmx::sparse::copy(), mmx::vct::hhorner(), eenv::nvr(), eenv::str(), eenv::sz(), and eenv::szs().

Referenced by heval().

  {
    typedef R result_type;

    // query for the environment information

    const int esz = env.sz ();  // number of coefficients
    const int nvr = env.nvr (); // number of variables 
    const int *szs = env.szs ();        // sizes in each variables
    const int *str = env.str ();        // corresponding strides.

    result_type tmp[env.sz ()],r;   // temporary array used by the inplace evaluation loop
    std::copy (data, data + env.sz (), tmp);
    for (int v = nvr - 1; v >= 0; v--)
      for (int i = 0; i < esz; i += str[v - 1]) {
        vct::hhorner(r,tmp + i, szs[v], p[v+1],p[0],str[v]);
        tmp[i] =  r;
      }

    let::assign(result,tmp[0]);

  };
void mmx::tensor::ibinoms ( C *  data,
const eenv &  env,
binomials< C > &  binms 
)

Definition at line 190 of file tensor_eenv_loops.hpp.

References binoms(), mmx::vct::inverses(), and eenv::sz().

  {
    binoms(data,env,binms);
    vct::inverses(data,data+env.sz());
  };
void mmx::tensor::islice ( monomials< C > &  f,
const monomials< C > &  src,
int  v,
int  i 
) [inline]

Definition at line 465 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), monomials< C >::env, and slice().

Referenced by slice().

  {
    slice( f.begin(), src.env, src.begin(), v );
  }
int mmx::tensor::leading_variable ( const monomials< Coeff > &  p) [inline]

Definition at line 368 of file tensor_monomials_fcts.hpp.

                                              {
    return 0;
  }
void mmx::tensor::levalb ( R &  result,
const C *  data,
const eenv &  env,
const P &  p 
)

Evaluation in bernstein form as ()@

Definition at line 77 of file tensor_eenv_loops.hpp.

References assign(), mmx::sparse::copy(), decasteljau(), eenv::nvr(), eenv::str(), eenv::sz(), and eenv::szs().

Referenced by eval().

  {
    //    typename sup<typename texp::value_type<P>::result_t, C >::T tmp[env.sz()];
    //XXX    typename texp::ringof_ < typename texp::value_type<P>::T,C >::T

    R tmp[env.sz()];

    const int esz  (env.sz ());
    const int nvr  (env.nvr ());
    const int *szs (env.szs ());
    const int *str (env.str ());

    std::copy (data, data + env.sz (), tmp);

    for (int v = nvr - 1; v >= 0; v--)
      for (int i = 0; i < esz; i += str[v - 1])
        decasteljau (tmp + i, szs[v], p[v], str[v]);

    let::assign(result,tmp[0]);
  };
void mmx::tensor::levalm ( R &  result,
const C *  data,
const eenv &  env,
const P &  p 
)

Evaluation by horner scheme of multivariate polynomial data.

Returns:
@ is the result of the evaluation of the coefficients in dense tensor form starting at @ and corresponding to the sizes and ordering of variables represented by @. @ is the parameter array (operator[])supposed to be as large as the number of variables in @.
@ is assumed to be assignable to the Type::Sup value of @ and @. Note that ()@ index of variables are local to @, it's the difference with gevalm.

Definition at line 20 of file tensor_eenv_loops.hpp.

References mmx::sparse::copy(), mmx::upoldse_::horner(), eenv::nvr(), eenv::str(), eenv::sz(), and eenv::szs().

Referenced by eval().

  {
    typedef R result_type;

    // query for the environment information

    const int esz = env.sz ();  // number of coefficients
    const int nvr = env.nvr (); // number of variables 
    const int *szs = env.szs ();        // sizes in each variables
    const int *str = env.str ();        // corresponding strides.

    result_type tmp[env.sz ()], r;      // temporary array used by the inplace evaluation loop
    std::copy (data, data + env.sz (), tmp);
    for (int v = nvr - 1; v >= 0; v--)
      for (int i = 0; i < esz; i += str[v - 1]) {
        vct::horner(r,tmp + i, szs[v], p[v], str[v]);
        tmp[i] =  r;
      }
//    let::assign(result,tmp[0]);
      result= tmp[0];
  };
void mmx::tensor::lface ( monomials< C > &  f,
const monomials< C > &  src,
int  v 
) [inline]

Definition at line 441 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), monomials< C >::env, and lface().

{
  lface( f.begin(), src.env, src.begin(), v );
};
void mmx::tensor::lface ( C *  dst,
const eenv &  a,
const C *  src,
int  v 
)

Definition at line 491 of file tensor_eenv_loops.hpp.

References eenv::str(), and eenv::sz().

  {
    const int   ssz  = a.sz ();
    //    const int * sszs = a.szs();
    const int * sstr = a.str();

    C * ed; const C * es;
    const C * fs;
    for ( ed = dst, es = src; es < src+ssz; es += sstr[v-1] )
      for ( fs = es; fs < es + sstr[v]; *ed++ = *fs++ ) ;
  };
void mmx::tensor::lface ( bernstein< C > &  f,
const bernstein< C > &  src,
int  v 
) [inline]

Definition at line 352 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::env.

Referenced by face(), and lface().

{
  lface( f.begin(), src.env, src.begin(), v );
};
void mmx::tensor::m_diff ( C *  op,
const eenv &  o,
C const *  ap,
const eenv &  a,
int  v 
)

Definition at line 333 of file tensor_eenv_loops.hpp.

References diff(), eenv::st(), and eenv::sz().

  {
    typedef int sz_t;
    sz_t is = 0;
    for ( sz_t i = 0; i < o.sz(); i += o.st(v-1), is += a.st(v-1) )
      for ( sz_t j = 0; j < a.st(v); j ++ )
        diff(op+i+j, ap+is+j,a.sz(v), o.st(v), a.st(v)) ;
  };
void mmx::tensor::maxs ( monomials< C > &  mm,
monomials< C > &  f,
int  v 
)

Definition at line 664 of file tensor_monomials_fcts.hpp.

References monomials< C >::data, monomials< C >::size(), monomials< C >::str(), and monomials< C >::szs().

    {

       int p,k,i,j;
       int * sszs = f.szs() ;
       int * sstr = f.str() ;

       for ( p = 0, k = 0; k < sszs[v]; k++, p += sstr[v] )
        {
            mm.data[k] = f.data[p];
          for ( i = 0; i < f.size(); i += sstr[v-1] )
            for ( j = i; j < i + sstr[v]; j ++ )
              if ( f.data[j+p] > mm[k] ) mm[k] = f.data[j+p];
        }
    }
void mmx::tensor::maxs ( OutputIterator  _maxs_,
const C *  data,
const eenv &  env,
int  v 
)

Definition at line 101 of file tensor_eenv_loops.hpp.

References eenv::str(), and eenv::szs().

  {
    const int *eszs = env.szs ();
    const int *estr = env.str ();
    //    const int envr = env.nvr ();
    int p, k, i; //, j;
    for (p = 0, k = 0; k < eszs[v]; k++, data += estr[v], _maxs_++)
      {
        *_maxs_ = *data;
        for (i = 0; i < estr[-1]; i += estr[v - 1])
          for (const C * edata = data + i; edata < data + i + estr[v]; edata++)
            if (*edata > *_maxs_)
              *_maxs_ = *edata;
      };
  };
void mmx::tensor::mdiff ( C *  dst,
const eenv &  a,
C const *const  src,
const eenv &  esrc,
int  v 
)

Definition at line 343 of file tensor_eenv_loops.hpp.

References mmx::vct::scmul(), eenv::str(), and eenv::sz().

Referenced by diff().

  {
    const int   ssz  = esrc.sz ();
    //    const int * sszs = a.szs();
    const int * sstr = esrc.str();
    int rst = sstr[v-1]-sstr[v];
    unsigned i;
    C * ed, * fd;
    const C * es, * fs;
    for ( ed = dst, es = src; es < src+ssz; ed += rst, es += sstr[v-1] )
      for ( i = 1, fd = ed, fs = es+sstr[v]; fs != es+sstr[v-1]; fd += sstr[v], fs += sstr[v], i ++  )
        vct::scmul(fd,fd+sstr[v],fs,C(i));
  }
void mmx::tensor::mescan ( int &  last,
vd *  vdeg,
const MONOM &  m 
)

Definition at line 400 of file tensor_eenv_fcts.hpp.

References vd::d, mmx::max(), and vd::n.

Referenced by eenv::eenv().

  {
    for (unsigned i = 0; i < m.size (); i++)
      {
        if (m[i] != 0)
          {
            if (vdeg[i].n != -1)
              vdeg[i].d = std::max ((int) m[i], vdeg[i].d);
            else
              {
                if (last != -1)
                  {
                    vdeg[i].n = vdeg[last].n;
                    vdeg[i].d = m[i];
                    vdeg[last].n = i;
                    last = i;
                  }
                else
                  {
                    last = i;
                    vdeg[i].n = i;
                    vdeg[i].d = m[i];
                  };
              };
          };
      };
  }
void mmx::tensor::mins ( monomials< C > &  mm,
monomials< C > &  f,
int  v 
)

Definition at line 648 of file tensor_monomials_fcts.hpp.

References monomials< C >::data, monomials< C >::size(), monomials< C >::str(), and monomials< C >::szs().

     {
        int p,k,i,j;
        int * sszs = f.szs() ;
        int * sstr = f.str() ;

        for ( p = 0, k = 0; k < sszs[v]; k++, p += sstr[v] )
        {
            mm.data[k] = f.data[p];
          for ( i = 0; i < f.size(); i += sstr[v-1] )
            for ( j = i; j < i + sstr[v]; j ++ )
              if ( f.data[j+p] < mm[k] ) mm[k] = f.data[j+p];
        }
     }
void mmx::tensor::mins ( OutputIterator  _mins_,
const C *  data,
const eenv &  env,
int  v 
)

Definition at line 118 of file tensor_eenv_loops.hpp.

References eenv::str(), and eenv::szs().

  {
    const int *eszs = env.szs ();
    const int *estr = env.str ();
    //    const int envr = env.nvr ();
    int p, k, i, j;
    for (p = 0, k = 0; k < eszs[v]; k++, p += estr[v], _mins_++)
      {
        *_mins_ = data[p];
        for (i = 0; i < estr[-1]; i += estr[v - 1])
          for (j = i; j < i + estr[v]; j++)
            if (data[j + p] < *_mins_)
              *_mins_ = data[j + p];
      };
  };
void mmx::tensor::mpolfill ( C *  data,
const sparse::monomial_seq< X, O > &  mpol,
const eenv &  env 
)

Definition at line 536 of file tensor_eenv_loops.hpp.

References assign(), eenv::nvr(), eenv::str(), and eenv::vrs().

Referenced by mmx::realroot::fill_data(), and monomials< C >::monomials().

  {
    const int *vr = env.vrs ();
    const int *st = env.str ();
    const int  nvr = env.nvr();
    typename sparse::monomial_seq<X,O>::const_iterator it;
    C c;
    for (it =mpol.begin (); it != mpol.end (); it++)
      {
        int a = 0;
        for (int v = 0; v < nvr; a += (*it)[vr[v]] * st[v], v++) ;
        let::assign(c,(*it).coeff ());
        data[a] += c;
      };
  }
void mmx::tensor::mprint ( OSTREAM &  o,
const bernstein< C > &  mpl 
)

Definition at line 289 of file tensor_bernstein_fcts.hpp.

References convert().

  {
    monomials < C > mp (0);
    convert (mp, mpl);
    o << mp;
    
  };
void mmx::tensor::mul ( monomials< C > &  r,
const monomials< C > &  a 
)

Definition at line 276 of file tensor_monomials_fcts.hpp.

References conv().

  {
    //    monomials<C> s(r);
    conv(r,a);
  };
void mmx::tensor::mul ( monomials< C > &  a,
const monomials< C > &  b,
const C &  c 
) [inline]

Definition at line 290 of file tensor_monomials_fcts.hpp.

References mul().

  {
    mul (a = b, c);
  };
void mmx::tensor::mul ( monomials< C > &  r,
const C &  c,
const monomials< C > &  a 
) [inline]

Definition at line 296 of file tensor_monomials_fcts.hpp.

References mul().

                                                                 {
    mul(r=a,c);
  };
void mmx::tensor::mul ( monomials< X > &  r,
const monomials< Y > &  a,
const monomials< Z > &  b 
) [inline]

Definition at line 284 of file tensor_monomials_fcts.hpp.

References conv().

  {
    conv(r,a,b);
  };
void mmx::tensor::mul ( bernstein< C > &  r,
const bernstein< C > &  a,
const bernstein< C > &  b 
)

Definition at line 142 of file tensor_bernstein_fcts.hpp.

References conv(), scale(), and uscale().

Referenced by mul().

                                                                             {
  bernstein < C > a_ (a);
  scale (a_);
  bernstein < C > b_ (b);
  scale (b_);
  tensor::conv (r, a_, b_);
  uscale (r);
};
void mmx::tensor::mul ( bernstein< C > &  r,
const bernstein< C > &  a 
)

Definition at line 152 of file tensor_bernstein_fcts.hpp.

References conv(), scale(), monomials< C >::swap(), and uscale().

                                                   {
  bernstein < C > a_;
  r.swap (a_);
  scale (a_);
  bernstein < C > b_ (a);
  scale (b_);
  tensor::conv (r, a_, b_);
  uscale (r);
};
void mmx::tensor::mul ( bernstein< C > &  r,
const bernstein< C > &  a,
const C &  c 
) [inline]

Definition at line 163 of file tensor_bernstein_fcts.hpp.

References mul().

                                                               {
  mul(r=a,c);
};
void mmx::tensor::mul ( bernstein< C > &  r,
const C &  c,
const bernstein< C > &  a 
) [inline]

Definition at line 168 of file tensor_bernstein_fcts.hpp.

References mul().

                                                               {
  mul(r=a,c);
};
void mmx::tensor::mul ( bernstein< C > &  r,
const C &  c 
)

Definition at line 173 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), monomials< C >::esz(), and mmx::vctops::scmul().

                                     {
  vct::scmul(r.begin (),c, r.esz (), 1);
}
void mmx::tensor::mul ( monomials< C > &  r,
const C &  c 
)

Definition at line 266 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), monomials< C >::esz(), and mmx::vctops::scmul().

  {
    vct::scmul (r.begin (), c, r.esz (), 1);
  };
std::ostream& mmx::tensor::operator<< ( std::ostream &  o,
const monomials< C > &  mpl 
)

Definition at line 122 of file tensor_monomials_fcts.hpp.

References print().

  {
    o << "monomials  object:\n";
    o << "\t(addresses) o: " << &mpl << " e: " << mpl.env.data <<  "d: " << mpl.
      begin () << std::endl;
    o << "\t(eenv)" << mpl.env << std::endl;
    o << "\t(data)";
    array::print (o, mpl.data);
    o << std::endl;
    o << ":object monomials\n";
    return o;
  };
std::ostream& mmx::tensor::operator<< ( std::ostream &  o,
const bernstein< C > &  mpl 
)

Definition at line 253 of file tensor_bernstein_fcts.hpp.

References print().

  {
    o << "bernstein object:\n";
    o << "\t(addresses) o: " << &mpl << " e: " << mpl.env.data <<  "d: " << mpl.
      begin () << std::endl;
    o << "\t(eenv)" << mpl.env << std::endl;
    o << "\t(data)";
    array::print (o, mpl.data);
    o << std::endl;
    o << ":object bernstein\n";
    return o;
  };
std::ostream& mmx::tensor::operator<< ( std::ostream &  o,
const vd &  vd_ 
) [inline]

Definition at line 394 of file tensor_eenv_fcts.hpp.

References vd::d, and vd::n.

  {
    o << "vd(" << vd_.n << ", " << vd_.d << ")";
    return o;
  };
std::ostream& mmx::tensor::operator<< ( std::ostream &  out,
const eenv &  env 
) [inline]

Definition at line 325 of file tensor_eenv_fcts.hpp.

References eenv::data, eenv::nvr(), print(), eenv::str(), eenv::sz(), eenv::szs(), and eenv::vrs().

  {
    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;
  };
OSTREAM& mmx::tensor::print ( OSTREAM &  os,
const monomials< C > &  mpl,
const variables &  Var = monom<C>::var 
)

Definition at line 306 of file tensor_monomials_fcts.hpp.

References monomials< C >::env, eenv::mxvr(), monomials< C >::nvr(), print(), monomials< C >::size(), monomials< C >::szs(), mmx::Var(), and monomials< C >::vrs().

                                                                                   { 
    typedef monom<C>             monom_t;
    typedef typename monom<C>::container_t exponent_t;
    exponent_t tmp (mpl.env.mxvr()+1);
    const int *szs = mpl.szs ();
    const int *vrs = mpl.vrs ();
    bool notfirst = false;
    for (int i = 0; i < mpl.size(); i++)
      if (mpl[i] != 0)
        {
          int a, v;
          for (a = i, v = mpl.nvr () - 1; a; a /= szs[v], v--)
            tmp[vrs[v]] = a % szs[v];
          std::ostringstream sm;
          print(sm, monom_t (mpl[i], tmp),Var);
          //bool is_pol = is_polynomial(sm);
         if ( sm.str()[0]!='-' && sm.str()[0]!='+' && notfirst) { 
            os <<'+'; 
          }
          os<<sm.str();
          notfirst=true;
        };
    if(!notfirst) os << "0";
    return os;
  }
void mmx::tensor::print ( OSTREAM &  o,
const bernstein< C > &  mpl 
)

Definition at line 298 of file tensor_bernstein_fcts.hpp.

References convertb2m().

Referenced by operator<<(), and print().

                                               { 
    monomials<C> mp(mpl);
    convertb2m(mp);
    print(o,mp);
  };
void mmx::tensor::print ( OSTREAM &  o,
const bernstein< C > &  mpl,
const variables &  v 
) [inline]

Definition at line 305 of file tensor_bernstein_fcts.hpp.

References print().

                                                                   { 
    print(o,mpl);
  };
void mmx::tensor::print_flatten ( SYNTAX &  out,
const monomials< C > &  mpl,
const variables &  Var = monom<C>::var 
)

Definition at line 333 of file tensor_monomials_fcts.hpp.

References monomials< C >::env, mmx::flatten(), eenv::mxvr(), monomials< C >::nvr(), mmx::pow(), monomials< C >::size(), monomials< C >::szs(), mmx::Var(), and monomials< C >::vrs().

Referenced by mmx::flatten().

                                                                                           { 
    typedef monom<C>             monom_t;
    typedef typename monom<C>::container_t exponent_t;
    exponent_t tmp (mpl.env.mxvr()+1);
    const int *szs = mpl.szs ();
    const int *vrs = mpl.vrs ();
    for (int i = 0; i < mpl.size(); i++)
      if (mpl[i] != 0)
        {
          int a, v;
          for (a = i, v = mpl.nvr () - 1; a; a /= szs[v], v--)
            tmp[vrs[v]] = a % szs[v];

          SYNTAX m = flatten(mpl[i]);
          for(int i=0;i<mpl.env.mxvr()+1;i++)
            m = m * pow(SYNTAX(Var[i].data()),flatten(tmp[i]));
          out+=m;             
        }
  }
void mmx::tensor::realloc ( monomials< C > &  mpl,
const eenv &  nenv 
)

Definition at line 78 of file tensor_monomials_fcts.hpp.

References monomials< C >::env, eenv::equal(), and monomials< C >::swap().

Referenced by add(), casteljau(), face(), slice(), split(), and sub().

  {
    if (!eenv::equal (mpl.env, nenv ))
      {
        monomials< C > tmp (nenv);
        mpl.swap (tmp);
      };
  };
void mmx::tensor::reciprocal ( monomials< C > &  f,
const int &  v 
)

Compute f (1/var[v])

Definition at line 578 of file tensor_monomials_fcts.hpp.

References monomials< C >::data, monomials< C >::nvr(), monomials< C >::str(), mmx::sparse::swap(), monomials< C >::szs(), and monomials< C >::vrs().

   {
       std::vector<int> ind = std::vector<int>( f.nvr() );
       int s,i,pos =0;

        int * vars = f.vrs();
        int * sstr = f.str();
        int * sszs = f.szs();
        int l= sszs[v]-1;
       
       for (;;) 
       {
           for ( s = 0 ; s <= l/2; s++ )
               std::swap(f.data[sstr[v]*s+pos], f.data[sstr[v]*(l-s)+pos] );

           // next row
           for (i = 0; i < f.nvr() ; ++i) 
           {
               if ( vars[i] != v )
               {
                   ind[i] += 1;
                   pos += sstr[i];
               } else continue;

               if (ind[i] < sszs[i])
                   break;
               ind[i] = 0;
               pos -= sszs[i]*sstr[i];
           }
           if (i == f.nvr() )
               break;
       }
   }
void mmx::tensor::rename_var ( monomials< C > &  f,
const int &  v,
const int &  n 
)

Definition at line 682 of file tensor_monomials_fcts.hpp.

References monomials< C >::nvr(), and monomials< C >::vrs().

Referenced by box_rep< POL >::lface(), and box_rep< POL >::rface().

    {
        int * vr = f.vrs();
        
        for (int i=0; i< f.nvr(); ++i)
            if (vr[i]==v) { 
                vr[i]=n;
                break; }
    }
void mmx::tensor::restrict ( bernstein< C > &  rst,
int  v,
const T &  a,
const T &  b 
)

Definition at line 345 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), brestrict(), monomials< C >::env, eenv::nvr(), and eenv::vridx().

Referenced by box_rep< C >::box_rep(), convertm2b(), and polynomial< C, with< Rep, Ord > >::polynomial().

                                                                    { 
    v = rst.env.vridx(v);
    if (v < rst.env.nvr())
      brestrict( rst.begin(), rst.env, v, a, b ); 
  };
void mmx::tensor::rewrite ( bernstein< C > &  r,
const eenv &  newe 
)

Definition at line 73 of file tensor_bernstein_fcts.hpp.

References elevate(), eenv::elevation(), and monomials< C >::env.

Referenced by add(), and sub().

  {
    if ( newe == r.env ) return;
    eenv elenv = eenv::elevation (newe, r.env);
    elevate (r, elenv) ;
  };
void mmx::tensor::rface ( C *  dst,
const eenv &  a,
const C *  src,
int  v 
)

Definition at line 504 of file tensor_eenv_loops.hpp.

References eenv::str(), and eenv::sz().

  {
    const int   ssz  = a.sz ();
    //    const int * sszs = a.szs();
    const int * sstr = a.str();

    C * ed; const C * es;
    const C * fs;
    es = src +  sstr[v-1]-sstr[v];
    for ( ed = dst; es < src+ssz; es += sstr[v-1] )
      {
        for ( fs = es; fs < es + sstr[v]; *ed++ = *fs++ ) ;
      };
  };
void mmx::tensor::rface ( bernstein< C > &  f,
const bernstein< C > &  src,
int  v 
) [inline]

Definition at line 359 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::env.

Referenced by face(), and rface().

{
  rface( f.begin(), src.env, src.begin(), v );
};
void mmx::tensor::rface ( monomials< C > &  f,
const monomials< C > &  src,
int  v 
) [inline]

Definition at line 447 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), monomials< C >::env, and rface().

{
  rface( f.begin(), src.env, src.begin(), v );
};
void mmx::tensor::scadd ( MPLBASE &  r,
const MPLBASE1 &  a,
const C &  c 
)

Definition at line 21 of file tensor_convert.hpp.

References scadd().

  {
    if (r.env != a.env) 
      scadd (r = a, c);
    else 
      vct::scadd (r.begin (), a.begin (), c, r.esz ());
  };
void mmx::tensor::scadd ( MPLBASE &  mpl,
const C &  c 
)

Definition at line 15 of file tensor_convert.hpp.

Referenced by add(), and scadd().

  {
    vct::scadd (mpl.begin (), c, mpl.esz (), 1);
  };
void mmx::tensor::scale ( bernstein< C > &  mpl) [inline]

Definition at line 14 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::env.

Referenced by elevate(), and mul().

  {
   scale (mpl.begin (), mpl.env, binomials < C >::default_);
  };
void mmx::tensor::scale ( C *  data,
const eenv &  env,
binomials< C > &  binoms 
)

Convert a multivariate polynomial data in the bernstein basis to the scaled bernstein basis.

Definition at line 198 of file tensor_eenv_loops.hpp.

References eenv::nvr(), mmx::vct::pmul(), mmx::vctops::pmul(), eenv::str(), eenv::sz(), and eenv::szs().

  {
    const int *estr = env.str ();
    const int *eszs = env.szs ();
    const int  envr = env.nvr ();
    const int  esz  = env.sz ();
    const C *  bins = binoms[eszs[envr - 1] - 1];
    
    for (C *  pdata = data; pdata < data + esz; vct::pmul (pdata, bins, eszs[envr - 1]), pdata += estr[envr - 2]) ;
    
    for (int v = 0; v < envr - 1; v++)
      {
        bins = binoms[eszs[v] - 1];
        //      int k = 0;
        for (int i = 0; i < esz; i += estr[v - 1])
          for (int j = 0; j < estr[v]; j++)
            vct::pmul (data + i + j, bins, eszs[v], estr[v], 1);
      };
  };
void mmx::tensor::set_variable ( monomials< C > &  f,
t,
int  v 
)

Compute f (x_v=t)

Definition at line 535 of file tensor_monomials_fcts.hpp.

References monomials< C >::data, monomials< C >::nvr(), monomials< C >::str(), monomials< C >::szs(), and monomials< C >::vrs().

    {
       std::vector<int> ind = std::vector<int>( f.nvr() );
       int k, i, pos =0;

        int * vars = f.vrs();
        int * sstr = f.str();
        int * sszs = f.szs() ;
        C tmp;
       
       for (;;) 
       {
           tmp=0;
           for( k = sszs[v]-1; k !=-1; --k )
           { 
               tmp *= t;
               tmp += f.data[sstr[v]*k + pos];
               f.data[sstr[v]*k + pos] = 0 ;
           }
           f.data[pos]=tmp;
           
           /* next row */
           for (i = 0; i < f.nvr() ; ++i) 
           {
               if ( vars[i] != v )
               {
                   ind[i] += 1;
                   pos += sstr[i];
               } else continue;

               if (ind[i] < sszs[i])
                   break;
               ind[i] = 0;
               pos -= sszs[i]*sstr[i];
           }
           if (i == f.nvr() )
               break;
       }
   }
void mmx::tensor::shift ( monomials< C > &  f,
const C &  t,
const int &  v 
)

Compute f (var[v]+t)

Definition at line 498 of file tensor_monomials_fcts.hpp.

References monomials< C >::data, monomials< C >::nvr(), monomials< C >::str(), monomials< C >::szs(), and monomials< C >::vrs().

   {
       std::vector<int> ind = std::vector<int>( f.nvr() );
       int s,k,j, i,pos =0;

        int * vars = f.vrs();
        int * sstr = f.str();
        int * sszs = f.szs() ;
       
       for (;;) 
       {
           for ( s = sszs[v], j = 0; j <= s-2; j++ )
               for( k = s-2; k >= j; k-- ) 
                   f.data[sstr[v]*k+ pos ] += 
                   t*f.data[ sstr[v]*(1+k)+ pos ];

           /* next row */
           for (i = 0; i < f.nvr() ; ++i) 
           {
               if ( vars[i] != v )
               {
                   ind[i] += 1;
                   pos += sstr[i];
               } else continue;

               if (ind[i] < sszs[i])
                   break;
               ind[i] = 0;
               pos -= sszs[i]*sstr[i];
           }
           if (i == f.nvr() )
               break;
       }
   }
unsigned mmx::tensor::size ( const bernstein< C > &  p) [inline]

Definition at line 70 of file tensor_bernstein.hpp.

References monomials< C >::size().

{return p.size();}
void mmx::tensor::slice ( C *  dst,
const eenv &  a,
const C *  src,
int  v,
int  n 
)

Definition at line 520 of file tensor_eenv_loops.hpp.

References eenv::str(), and eenv::sz().

Referenced by convert(), islice(), and slice().

  {
    const int   ssz  = a.sz ();
    const int * sstr = a.str();

    C * ed; const C * es;
    const C * fs;
    es = src +  sstr[v-1]-sstr[v];
    for ( ed = dst; es < src+ssz; es += sstr[v-1] )
      {
        //      fs = es + sstr[v-1] - sstr[v];
        for ( fs = es; fs < es + sstr[v]; *ed++ = *fs++ ) ;
      };
  };
void mmx::tensor::slice ( monomials< C > &  f,
const monomials< C > &  src,
int  v,
int  n 
) [inline]

Definition at line 471 of file tensor_monomials_fcts.hpp.

References assert, monomials< C >::env, islice(), eenv::localv(), realloc(), and slice().

  {
    assert(n==0||n==1);
    eenv fenv(slice(src.env,src.env.localv(v)));
    if ( f.env != fenv ) realloc( f, fenv );
    islice( f, src, src.env.localv(v),n);
  }
void mmx::tensor::split ( bernstein< C > &  l,
bernstein< C > &  r,
int  v 
) [inline]

Definition at line 338 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), bsplit2(), monomials< C >::env, eenv::localv(), and realloc().

  {
    if ( l.env != r.env ) { realloc(l,r.env); };
    bsplit2( l.begin(), r.begin(), r.env, r.env.localv(v) );
  };
void mmx::tensor::split ( bernstein< C > &  l,
bernstein< C > &  r,
int  v,
const T &  t 
)

Definition at line 330 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), bsplit(), monomials< C >::env, eenv::localv(), and realloc().

  {
    if ( l.env != r.env ) { realloc(l,r.env); };
    bsplit( l.begin(), r.begin(), r.env, t, r.env.localv(v) );
  };
void mmx::tensor::split ( polynomial< C, with< Rep, Ord > > &  r,
polynomial< C, with< Rep, Ord > > &  p,
int  v 
) [inline]

Definition at line 187 of file polynomial_fcts.hpp.

Referenced by mv_binary_approx::subdivide(), and binary_approx::subdivide().

                                             {
    split(r.rep(),p.rep(),v); 
  }
void mmx::tensor::sub ( bernstein< C > &  mpl,
const bernstein< C > &  a,
const C &  c 
)

Definition at line 137 of file tensor_bernstein_fcts.hpp.

References add().

                                                                 {
  add(mpl,a,-c);
}
void mmx::tensor::sub ( bernstein< C > &  mpl,
const C &  c 
)

Definition at line 127 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), monomials< C >::esz(), and mmx::vctops::scsub().

                                        {
  vct::scsub (mpl.begin (), c, mpl.esz (), 1);
}
void mmx::tensor::sub ( monomials< X > &  r,
const monomials< Y > &  a 
) [inline]

Definition at line 249 of file tensor_monomials_fcts.hpp.

References eenv::common(), monomials< C >::env, extend(), and wsubm().

  {
    extend (r, eenv::common (r.env, a.env)), wsubm (r, a);
  }
void mmx::tensor::sub ( monomials< C > &  mpl,
const C &  c,
const monomials< C > &  a 
) [inline]

Definition at line 235 of file tensor_monomials_fcts.hpp.

References add().

                                                                    {
    add(mpl,a,-c);
  }
void mmx::tensor::sub ( monomials< C > &  a,
const X &  x 
) [inline]

Definition at line 261 of file tensor_monomials_fcts.hpp.

  {
    a[0] -= (C)x;
  }
void mmx::tensor::sub ( bernstein< C > &  mpl,
const C &  c,
const bernstein< C > &  a 
)

Definition at line 132 of file tensor_bernstein_fcts.hpp.

References add().

                                                                  {
  add(mpl,a,-c);
}
void mmx::tensor::sub ( bernstein< C > &  r,
const bernstein< C > &  a 
)

Definition at line 105 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), eenv::common(), monomials< C >::env, monomials< C >::esz(), mmx::vctops::psub(), and rewrite().

Referenced by sub().

                                                   {
  eenv cm(eenv::common(r.env,a.env));
  if ( r.env != cm ) { rewrite(r,cm); };
  if ( a.env == cm ) 
    {
      vct::psub (r.begin (), a.begin (), r.esz (), 1, 1); 
    }
  else 
    {
      bernstein<C> tmp(a);
      rewrite(tmp,cm);
      vct::psub (r.begin (), tmp.begin (), r.esz (), 1, 1);
    };
}
void mmx::tensor::sub ( monomials< X > &  r,
const monomials< X > &  a,
const C &  c 
) [inline]

Definition at line 256 of file tensor_monomials_fcts.hpp.

References sub().

  {
    r=a;sub(r,c);
  }
void mmx::tensor::sub ( bernstein< C > &  r,
const bernstein< C > &  a,
const bernstein< C > &  b 
)

Definition at line 122 of file tensor_bernstein_fcts.hpp.

References sub().

                                                                             {
  sub (r = a, b);
}
void mmx::tensor::sub ( monomials< C > &  r,
const monomials< C > &  a,
const monomials< C > &  b 
) [inline]

Definition at line 221 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), eenv::common(), monomials< C >::env, monomials< C >::esz(), mmx::vct::icopy(), mmx::vct::ipsub(), mmx::max(), eenv::oaddress(), realloc(), and sub().

  {
    if ( &r == &a  ) {  sub(r,b);  return;  };
    if ( &r == &b  ) {  monomials<C> tmp = b; sub(r,a,tmp); return; };
    
    realloc(r,eenv::common(a.env,b.env));
    unsigned *oadd = new unsigned[std::max(a.esz (),b.esz())];
    eenv::oaddress (r.env, oadd,a.env, 0, 0);
    vct::icopy(r.begin(),oadd,a.esz(),a.begin());
    eenv::oaddress(r.env,oadd,b.env,0,0);
    vct::ipsub (r.begin (), oadd,b.esz (), b.begin ());
  };
void mmx::tensor::subs0 ( Result *  result,
const monomials< Coeff > &  monoms,
const Parameters &  parameters 
) [inline]

Definition at line 155 of file tensor_monomials_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::env.

  { 
    subs0m( result, monoms.begin (), monoms.env, parameters ); 
  };
void mmx::tensor::subs0 ( Result *  result,
const bernstein< Coeff > &  controls,
const Parameters &  parameters 
) [inline]

Definition at line 216 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::env.

{ 
  subs0b( result, controls.begin (), controls.env, parameters ); 
};
void mmx::tensor::uscale ( C *  data,
const eenv &  env,
binomials< C > &  binoms 
)

Convert a multivariate polynomial data in the scaled bernstein basis to the bernstein basis

Definition at line 220 of file tensor_eenv_loops.hpp.

References eenv::nvr(), mmx::vct::pdiv(), eenv::str(), eenv::sz(), and eenv::szs().

  {
    const int *estr = env.str ();
    const int *eszs = env.szs ();
    const int envr = env.nvr ();
    const int esz = env.sz ();
    const C *bins = binoms[eszs[envr - 1] - 1];
    for (C * pdata = data; pdata < data + esz; pdata += estr[envr - 2])
      vct::pdiv (pdata, bins, eszs[envr - 1]);
    for (int v = 0; v < envr - 1; v++)
      {
        bins = binoms[eszs[v] - 1];
        //      int k = 0;
        for (int i = 0; i < esz; i += estr[v - 1])
          for (int j = 0; j < estr[v]; j++)
            vct::pdiv (data + i + j, bins, eszs[v], estr[v], 1);
      };
  };
void mmx::tensor::uscale ( bernstein< C > &  mpl) [inline]

Definition at line 20 of file tensor_bernstein_fcts.hpp.

References monomials< C >::begin(), and monomials< C >::env.

Referenced by elevate(), and mul().

  {
    uscale (mpl.begin (), mpl.env, binomials < C >::default_);
  };
bool mmx::tensor::varindex ( int &  lv,
const monomials< C > &  mpl,
int  gv 
)

Definition at line 100 of file tensor_monomials_fcts.hpp.

References monomials< C >::env, and eenv::hasvar().

  {
    return mpl.env.hasvar (lv, gv);
  }
void mmx::tensor::vswap ( C *  data,
const eenv &  env,
int *  perm,
int *  supp = 0,
int  nsupp = 0 
)

Definition at line 137 of file tensor_eenv_loops.hpp.

References eenv::nvr(), eenv::str(), mmx::sparse::swap(), eenv::szs(), and eenv::vswap().

  {
    const int *szs = env.szs ();
    const int *str = env.str ();
    int ostr[env.nvr ()];
    int i;
    for (i = env.nvr () - 2, str[env.nvr () - 1] = 1; i >= -1;
         ostr[i] = szs[perm[i + 1]] * str[i + 1], i--) ;
    if (supp == 0)
      {
        int a, o, v;
        for (i = 0; i < env.esz (); i++)
          {
            for (a = i, v = env.nvr () - 1; a; a /= szs[v], v--)
              o += (a % szs[v]) * ostr[perm[v]];
            std::swap (data[i], data[o]) ;
          };
      }
    else
      {
        int a, o, v;
        for (i = 0; i < nsupp; supp[i++] = o)
          {
            for (a = supp[i], v = env.nvr () - 1; a; a /= szs[v], v--)
              o += (a % szs[v]) * ostr[perm[v]];
            std::swap (data[i], data[o]);
          };
      };
    env.vswap (perm);
  };
void mmx::tensor::waddm ( monomials< X > &  mpla,
const monomials< Y > &  mplb 
)

Definition at line 176 of file tensor_monomials_fcts.hpp.

References assert, monomials< C >::begin(), monomials< C >::env, monomials< C >::esz(), mmx::vct::ipadd(), eenv::oaddress(), and eenv::subset().

Referenced by add().

  {
    assert (eenv::subset (mplb.env, mpla.env));
    unsigned *oadd = new unsigned[mplb.esz ()];
    eenv::oaddress (mpla.env, oadd, mplb.env, 0, 0);
    vct::ipadd (mpla.begin (), oadd, mplb.esz (), mplb.begin ());
    delete[]oadd;
  };
void mmx::tensor::wsubm ( monomials< X > &  mpla,
const monomials< Y > &  mplb 
)

Definition at line 239 of file tensor_monomials_fcts.hpp.

References assert, monomials< C >::begin(), monomials< C >::env, monomials< C >::esz(), mmx::vct::ipsub(), eenv::oaddress(), and eenv::subset().

Referenced by sub().

  {
    assert (eenv::subset (mplb.env, mpla.env));
    unsigned *oadd = new unsigned[mplb.esz ()];
    eenv::oaddress (mpla.env, oadd, mplb.env, 0, 0);
    vct::ipsub (mpla.begin (), oadd, mplb.esz (), mplb.begin ());
    delete[]oadd;
  };