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 ( monomials< C > &  r,
const monomials< C > &  a,
const monomials< C > &  b 
) [inline]

Definition at line 207 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().

00208   {
00209     if ( &r == &a  ) {  add(r,b);  return;  };
00210     if ( &r  == &b ) {  add(r,a); return; };
00211     realloc(r,eenv::common(a.env,b.env));
00212     unsigned *oadd = new unsigned[std::max(a.esz (),b.esz())];
00213     eenv::oaddress (r.env, oadd,a.env, 0, 0);
00214     vct::icopy(r.begin(),oadd,a.esz(),a.begin());
00215     eenv::oaddress(r.env,oadd,b.env,0,0);
00216     vct::ipadd (r.begin (), oadd,b.esz (), b.begin ());
00217   };

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

Definition at line 200 of file tensor_monomials_fcts.hpp.

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

00201   {
00202     extend (r, eenv::common (r.env, a.env));
00203     waddm (r, a);
00204   }

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

Definition at line 195 of file tensor_monomials_fcts.hpp.

References add().

00195                                                                   {
00196     add(r,a,c);
00197   }

void mmx::tensor::add ( monomials< C > &  a,
const C &  x 
) [inline]

Definition at line 190 of file tensor_monomials_fcts.hpp.

00190                                         {
00191     a[0] += x;
00192   }

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

Definition at line 185 of file tensor_monomials_fcts.hpp.

References add().

00185                                                                   {
00186     add(r=a,c);
00187   }

void mmx::tensor::add ( bernstein< C > &  r,
const bernstein< C > &  a,
const bernstein< C > &  b 
) [inline]

Definition at line 99 of file tensor_bernstein_fcts.hpp.

References add().

00099                                                                              {
00100   add (r=a, b);
00101 }

void mmx::tensor::add ( bernstein< C > &  r,
const bernstein< C > &  a 
) [inline]

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().

00082   {
00083     eenv cm(eenv::common(r.env,a.env));
00084     if ( r.env != cm ) { rewrite(r,cm); };
00085     if ( a.env == cm ) 
00086       {
00087         vct::padd (r.begin (), a.begin (), r.esz (), 1, 1); 
00088       }
00089     else 
00090       {
00091         bernstein<C> tmp(a);
00092         rewrite(tmp,cm);
00093         vct::padd (r.begin (), tmp.begin (), r.esz (), 1, 1);
00094       };
00095   };

void mmx::tensor::add ( bernstein< C > &  r,
const C &  c,
const bernstein< C > &  a 
) [inline]

Definition at line 68 of file tensor_bernstein_fcts.hpp.

References add().

00068                                                                   {
00069     add(r,a,c);
00070   }

void mmx::tensor::add ( bernstein< C > &  r,
const bernstein< C > &  a,
const C &  c 
) [inline]

Definition at line 59 of file tensor_bernstein_fcts.hpp.

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

00060   {
00061     if (r.env != a.env)
00062       add (r = a, c);
00063     else
00064       vct::scadd (r.begin (), a.begin (), c, r.esz (), 1);
00065   };

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

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().

00054   {
00055     vct::scadd (mpl.begin (), c, mpl.esz (), 1);
00056   };

void mmx::tensor::assign ( monomials< C > &  monoms,
const bernstein< C > &  controls 
) [inline]

Definition at line 267 of file tensor_bernstein_fcts.hpp.

References convertb2m().

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

00268   {
00269     monoms = controls;
00270     tensor::convertb2m(monoms);
00271   };

static void mmx::tensor::bdiff ( C *  dst,
const eenv &  a,
C const *const   src,
int  v 
) [inline, static]

Definition at line 368 of file tensor_eenv_loops.hpp.

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

Referenced by diff().

00369   {
00370     const int   ssz  = a.sz ();
00371     const int * sszs = a.szs();
00372     const int * sstr = a.str();
00373     int rst = sstr[v-1]-sstr[v];
00374     //    unsigned i;
00375     C * ed; const C * es;
00376     for ( ed = dst, es = src; es < src+ssz; ed += rst, es += sstr[v-1] )
00377       {
00378         C * fd; const C * fs;
00379         for ( fs = es, fd = ed; fs < es + sstr[v]; fs++, fd ++ )
00380           {
00381             C * dp; const C * p;
00382             for ( p = fs, dp = fd; p < fs+rst; p += sstr[v], dp += sstr[v] )
00383               *dp = (*(p+sstr[v])-*p)*(sszs[v]-1);
00384           };
00385       };
00386   }

void mmx::tensor::binoms ( C *  data,
const eenv &  env,
binomials< C > &  binms 
) [inline]

Definition at line 178 of file tensor_eenv_loops.hpp.

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

00179   {
00180     const int *estr = env.str ();
00181     const int *eszs = env.szs ();
00182     const int envr = env.nvr ();
00183     const int esz = env.sz ();
00184     const C *bins = binms[eszs[envr - 1] - 1];
00185     for (C * pdata = data; pdata < data + esz; pdata += estr[envr - 2])
00186       vct::copy (pdata, bins, eszs[envr - 1]);
00187     for (int v = 0; v < envr - 1; v++)
00188       {
00189         bins = binms[eszs[v] - 1];
00190         //      int k = 0;
00191         for (int i = 0; i < esz; i += estr[v - 1])
00192           for (int j = 0; j < estr[v]; j++)
00193             vct::pmul (data + i + j, bins, eszs[v], estr[v], 1);
00194       };
00195   };

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().

00009                               {
00010     binoms( mpl.begin(), mpl.env, binomials<C>::default_ ) ;
00011   }

void mmx::tensor::brestrict ( C *  src,
const eenv &  env,
int  v,
const T &  a,
const T &  b 
) [inline]

Definition at line 492 of file tensor_eenv_loops.hpp.

References brestrictLR().

Referenced by restrict().

00493   {
00494     brestrictLR   ( src, env, v, T(1-a), a, T((b-a)/(T(1)-a)), T((T(1)-b)/(T(1)-a)) );
00495   };

void mmx::tensor::brestrict_uloop ( C *  r,
C *  rlast,
int  st,
const T &  a,
const T &  b 
) [inline]

Definition at line 446 of file tensor_eenv_loops.hpp.

References C.

Referenced by brestrictLR(), and brestrictRL().

00447   {
00448     C * er, * p;
00449     for ( er = rlast - st ; er != r; er -= st )
00450       for ( p = r; p != er; p += st )
00451         *p = (a**p+b**(p+st));
00452   };

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 457 of file tensor_eenv_loops.hpp.

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

Referenced by brestrict().

00458   {
00459     //    std::cout << a << " " << b << std::endl;
00460     //    std::cout << c << " " << d << std::endl;
00461     //    const int *sszs = env.szs ();
00462     const int *sstr = env.str ();
00463     //    int i, j, k;
00464     for ( C * es = s; es != s + sstr[-1]; es += sstr[v-1] )
00465       for ( C * fs = es; fs != es + sstr[v]; fs ++ )
00466         {
00467           brestrict_uloop(fs,fs+sstr[v-1],sstr[v],a,b);
00468           brestrict_uloop(fs+sstr[v-1]-sstr[v],fs-sstr[v],-sstr[v],c,d);
00469         };
00470   };

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 473 of file tensor_eenv_loops.hpp.

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

00474   {
00475     //    std::cout << a << " " << b << std::endl;
00476     //    std::cout << c << " " << d << std::endl;
00477    
00478     
00479 
00480     //    const int *sszs = env.szs ();
00481     const int *sstr = env.str ();
00482     //    int i, j, k;
00483     for ( C * es = s; es != s + sstr[-1]; es += sstr[v-1] )
00484       for ( C * fs = es; fs != es + sstr[v]; fs ++ )
00485         {
00486           brestrict_uloop(fs+sstr[v-1]-sstr[v],fs-sstr[v],-sstr[v],c,d);        
00487           brestrict_uloop(fs,fs+sstr[v-1],sstr[v],a,b);
00488         };
00489   };

void mmx::tensor::bsplit ( C *  l,
C *  r,
const eenv &  env,
const T &  t,
int  v 
) [inline]

Definition at line 402 of file tensor_eenv_loops.hpp.

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

Referenced by split().

00403   {
00404     //  const int *sszs = env.szs ();
00405     const int *sstr = env.str ();
00406     //  int i, j, k;
00407     C *er,*el;
00408     for ( el = l, er = r; el != l + sstr[-1]; el += sstr[v-1], er += sstr[v-1] )
00409       {
00410         C *fr,*fl;
00411         for ( fl = el, fr = er; fl != el + sstr[v]; fl++, fr++ )
00412           bsplit_uloop(fr,fr+sstr[v-1],fl,t,sstr[v]) ;
00413       };
00414   };

void mmx::tensor::bsplit2 ( C *  l,
C *  r,
const eenv &  env,
int  v 
) [inline]

Definition at line 431 of file tensor_eenv_loops.hpp.

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

Referenced by split().

00432   {
00433     //    const int *sszs = env.szs ();
00434     const int *sstr = env.str ();
00435     C *er,*el;
00436     for ( el = l, er = r; el != l + sstr[-1]; el += sstr[v-1], er += sstr[v-1] )
00437       {
00438         C *fr,*fl;
00439         for ( fl = el, fr = er; fl != el + sstr[v]; fl++, fr++ )
00440           bsplit2_uloop(fr,fr+sstr[v-1],fl,sstr[v]);
00441       };
00442   };

void mmx::tensor::bsplit2_uloop ( C *  r,
C *  rlast,
C *  l,
int  st 
) [inline]

Definition at line 418 of file tensor_eenv_loops.hpp.

References C.

Referenced by bsplit2().

00419   {
00420     C * er, * p;
00421     for ( er = rlast - st ; er != r; er -= st, l += st )
00422       {
00423         *l = *r;
00424         for ( p = r; p != er; p += st )
00425           *p = (*p+*(p+st))/C(2);
00426       };
00427     *l = *r;
00428   };

void mmx::tensor::bsplit_uloop ( C *  r,
C *  rlast,
C *  l,
const T &  t,
int  st 
) [inline]

Definition at line 389 of file tensor_eenv_loops.hpp.

References C.

Referenced by bsplit().

00390   {
00391     C * er, * p;
00392     for ( er = rlast - st ; er != r; er -= st, l += st )
00393       {
00394         *l = *r;
00395         for ( p = r; p != er; p += st )
00396           *p = (1.0-t)**p+t**(p+st);
00397       };
00398     *l = *r;
00399   };

void mmx::tensor::casteljau ( bernstein< C > &  left,
bernstein< C > &  right,
const bernstein< C > &  source,
int  v 
) [inline]

Definition at line 246 of file tensor_bernstein_fcts.hpp.

References casteljau().

00248   {
00249     casteljau (left, right = source, v);
00250   };

void mmx::tensor::casteljau ( bernstein< C > &  a,
bernstein< C > &  b,
int  v 
) [inline]

Definition at line 238 of file tensor_bernstein_fcts.hpp.

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

00239   {
00240     if (a.env != b.env)
00241       realloc (a, b.env);
00242     casteljau (a.begin (), b.begin (), v);
00243   };

void mmx::tensor::casteljau ( bernstein< C > &  left,
bernstein< C > &  right,
const bernstein< C > &  source,
const C &  t,
int  v 
) [inline]

Definition at line 230 of file tensor_bernstein_fcts.hpp.

References casteljau().

00232 {
00233   casteljau (left, right = source, t, v);
00234 };

void mmx::tensor::casteljau ( bernstein< C > &  a,
bernstein< C > &  b,
const C &  t,
int  v 
) [inline]

Definition at line 222 of file tensor_bernstein_fcts.hpp.

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

Referenced by casteljau().

00223 {
00224   if (a.env != b.env)
00225     realloc (a, b.env);
00226   casteljau (a.begin (), b.begin (), t, v);
00227 };

void mmx::tensor::cfdump ( std::ostream &  o,
const bernstein< C > &  mpl 
) [inline]

Definition at line 283 of file tensor_bernstein_fcts.hpp.

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

00284   {
00285     for (const C * a = mpl.begin (); a != mpl.end (); o << " " << *a++){}
00286   };

void mmx::tensor::clear ( monomials< C > &  mpl,
const eenv &  nenv 
) [inline]

Definition at line 89 of file tensor_monomials_fcts.hpp.

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

00090   {
00091     if (mpl.env != nenv) {
00092       monomials < C > tmp (nenv, C (0));
00093       mpl.swap (tmp);
00094     } else 
00095       clear(mpl);
00096   };

void mmx::tensor::clear ( monomials< C > &  monoms  )  [inline]

Definition at line 87 of file tensor_monomials_fcts.hpp.

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

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

00087 { std::fill(monoms.begin(),monoms.end(),C(0)); };

void mmx::tensor::coefficients ( Seq< U > &  r,
const bernstein< C > &  p,
int  v 
) [inline]

Definition at line 84 of file tensor_bernstein.hpp.

00084                                                                                     {
00085 
00086   }

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

Compute f (a*var[v]).

Definition at line 613 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().

00614     {
00615         std::vector<int> ind = std::vector<int>( f.nvr() );
00616         int s,i,pos =0;
00617         
00618         int * vars = f.vrs();
00619         int * sstr = f.str();
00620         int * sszs = f.szs();
00621         
00622        for (;;) 
00623        {
00624            for ( s = 0 ; s < sszs[v]; ++s )
00625                f.data[sstr[v]*s+pos] *= pow(t,s) ;
00626 
00627            // next row
00628            for (i = 0; i < f.nvr() ; ++i) 
00629            {
00630                if ( vars[i] != v )
00631                {
00632                    ind[i] += 1;
00633                    pos += sstr[i];
00634                } else continue;
00635 
00636                if (ind[i] < sszs[i])
00637                    break;
00638                ind[i] = 0;
00639                pos -= sszs[i]*sstr[i];
00640            }
00641            if (i == f.nvr() )
00642                break;
00643        }
00644    };

void mmx::tensor::conv ( MPLBASE0 &  r,
const MPLBASE1 &  a,
const MPLBASE2 &  b 
) [inline]

Definition at line 33 of file tensor_convert.hpp.

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

00034   {
00035     if (&a == &r) { conv (r, b); return; };
00036     if (&b == &r) { conv (r, a); return; };
00037     clear (r, eenv::mul (a.env, b.env));
00038 
00039     unsigned *oa = new unsigned[a.esz () + b.esz ()];
00040     unsigned *ob = oa + a.esz ();
00041 
00042     eenv::oaddress (r.env, oa, a.env);
00043     eenv::oaddress (r.env, ob, b.env);
00044     
00045     typedef typename MPLBASE0::value_type rreal;
00046     typedef typename MPLBASE1::value_type areal;
00047     typedef typename MPLBASE2::value_type breal;
00048     
00049     unsigned *ea;
00050     unsigned *eb;
00051     rreal * pr = r.begin();
00052     const areal * pa;
00053     const breal * pb;
00054     
00055     for (ea = oa, pa = a.begin (); ea != oa + a.esz (); ea++, pa++)
00056       for (eb = ob, pb = b.begin (); eb != ob + b.esz ();
00057            pr[*ea + *eb++] += (*pa) * (*pb++) ) ;
00058     delete[]oa;
00059   };

void conv ( MPLBASE0 &  r,
const MPLBASE1 &  a 
) [inline]

Definition at line 62 of file tensor_convert.hpp.

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

00062                                          { 
00063     MPLBASE0 tmp;
00064     r.swap (tmp);
00065     conv (r, tmp, a);
00066   };

void mmx::tensor::convert ( sparse::monomial_seq< C, O > &  pol,
const monomials< C > &  mpl 
) [inline]

Definition at line 399 of file tensor_monomials_fcts.hpp.

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

00399                                                                        {
00400     typedef typename sparse::monomial_seq< C, O>::monom_t monom_t;
00401     typedef typename monom_t::container_t container_t;
00402     add(pol,C(0));
00403     container_t tmp (mpl.env.mxvr()+1);
00404     const int *szs = mpl.szs ();
00405     const int *vrs = mpl.vrs ();
00406     for (int i = 0; i < mpl.size(); i++)
00407       if (mpl[i] != 0)
00408         {
00409           int a, v;
00410           for (a = i, v = mpl.nvr () - 1; a; a /= szs[v], v--)
00411           tmp[vrs[v]] = a % szs[v];
00412           add(pol, monom_t (mpl[i], tmp));
00413         };
00414   }

void mmx::tensor::convert ( monomials< C > &  mpl,
const sparse::monomial_seq< C, O > &  imp 
) [inline]

Definition at line 392 of file tensor_monomials_fcts.hpp.

00393   {
00394     mpl. ~ monomials < C > ();
00395     new (&mpl) monomials<C>(imp);
00396   };

UPOL mmx::tensor::convert ( const MPOL &  p,
unsigned  v 
) [inline]

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().

00074   {
00075     unsigned N = degree(p,v)+1;
00076     UPOL r(N, AsSize());
00077     for(unsigned i =0; i<N;i++) { slice(r[i].rep(),p.rep(),v,i); }
00078     return r;
00079   }

void mmx::tensor::convertb2m ( C *  data,
const eenv &  env,
binomials< C > &  bins 
) [inline]

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

Definition at line 309 of file tensor_eenv_loops.hpp.

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

00310   {
00311     for (int v = 0; v < env.nvr (); convertb2m (data, env, bins, v++)) ;
00312   };

void mmx::tensor::convertb2m ( C *  data,
const eenv &  e,
binomials< C > &  bins,
int  v 
) [inline]

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

Definition at line 297 of file tensor_eenv_loops.hpp.

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

00298   {
00299     const int *esz = e.szs ();
00300     const int *est = e.str ();
00301     int i, j;
00302     for (i = 0; i < e.sz (); i += est[v - 1])
00303       for (j = i; j < i + est[v];
00304            convertb2m (data + j, esz[v], est[v], bins), j++) ;
00305   };

void mmx::tensor::convertb2m ( C *  bzc,
unsigned  sz,
int  st,
binomials< C > &  binom 
) [inline]

Definition at line 248 of file tensor_eenv_loops.hpp.

References mmx::vctops::pmul().

00248                                                                        {
00249     int i,k;
00250     for ( i = st; i != st*int(sz); i += st )
00251     for ( k = (sz-1)*st; k != i-st; k -= st )
00252       bzc[k] -= bzc[k-st];
00253     vct::pmul(bzc,binom[sz-1],sz,st,1);
00254   };

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().

00026                                      { 
00027     convertb2m (mpl.begin (), mpl.env, binomials < C >::default_); 
00028   }

void mmx::tensor::convertm2b ( C *  data,
const eenv &  env,
binomials< C > &  bins 
) [inline]

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

Definition at line 288 of file tensor_eenv_loops.hpp.

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

00289   {
00290     for (int v = 0; v < env.nvr (); convertm2b (data, env, bins, v++)) ;
00291   };

void mmx::tensor::convertm2b ( C *  data,
const eenv &  e,
binomials< C > &  bins,
int  v 
) [inline]

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

Definition at line 277 of file tensor_eenv_loops.hpp.

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

00278   {
00279     const int *esz = e.szs ();
00280     const int *est = e.str ();
00281     int i, j;
00282     for (i = 0; i < e.sz (); i += est[v - 1])
00283       for (j = i; j < i + est[v]; convertm2b (data + j, esz[v], est[v], bins), j++) ;
00284   };

void mmx::tensor::convertm2b ( C *  bzc,
unsigned  sz,
int  st,
binomials< C > &  binoms 
) [inline]

Definition at line 258 of file tensor_eenv_loops.hpp.

References C.

00258                                                                         {
00259     C tmp[sz];
00260     const C * bin;
00261     unsigned i,k,p,l;
00262     
00263     for ( p = 0, i = 0; i < sz; i++, p += st ) 
00264       { tmp[i] = bzc[p]; bzc[p] = C(0); };
00265     for ( p = 0, i = 0; i < sz; i++, p += st )
00266       for ( bin = binoms[sz-i-1], l = p, k = 0; k < sz-i; k++, l += st )
00267         bzc[l] += tmp[i]*bin[k];
00268     bin = binoms[sz-1];
00269     for ( i = 0, l = 0; i < sz; i ++, l += st  )
00270       bzc[l] /= bin[i];
00271   };

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().

00036                                                  {
00037     convertm2b (mpl);
00038     for(unsigned i=0;i<bx.size();i+=2)
00039       restrict(mpl,i/2,bx[i],bx[i+1]);
00040   };

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 bernstein< C >::bernstein(), convertm2b(), mmx::realroot::fill_data(), solver< Ring, Bspline >::first_root(), and binary_sleeve_subdivision< K >::init_pol().

00031                                     {
00032     convertm2b (mpl.begin (), mpl.env, binomials < C >::default_);
00033   };

void mmx::tensor::decasteljau ( real_t *  r,
unsigned  sz,
const value_t &  t,
int  str = 1 
) [inline]

Definition at line 73 of file tensor_eenv_loops.hpp.

Referenced by eval(), and levalb().

00074   {
00075     real_t *er, *p;
00076       for ( er = r + (sz-1)*str; er != r; er -= str )
00077         for ( p = r; p != er; p += str )
00078           *p = real_t(value_t(1)-t)* *p+t**(p+str);
00079   };  

int mmx::tensor::degree ( const monomials< Coeff > &  p,
int  v 
) [inline]

Definition at line 361 of file tensor_monomials_fcts.hpp.

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

00361                                            {
00362     return p.env.sz(v)-1;
00363   }

int mmx::tensor::degree ( const monomials< Coeff > &  p  )  [inline]

Definition at line 354 of file tensor_monomials_fcts.hpp.

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

00354                                     {
00355     int d=0;
00356     for(int i=0;i<p.nbvar();i++) d+= *(p.env.szs()+i)-1;
00357     return d;
00358   }

int mmx::tensor::degree ( const bernstein< C > &  p,
int  v 
) [inline]

Definition at line 76 of file tensor_bernstein.hpp.

References degree().

00076 {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().

00073 {return degree((const monomials<C>&)p);}

void mmx::tensor::diff ( monomials< Coeff > &  res,
const monomials< Coeff > &  src,
int  v 
) [inline]

Definition at line 372 of file tensor_monomials_fcts.hpp.

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

00372                                                                     {
00373     clear( res, eenv::diff(src.env,v));
00374     //    mdiff( res.begin(), res.env, src.begin(), src.env, v );
00375     mdiff( res.begin(), res.env, src.begin(), src.env,  v );
00376   }

void mmx::tensor::diff ( C *  b,
C *  e,
C const *  a 
) [inline]

Definition at line 334 of file tensor_eenv_loops.hpp.

00335   { 
00336     for ( int i = 1; b != e; *b++ = *(++a)*i++ ) ;
00337   };

void mmx::tensor::diff ( C *  b,
C *  e,
C const *  a,
int  s 
) [inline]

Definition at line 327 of file tensor_eenv_loops.hpp.

00328   { 
00329     unsigned i;
00330     for ( i = 1, a += s; b != e; *b = *a*i++, b += s, a += s ) ;
00331   };

void mmx::tensor::diff ( C *  b,
const C *  a,
unsigned  sz,
int  sb,
int  sa 
) [inline]

Definition at line 319 of file tensor_eenv_loops.hpp.

References assert.

00320   {
00321     assert(sa==sb);
00322     for ( unsigned i = 1; i < sz; i ++ ) { b[(i-1)*sb] = i*a[i]; };
00323     //    for ( unsigned i = 1, a += sa; i < sz; *b = *a*i++, b += sb, a += sa ) ; 
00324   };

void mmx::tensor::diff ( bernstein< C > &  res,
const bernstein< C > &  src,
int  v 
) [inline]

Definition at line 317 of file tensor_bernstein_fcts.hpp.

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

00318   {
00319     clear( res, eenv::diff(src.env,v) );
00320     bdiff( res.begin(), src.env, src.begin(), v );
00321   };

bernstein<C> mmx::tensor::diff ( const bernstein< C > &  p,
int  v 
) [inline]

Definition at line 79 of file tensor_bernstein.hpp.

References Polynomial.

Referenced by m_diff().

00080   {
00081     Polynomial dp(p);   diff(dp,p,v);   return dp;
00082   }

void mmx::tensor::div ( monomials< C > &  r,
const monomials< C > &  a,
const C &  c 
) [inline]

Definition at line 300 of file tensor_monomials_fcts.hpp.

References div().

00300                                                                  {
00301     div(r=a,c);
00302   }

void mmx::tensor::div ( monomials< C > &  r,
const C &  c 
) [inline]

Definition at line 270 of file tensor_monomials_fcts.hpp.

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

00271   {
00272     vct::scdiv (r.begin (), c, r.esz (), 1);
00273   };

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().

00178                                                                {
00179   div(r=a,c);
00180 }

void mmx::tensor::elevate ( bernstein< C > &  r,
const eenv &  elev 
) [inline]

Definition at line 43 of file tensor_bernstein_fcts.hpp.

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

Referenced by rewrite().

00044   {
00045     bernstein < C > tmp (elev);
00046     tensor::binoms (tmp);
00047     scale (r);
00048     tensor::conv(r, tmp);
00049     uscale (r);
00050   };

void mmx::tensor::eval ( Result &  result,
const monomials< Coeff > &  monoms,
const Parameters &  parameters,
unsigned  n 
) [inline]

Definition at line 141 of file tensor_monomials_fcts.hpp.

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

00142   { 
00143       //assert(parameters.size()<n);
00144     levalm( result, monoms.begin (), monoms.env, parameters ); 
00145   };

void mmx::tensor::eval ( Result &  result,
const monomials< Coeff > &  monoms,
const Parameters &  parameters 
) [inline]

Definition at line 134 of file tensor_monomials_fcts.hpp.

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

00135   { 
00136     //    if (monoms.nbvar()==1)
00137     vct::horner(result, monoms.begin (), monoms.size(), parameters, 1); 
00138     // levalm( result, monoms.begin (), monoms.env, parameters ); 
00139   };

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().

00210                                                                                                                { 
00211   //assert(parameters.size()<n);
00212   levalb( result, controls.begin (), controls.env, parameters ); 
00213 };

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().

00202 {
00203   Coeff tmp[controls.env.sz()];
00204   std::copy (controls.begin(), controls.end(), tmp);
00205   decasteljau (tmp , controls.env.sz(), v, 1);
00206   result=tmp[0];
00207 };

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().

00196 {
00197   levalb (result, controls.begin (), controls.env,parameters);
00198 };

void mmx::tensor::extend ( monomials< C > &  mpl,
const eenv &  nenv 
) [inline]

Definition at line 160 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().

00161   {
00162     if ( mpl.env != nenv )
00163       {
00164         unsigned *oadd = new unsigned[mpl.esz ()];
00165         eenv::oaddress (nenv, oadd, mpl.env, 0, 0);
00166         monomials < C > tmp (nenv);
00167         vct::icopy (tmp.begin (), oadd, mpl.esz (), mpl.begin ());
00168         delete[]oadd;
00169         mpl.swap (tmp);
00170       };
00171   };

void mmx::tensor::face ( monomials< C > &  f,
const monomials< C > &  src,
int  v,
int  n 
) [inline]

Definition at line 453 of file tensor_monomials_fcts.hpp.

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

00454 {
00455   assert(n==0||n==1);
00456   eenv fenv(face_env(src.env,src.env.localv(v)));
00457   if ( f.env != fenv ) realloc( f, fenv );
00458   if ( n ) rface( f, src, src.env.localv(v)  );
00459   else     lface( f, src, src.env.localv(v)  );
00460 };

void mmx::tensor::face ( bernstein< C > &  f,
const bernstein< C > &  src,
int  v,
int  n 
) [inline]

Definition at line 368 of file tensor_bernstein_fcts.hpp.

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

00369 {
00370   assert(n==0||n==1);
00371   eenv fenv(face_env(src.env,src.env.localv(v)));
00372   if ( f.env != fenv ) realloc( f, fenv );
00373   if ( n ) rface( f, src, src.env.localv(v) );
00374   else     lface( f, src, src.env.localv(v) );
00375 };

void mmx::tensor::face ( polynomial< C, with< Rep, Ord > > &  r,
const polynomial< C, with< Rep, Ord > > &  p,
int  v,
int  f 
) [inline]
eenv mmx::tensor::face_env ( const eenv &  e,
int  lv 
) [inline]

Definition at line 428 of file tensor_monomials_fcts.hpp.

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

Referenced by face().

00428                                               {
00429   const int * eszs = e.szs();
00430   const int * evrs = e.vrs();
00431   const int   envr = e.nvr();
00432   int szs[ envr ];
00433   int vrs[ envr ];
00434   int c = 0;
00435   for ( int v = 0; v < envr; v ++ ) if ( v != lv ) { szs[c] = eszs[v]; vrs[c++] = evrs[v]; };//evrs[v]; };
00436   return eenv(c,szs,vrs);
00437 }

void mmx::tensor::heval ( Result &  result,
const monomials< Coeff > &  monoms,
const Parameters &  parameters 
) [inline]

Definition at line 148 of file tensor_monomials_fcts.hpp.

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

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

00149   { 
00150     hevalm( result, monoms.begin (), monoms.env, parameters ); 
00151   };

void mmx::tensor::hevalm ( R &  result,
const C *  data,
const eenv &  env,
const P &  p 
) [inline]

Definition at line 47 of file tensor_eenv_loops.hpp.

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

Referenced by heval().

00048   {
00049     typedef R result_type;
00050 
00051     // query for the environment information
00052 
00053     const int esz = env.sz ();  // number of coefficients
00054     const int nvr = env.nvr (); // number of variables 
00055     const int *szs = env.szs ();        // sizes in each variables
00056     const int *str = env.str ();        // corresponding strides.
00057 
00058     result_type *tmp = new result_type[env.sz()];   // temporary array used by the inplace evaluation loop
00059     result_type r;
00060     std::copy (data, data + env.sz (), tmp);
00061     for (int v = nvr - 1; v >= 0; v--)
00062       for (int i = 0; i < esz; i += str[v - 1]) {
00063         vct::hhorner(r,tmp + i, szs[v], p[v+1],p[0],str[v]);
00064         tmp[i] =  r;
00065       }
00066 
00067     let::assign(result,tmp[0]);
00068 
00069     delete tmp;
00070   };

void mmx::tensor::ibinoms ( C *  data,
const eenv &  env,
binomials< C > &  binms 
) [inline]

Definition at line 198 of file tensor_eenv_loops.hpp.

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

00199   {
00200     binoms(data,env,binms);
00201     vct::inverses(data,data+env.sz());
00202   };

void mmx::tensor::islice ( monomials< C > &  f,
const monomials< C > &  src,
int  v,
int  i 
) [inline]

Definition at line 464 of file tensor_monomials_fcts.hpp.

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

Referenced by slice().

00465   {
00466     slice( f.begin(), src.env, src.begin(), v );
00467   }

int mmx::tensor::leading_variable ( const monomials< Coeff > &  p  )  [inline]

Definition at line 367 of file tensor_monomials_fcts.hpp.

00367                                               {
00368     return 0;
00369   }

void mmx::tensor::levalb ( R &  result,
const C *  data,
const eenv &  env,
const P &  p 
) [inline]

Evaluation in bernstein form as levalm()

Definition at line 83 of file tensor_eenv_loops.hpp.

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

Referenced by eval().

00084   {
00085     //    typename sup<typename texp::value_type<P>::result_t, C >::T tmp[env.sz()];
00086     //XXX    typename texp::ringof_ < typename texp::value_type<P>::T,C >::T
00087 
00088     int szTemp =  env.sz();
00089 
00090     R tmp[szTemp];
00091 
00092     const int esz  (env.sz ());
00093     const int nvr  (env.nvr ());
00094     const int *szs (env.szs ());
00095     const int *str (env.str ());
00096 
00097     std::copy (data, data + env.sz (), tmp);
00098 
00099     for (int v = nvr - 1; v >= 0; v--)
00100       for (int i = 0; i < esz; i += str[v - 1])
00101         decasteljau (tmp + i, szs[v], p[v], str[v]);
00102 
00103     let::assign(result,tmp[0]);
00104   };

void mmx::tensor::levalm ( R &  result,
const C *  data,
const eenv &  env,
const P &  p 
) [inline]

Evaluation by horner scheme of multivariate polynomial data. result is the result of the evaluation of the coefficients in dense tensor form starting at data and corresponding to the sizes and ordering of variables represented by env. p is the parameter array (operator[]) supposed to be as large as the number of variables in env. result is assumed to be assignable to the Type::Sup value of P and R. Note that levalm() index of variables are local to env, 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(), R, eenv::str(), eenv::sz(), and eenv::szs().

Referenced by eval().

00021   {
00022     typedef R result_type;
00023 
00024     // query for the environment information
00025 
00026     const int esz = env.sz ();  // number of coefficients
00027     const int nvr = env.nvr (); // number of variables 
00028     const int *szs = env.szs ();        // sizes in each variables
00029     const int *str = env.str ();        // corresponding strides.
00030 
00031     result_type *tmp = new result_type[env.sz()]; // temporary array used by the inplace evaluation loop
00032     result_type r;
00033     std::copy (data, data + env.sz (), tmp);
00034     for (int v = nvr - 1; v >= 0; v--) {
00035       for (int i = 0; i < esz; i += str[v - 1]) {
00036         vct::horner(r,tmp + i, szs[v], p[v], str[v]);
00037         tmp[i] =  r;
00038       }
00039     }
00040 //    let::assign(result,tmp[0]);
00041     result = tmp[0];
00042 
00043     delete tmp;
00044   };

void mmx::tensor::lface ( monomials< C > &  f,
const monomials< C > &  src,
int  v 
) [inline]

Definition at line 440 of file tensor_monomials_fcts.hpp.

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

00441 {
00442   lface( f.begin(), src.env, src.begin(), v );
00443 };

void mmx::tensor::lface ( C *  dst,
const eenv &  a,
const C *  src,
int  v 
) [inline]

Definition at line 499 of file tensor_eenv_loops.hpp.

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

00500   {
00501     const int   ssz  = a.sz ();
00502     //    const int * sszs = a.szs();
00503     const int * sstr = a.str();
00504 
00505     C * ed; const C * es;
00506     const C * fs;
00507     for ( ed = dst, es = src; es < src+ssz; es += sstr[v-1] )
00508       for ( fs = es; fs < es + sstr[v]; *ed++ = *fs++ ) ;
00509   };

void mmx::tensor::lface ( bernstein< C > &  f,
const bernstein< C > &  src,
int  v 
) [inline]

Definition at line 354 of file tensor_bernstein_fcts.hpp.

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

Referenced by face(), and lface().

00355 {
00356   lface( f.begin(), src.env, src.begin(), v );
00357 };

void mmx::tensor::m_diff ( C *  op,
const eenv &  o,
C const *  ap,
const eenv &  a,
int  v 
) [inline]

Definition at line 341 of file tensor_eenv_loops.hpp.

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

00342   {
00343     typedef int sz_t;
00344     sz_t is = 0;
00345     for ( sz_t i = 0; i < o.sz(); i += o.st(v-1), is += a.st(v-1) )
00346       for ( sz_t j = 0; j < a.st(v); j ++ )
00347         diff(op+i+j, ap+is+j,a.sz(v), o.st(v), a.st(v)) ;
00348   };

void mmx::tensor::maxs ( monomials< C > &  mm,
monomials< C > &  f,
int  v 
) [inline]

Definition at line 663 of file tensor_monomials_fcts.hpp.

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

00664     {
00665 
00666        int p,k,i,j;
00667        int * sszs = f.szs() ;
00668        int * sstr = f.str() ;
00669 
00670        for ( p = 0, k = 0; k < sszs[v]; k++, p += sstr[v] )
00671         {
00672             mm.data[k] = f.data[p];
00673           for ( i = 0; i < f.size(); i += sstr[v-1] )
00674             for ( j = i; j < i + sstr[v]; j ++ )
00675               if ( f.data[j+p] > mm[k] ) mm[k] = f.data[j+p];
00676         }
00677     }

void mmx::tensor::maxs ( OutputIterator  _maxs_,
const C *  data,
const eenv &  env,
int  v 
) [inline]

Definition at line 109 of file tensor_eenv_loops.hpp.

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

00110   {
00111     const int *eszs = env.szs ();
00112     const int *estr = env.str ();
00113     //    const int envr = env.nvr ();
00114     int k, i; //, j;
00115     for ( k = 0; k < eszs[v]; k++, data += estr[v], _maxs_++)
00116       {
00117         *_maxs_ = *data;
00118         for (i = 0; i < estr[-1]; i += estr[v - 1])
00119           for (const C * edata = data + i; edata < data + i + estr[v]; edata++)
00120             if (*edata > *_maxs_)
00121               *_maxs_ = *edata;
00122       };
00123   };

void mmx::tensor::mdiff ( C *  dst,
const eenv &  a,
C const *const   src,
const eenv &  esrc,
int  v 
) [inline]

Definition at line 351 of file tensor_eenv_loops.hpp.

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

Referenced by diff().

00352   {
00353     const int   ssz  = esrc.sz ();
00354     //    const int * sszs = a.szs();
00355     const int * sstr = esrc.str();
00356     int rst = sstr[v-1]-sstr[v];
00357     unsigned i;
00358     C * ed, * fd;
00359     const C * es, * fs;
00360     for ( ed = dst, es = src; es < src+ssz; ed += rst, es += sstr[v-1] )
00361       for ( i = 1, fd = ed, fs = es+sstr[v]; fs != es+sstr[v-1]; fd += sstr[v], fs += sstr[v], i ++  )
00362         vct::scmul(fd,fd+sstr[v],fs,C(i));
00363   }

void mmx::tensor::mescan ( int &  last,
vd *  vdeg,
const MONOM &  m 
) [inline]

Definition at line 404 of file tensor_eenv_fcts.hpp.

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

Referenced by eenv::eenv().

00405   {
00406     for (unsigned i = 0; i < m.size (); i++)
00407       {
00408         if (m[i] != 0)
00409           {
00410             if (vdeg[i].n != -1)
00411               vdeg[i].d = std::max ((int) m[i], vdeg[i].d);
00412             else
00413               {
00414                 if (last != -1)
00415                   {
00416                     vdeg[i].n = vdeg[last].n;
00417                     vdeg[i].d = m[i];
00418                     vdeg[last].n = i;
00419                     last = i;
00420                   }
00421                 else
00422                   {
00423                     last = i;
00424                     vdeg[i].n = i;
00425                     vdeg[i].d = m[i];
00426                   };
00427               };
00428           };
00429       };
00430   }

void mmx::tensor::mins ( monomials< C > &  mm,
monomials< C > &  f,
int  v 
) [inline]

Definition at line 647 of file tensor_monomials_fcts.hpp.

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

00648      {
00649         int p,k,i,j;
00650         int * sszs = f.szs() ;
00651         int * sstr = f.str() ;
00652 
00653         for ( p = 0, k = 0; k < sszs[v]; k++, p += sstr[v] )
00654         {
00655             mm.data[k] = f.data[p];
00656           for ( i = 0; i < f.size(); i += sstr[v-1] )
00657             for ( j = i; j < i + sstr[v]; j ++ )
00658               if ( f.data[j+p] < mm[k] ) mm[k] = f.data[j+p];
00659         }
00660      }

void mmx::tensor::mins ( OutputIterator  _mins_,
const C *  data,
const eenv &  env,
int  v 
) [inline]

Definition at line 126 of file tensor_eenv_loops.hpp.

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

00127   {
00128     const int *eszs = env.szs ();
00129     const int *estr = env.str ();
00130     //    const int envr = env.nvr ();
00131     int p, k, i, j;
00132     for (p = 0, k = 0; k < eszs[v]; k++, p += estr[v], _mins_++)
00133       {
00134         *_mins_ = data[p];
00135         for (i = 0; i < estr[-1]; i += estr[v - 1])
00136           for (j = i; j < i + estr[v]; j++)
00137             if (data[j + p] < *_mins_)
00138               *_mins_ = data[j + p];
00139       };
00140   };

void mmx::tensor::mpolfill ( C *  data,
const sparse::monomial_seq< X, O > &  mpol,
const eenv &  env 
) [inline]

Definition at line 544 of file tensor_eenv_loops.hpp.

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

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

00545   {
00546     const int *vr = env.vrs ();
00547     const int *st = env.str ();
00548     const int  nvr = env.nvr();
00549     typename sparse::monomial_seq<X,O>::const_iterator it;
00550     C c;
00551     for (it =mpol.begin (); it != mpol.end (); it++)
00552       {
00553         int a = 0;
00554         for (int v = 0; v < nvr; a += (*it)[vr[v]] * st[v], v++) ;
00555         let::assign(c,(*it).coeff ());
00556         data[a] += c;
00557       };
00558   }

void mmx::tensor::mprint ( OSTREAM &  o,
const bernstein< C > &  mpl 
) [inline]

Definition at line 289 of file tensor_bernstein_fcts.hpp.

References convert().

00290   {
00291     monomials < C > mp (0);
00292     convert (mp, mpl);
00293     o << mp;
00294     
00295   };

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

Definition at line 295 of file tensor_monomials_fcts.hpp.

References mul().

00295                                                                  {
00296     mul(r=a,c);
00297   };

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

Definition at line 289 of file tensor_monomials_fcts.hpp.

References mul().

00290   {
00291     mul (a = b, c);
00292   };

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

Definition at line 283 of file tensor_monomials_fcts.hpp.

References conv().

00284   {
00285     conv(r,a,b);
00286   };

void mmx::tensor::mul ( monomials< C > &  r,
const monomials< C > &  a 
) [inline]

Definition at line 275 of file tensor_monomials_fcts.hpp.

References conv().

00276   {
00277     //    monomials<C> s(r);
00278     conv(r,a);
00279   };

void mmx::tensor::mul ( monomials< C > &  r,
const C &  c 
) [inline]

Definition at line 265 of file tensor_monomials_fcts.hpp.

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

00266   {
00267     vct::scmul (r.begin (), c, r.esz (), 1);
00268   };

void mmx::tensor::mul ( bernstein< C > &  r,
const C &  c 
) [inline]

Definition at line 173 of file tensor_bernstein_fcts.hpp.

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

00173                                      {
00174   vct::scmul(r.begin (),c, r.esz (), 1);
00175 }

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().

00168                                                                {
00169   mul(r=a,c);
00170 };

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().

00163                                                                {
00164   mul(r=a,c);
00165 };

void mmx::tensor::mul ( bernstein< C > &  r,
const bernstein< C > &  a 
) [inline]

Definition at line 152 of file tensor_bernstein_fcts.hpp.

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

00152                                                    {
00153   bernstein < C > a_;
00154   r.swap (a_);
00155   scale (a_);
00156   bernstein < C > b_ (a);
00157   scale (b_);
00158   tensor::conv (r, a_, b_);
00159   uscale (r);
00160 };

void mmx::tensor::mul ( bernstein< C > &  r,
const bernstein< C > &  a,
const bernstein< C > &  b 
) [inline]

Definition at line 142 of file tensor_bernstein_fcts.hpp.

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

Referenced by mul().

00142                                                                              {
00143   bernstein < C > a_ (a);
00144   scale (a_);
00145   bernstein < C > b_ (b);
00146   scale (b_);
00147   tensor::conv (r, a_, b_);
00148   uscale (r);
00149 };

std::ostream& mmx::tensor::operator<< ( std::ostream &  o,
const monomials< C > &  mpl 
) [inline]

Definition at line 121 of file tensor_monomials_fcts.hpp.

References print().

00122   {
00123     o << "monomials  object:\n";
00124     o << "\t(addresses) o: " << &mpl << " e: " << mpl.env.data <<  "d: " << mpl.
00125       begin () << std::endl;
00126     o << "\t(eenv)" << mpl.env << std::endl;
00127     o << "\t(data)";
00128     array::print (o, mpl.data);
00129     o << std::endl;
00130     o << ":object monomials\n";
00131     return o;
00132   };

std::ostream& mmx::tensor::operator<< ( std::ostream &  o,
const vd &  vd_ 
) [inline]

Definition at line 398 of file tensor_eenv_fcts.hpp.

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

00399   {
00400     o << "vd(" << vd_.n << ", " << vd_.d << ")";
00401     return o;
00402   };

std::ostream& mmx::tensor::operator<< ( std::ostream &  out,
const eenv &  env 
) [inline]

Definition at line 329 of file tensor_eenv_fcts.hpp.

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

00330   {
00331     out << "*eenv*\n";
00332     out << "\tpos: " << env.data    << "\n";
00333     out << "\tref: " << env.data[0] << "\n";
00334     out << "\tnvr: " << env.nvr()   << "\n";
00335     out << "\tesz: " << env.sz ()   << "\n";
00336     out << "\tszs: ";
00337     vct::print (env.szs (), env.nvr (), 1, out);
00338     out << "\n";
00339     out << "\tvrs: ";
00340     vct::print (env.vrs (), env.nvr (), 1, out);
00341     out << "\n";
00342     out << "\tstr: ";
00343     vct::print (env.str (), env.nvr (), 1, out);
00344     return out;
00345   };

std::ostream& mmx::tensor::operator<< ( std::ostream &  o,
const bernstein< C > &  mpl 
) [inline]

Definition at line 253 of file tensor_bernstein_fcts.hpp.

References print().

00254   {
00255     o << "bernstein object:\n";
00256     o << "\t(addresses) o: " << &mpl << " e: " << mpl.env.data <<  "d: " << mpl.
00257       begin () << std::endl;
00258     o << "\t(eenv)" << mpl.env << std::endl;
00259     o << "\t(data)";
00260     array::print (o, mpl.data);
00261     o << std::endl;
00262     o << ":object bernstein\n";
00263     return o;
00264   };

OSTREAM& mmx::tensor::print ( OSTREAM &  os,
const monomials< C > &  mpl,
const variables &  Var = monom<C>::var 
) [inline]

Definition at line 305 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().

00305                                                                                    { 
00306     typedef monom<C>             monom_t;
00307     typedef typename monom<C>::container_t exponent_t;
00308     exponent_t tmp (mpl.env.mxvr()+1);
00309     const int *szs = mpl.szs ();
00310     const int *vrs = mpl.vrs ();
00311     bool notfirst = false;
00312     for (int i = 0; i < mpl.size(); i++)
00313       if (mpl[i] != 0)
00314         {
00315           int a, v;
00316           for (a = i, v = mpl.nvr () - 1; a; a /= szs[v], v--)
00317             tmp[vrs[v]] = a % szs[v];
00318           std::ostringstream sm;
00319           print(sm, monom_t (mpl[i], tmp), Var);
00320           //bool is_pol = is_polynomial(sm);
00321          if ( sm.str()[0]!='-' && sm.str()[0]!='+' && notfirst) { 
00322             os <<'+'; 
00323           }
00324          os<<sm.str().c_str();
00325          notfirst=true;
00326         };
00327     if(!notfirst) os << "0";
00328     return os;
00329   }

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 convertb2m(), and print().

00305                                                                    { 
00306     monomials<C> mp(mpl);
00307     convertb2m(mp);
00308     print(o,mp,v);
00309   };

void mmx::tensor::print ( OSTREAM &  o,
const bernstein< C > &  mpl 
) [inline]

Definition at line 298 of file tensor_bernstein_fcts.hpp.

References convertb2m().

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

00298                                                { 
00299     monomials<C> mp(mpl);
00300     convertb2m(mp);
00301     print(o,mp);
00302   };

void mmx::tensor::print_flatten ( SYNTAX &  out,
const monomials< C > &  mpl,
const variables &  Var = monom<C>::var 
) [inline]

Definition at line 332 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().

00332                                                                                            { 
00333     typedef monom<C>             monom_t;
00334     typedef typename monom<C>::container_t exponent_t;
00335     exponent_t tmp (mpl.env.mxvr()+1);
00336     const int *szs = mpl.szs ();
00337     const int *vrs = mpl.vrs ();
00338     for (int i = 0; i < mpl.size(); i++)
00339       if (mpl[i] != 0)
00340         {
00341           int a, v;
00342           for (a = i, v = mpl.nvr () - 1; a; a /= szs[v], v--)
00343             tmp[vrs[v]] = a % szs[v];
00344 
00345           SYNTAX m = flatten(mpl[i]);
00346           for(int i=0;i<mpl.env.mxvr()+1;i++)
00347             m = m * pow(SYNTAX(Var[i].data()),flatten(tmp[i]));
00348           out+=m;             
00349         }
00350   }

void mmx::tensor::realloc ( monomials< C > &  mpl,
const eenv &  nenv 
) [inline]

Definition at line 77 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().

00078   {
00079     if (!eenv::equal (mpl.env, nenv ))
00080       {
00081         monomials< C > tmp (nenv);
00082         mpl.swap (tmp);
00083       };
00084   };

void mmx::tensor::reciprocal ( monomials< C > &  f,
const int &  v 
) [inline]

Compute f (1/var[v]).

Definition at line 577 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().

00578    {
00579        std::vector<int> ind = std::vector<int>( f.nvr() );
00580        int s,i,pos =0;
00581 
00582         int * vars = f.vrs();
00583         int * sstr = f.str();
00584         int * sszs = f.szs();
00585         int l= sszs[v]-1;
00586        
00587        for (;;) 
00588        {
00589            for ( s = 0 ; s <= l/2; s++ )
00590                std::swap(f.data[sstr[v]*s+pos], f.data[sstr[v]*(l-s)+pos] );
00591 
00592            // next row
00593            for (i = 0; i < f.nvr() ; ++i) 
00594            {
00595                if ( vars[i] != v )
00596                {
00597                    ind[i] += 1;
00598                    pos += sstr[i];
00599                } else continue;
00600 
00601                if (ind[i] < sszs[i])
00602                    break;
00603                ind[i] = 0;
00604                pos -= sszs[i]*sstr[i];
00605            }
00606            if (i == f.nvr() )
00607                break;
00608        }
00609    }

void mmx::tensor::rename_var ( monomials< C > &  f,
const int &  v,
const int &  n 
) [inline]

Definition at line 681 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().

00682     {
00683         int * vr = f.vrs();
00684         
00685         for (int i=0; i< f.nvr(); ++i)
00686             if (vr[i]==v) { 
00687                 vr[i]=n;
00688                 break; }
00689     }

void mmx::tensor::restrict ( bernstein< C > &  rst,
int  v,
const T &  a,
const T &  b 
) [inline]

Definition at line 347 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().

00347                                                                     { 
00348     v = rst.env.vridx(v);
00349     if (v < rst.env.nvr())
00350       brestrict( rst.begin(), rst.env, v, a, b ); 
00351   };

void mmx::tensor::rewrite ( bernstein< C > &  r,
const eenv &  newe 
) [inline]

Definition at line 73 of file tensor_bernstein_fcts.hpp.

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

Referenced by add(), and sub().

00074   {
00075     if ( newe == r.env ) return;
00076     eenv elenv = eenv::elevation (newe, r.env);
00077     elevate (r, elenv) ;
00078   };

void mmx::tensor::rface ( monomials< C > &  f,
const monomials< C > &  src,
int  v 
) [inline]

Definition at line 446 of file tensor_monomials_fcts.hpp.

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

00447 {
00448   rface( f.begin(), src.env, src.begin(), v );
00449 };

void mmx::tensor::rface ( C *  dst,
const eenv &  a,
const C *  src,
int  v 
) [inline]

Definition at line 512 of file tensor_eenv_loops.hpp.

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

00513   {
00514     const int   ssz  = a.sz ();
00515     //    const int * sszs = a.szs();
00516     const int * sstr = a.str();
00517 
00518     C * ed; const C * es;
00519     const C * fs;
00520     es = src +  sstr[v-1]-sstr[v];
00521     for ( ed = dst; es < src+ssz; es += sstr[v-1] )
00522       {
00523         for ( fs = es; fs < es + sstr[v]; *ed++ = *fs++ ) ;
00524       };
00525   };

void mmx::tensor::rface ( bernstein< C > &  f,
const bernstein< C > &  src,
int  v 
) [inline]

Definition at line 361 of file tensor_bernstein_fcts.hpp.

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

Referenced by face(), and rface().

00362 {
00363   rface( f.begin(), src.env, src.begin(), v );
00364 };

void mmx::tensor::scadd ( MPLBASE &  r,
const MPLBASE1 &  a,
const C &  c 
) [inline]

Definition at line 21 of file tensor_convert.hpp.

References scadd().

00022   {
00023     if (r.env != a.env) 
00024       scadd (r = a, c);
00025     else 
00026       vct::scadd (r.begin (), a.begin (), c, r.esz ());
00027   };

void mmx::tensor::scadd ( MPLBASE &  mpl,
const C &  c 
) [inline]

Definition at line 15 of file tensor_convert.hpp.

Referenced by add(), and scadd().

00016   {
00017     vct::scadd (mpl.begin (), c, mpl.esz (), 1);
00018   };

void mmx::tensor::scale ( C *  data,
const eenv &  env,
binomials< C > &  binoms 
) [inline]

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

Definition at line 206 of file tensor_eenv_loops.hpp.

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

00207   {
00208     const int *estr = env.str ();
00209     const int *eszs = env.szs ();
00210     const int  envr = env.nvr ();
00211     const int  esz  = env.sz ();
00212     const C *  bins = binoms[eszs[envr - 1] - 1];
00213     
00214     for (C *  pdata = data; pdata < data + esz; vct::pmul (pdata, bins, eszs[envr - 1]), pdata += estr[envr - 2]) ;
00215     
00216     for (int v = 0; v < envr - 1; v++)
00217       {
00218         bins = binoms[eszs[v] - 1];
00219         //      int k = 0;
00220         for (int i = 0; i < esz; i += estr[v - 1])
00221           for (int j = 0; j < estr[v]; j++)
00222             vct::pmul (data + i + j, bins, eszs[v], estr[v], 1);
00223       };
00224   };

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().

00015   {
00016    scale (mpl.begin (), mpl.env, binomials < C >::default_);
00017   };

void mmx::tensor::set_variable ( monomials< C > &  f,
t,
int  v 
) [inline]

Compute f (x_v=t).

Definition at line 534 of file tensor_monomials_fcts.hpp.

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

00535     {
00536        std::vector<int> ind = std::vector<int>( f.nvr() );
00537        int k, i, pos =0;
00538 
00539         int * vars = f.vrs();
00540         int * sstr = f.str();
00541         int * sszs = f.szs() ;
00542         C tmp;
00543        
00544        for (;;) 
00545        {
00546            tmp=0;
00547            for( k = sszs[v]-1; k !=-1; --k )
00548            { 
00549                tmp *= t;
00550                tmp += f.data[sstr[v]*k + pos];
00551                f.data[sstr[v]*k + pos] = 0 ;
00552            }
00553            f.data[pos]=tmp;
00554            
00555            /* next row */
00556            for (i = 0; i < f.nvr() ; ++i) 
00557            {
00558                if ( vars[i] != v )
00559                {
00560                    ind[i] += 1;
00561                    pos += sstr[i];
00562                } else continue;
00563 
00564                if (ind[i] < sszs[i])
00565                    break;
00566                ind[i] = 0;
00567                pos -= sszs[i]*sstr[i];
00568            }
00569            if (i == f.nvr() )
00570                break;
00571        }
00572    }

void mmx::tensor::shift ( monomials< C > &  f,
const C &  t,
const int &  v 
) [inline]

Compute f (var[v]+t).

Definition at line 497 of file tensor_monomials_fcts.hpp.

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

00498    {
00499        std::vector<int> ind = std::vector<int>( f.nvr() );
00500        int s,k,j, i,pos =0;
00501 
00502         int * vars = f.vrs();
00503         int * sstr = f.str();
00504         int * sszs = f.szs() ;
00505        
00506        for (;;) 
00507        {
00508            for ( s = sszs[v], j = 0; j <= s-2; j++ )
00509                for( k = s-2; k >= j; k-- ) 
00510                    f.data[sstr[v]*k+ pos ] += 
00511                    t*f.data[ sstr[v]*(1+k)+ pos ];
00512 
00513            /* next row */
00514            for (i = 0; i < f.nvr() ; ++i) 
00515            {
00516                if ( vars[i] != v )
00517                {
00518                    ind[i] += 1;
00519                    pos += sstr[i];
00520                } else continue;
00521 
00522                if (ind[i] < sszs[i])
00523                    break;
00524                ind[i] = 0;
00525                pos -= sszs[i]*sstr[i];
00526            }
00527            if (i == f.nvr() )
00528                break;
00529        }
00530    }

unsigned mmx::tensor::size ( const bernstein< C > &  p  )  [inline]

Definition at line 70 of file tensor_bernstein.hpp.

References monomials< C >::size().

00070 {return p.size();}

void mmx::tensor::slice ( monomials< C > &  f,
const monomials< C > &  src,
int  v,
int  n 
) [inline]

Definition at line 470 of file tensor_monomials_fcts.hpp.

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

00471   {
00472     assert(n==0||n==1);
00473     eenv fenv(slice(src.env,src.env.localv(v)));
00474     if ( f.env != fenv ) realloc( f, fenv );
00475     islice( f, src, src.env.localv(v),n);
00476   }

void mmx::tensor::slice ( C *  dst,
const eenv &  a,
const C *  src,
int  v,
int  n 
) [inline]

Definition at line 528 of file tensor_eenv_loops.hpp.

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

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

00529   {
00530     const int   ssz  = a.sz ();
00531     const int * sstr = a.str();
00532 
00533     C * ed; const C * es;
00534     const C * fs;
00535     es = src +  sstr[v-1]-sstr[v];
00536     for ( ed = dst; es < src+ssz; es += sstr[v-1] )
00537       {
00538         //      fs = es + sstr[v-1] - sstr[v];
00539         for ( fs = es; fs < es + sstr[v]; *ed++ = *fs++ ) ;
00540       };
00541   };

void mmx::tensor::split ( bernstein< C > &  l,
bernstein< C > &  r,
int  v 
) [inline]

Definition at line 340 of file tensor_bernstein_fcts.hpp.

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

00341   {
00342     if ( l.env != r.env ) { realloc(l,r.env); };
00343     bsplit2( l.begin(), r.begin(), r.env, r.env.localv(v) );
00344   };

void mmx::tensor::split ( bernstein< C > &  l,
bernstein< C > &  r,
int  v,
const T &  t 
) [inline]

Definition at line 332 of file tensor_bernstein_fcts.hpp.

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

00333   {
00334     if ( l.env != r.env ) { realloc(l,r.env); };
00335     bsplit( l.begin(), r.begin(), r.env, t, r.env.localv(v) );
00336   };

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().

00187                                              {
00188     split(r.rep(),p.rep(),v); 
00189   }

void mmx::tensor::sub ( monomials< C > &  a,
const X &  x 
) [inline]

Definition at line 260 of file tensor_monomials_fcts.hpp.

References C.

00261   {
00262     a[0] -= (C)x;
00263   }

void mmx::tensor::sub ( monomials< X > &  r,
const monomials< X > &  a,
const C &  c 
) [inline]

Definition at line 255 of file tensor_monomials_fcts.hpp.

References sub().

00256   {
00257     r=a;sub(r,c);
00258   }

void mmx::tensor::sub ( monomials< X > &  r,
const monomials< Y > &  a 
) [inline]

Definition at line 248 of file tensor_monomials_fcts.hpp.

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

00249   {
00250     extend (r, eenv::common (r.env, a.env)), wsubm (r, a);
00251   }

void mmx::tensor::sub ( monomials< C > &  mpl,
const C &  c,
const monomials< C > &  a 
) [inline]

Definition at line 234 of file tensor_monomials_fcts.hpp.

References add().

00234                                                                     {
00235     add(mpl,a,-c);
00236   }

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

Definition at line 220 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().

00221   {
00222     if ( &r == &a  ) {  sub(r,b);  return;  };
00223     if ( &r == &b  ) {  monomials<C> tmp = b; sub(r,a,tmp); return; };
00224     
00225     realloc(r,eenv::common(a.env,b.env));
00226     unsigned *oadd = new unsigned[std::max(a.esz (),b.esz())];
00227     eenv::oaddress (r.env, oadd,a.env, 0, 0);
00228     vct::icopy(r.begin(),oadd,a.esz(),a.begin());
00229     eenv::oaddress(r.env,oadd,b.env,0,0);
00230     vct::ipsub (r.begin (), oadd,b.esz (), b.begin ());
00231   };

void mmx::tensor::sub ( bernstein< C > &  mpl,
const bernstein< C > &  a,
const C &  c 
) [inline]

Definition at line 137 of file tensor_bernstein_fcts.hpp.

References add().

00137                                                                  {
00138   add(mpl,a,-c);
00139 }

void mmx::tensor::sub ( bernstein< C > &  mpl,
const C &  c,
const bernstein< C > &  a 
) [inline]

Definition at line 132 of file tensor_bernstein_fcts.hpp.

References add().

00132                                                                   {
00133   add(mpl,a,-c);
00134 }

void mmx::tensor::sub ( bernstein< C > &  mpl,
const C &  c 
) [inline]

Definition at line 127 of file tensor_bernstein_fcts.hpp.

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

00127                                         {
00128   vct::scsub (mpl.begin (), c, mpl.esz (), 1);
00129 }

void mmx::tensor::sub ( bernstein< C > &  r,
const bernstein< C > &  a,
const bernstein< C > &  b 
) [inline]

Definition at line 122 of file tensor_bernstein_fcts.hpp.

References sub().

00122                                                                              {
00123   sub (r = a, b);
00124 }

void mmx::tensor::sub ( bernstein< C > &  r,
const bernstein< C > &  a 
) [inline]

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().

00105                                                    {
00106   eenv cm(eenv::common(r.env,a.env));
00107   if ( r.env != cm ) { rewrite(r,cm); };
00108   if ( a.env == cm ) 
00109     {
00110       vct::psub (r.begin (), a.begin (), r.esz (), 1, 1); 
00111     }
00112   else 
00113     {
00114       bernstein<C> tmp(a);
00115       rewrite(tmp,cm);
00116       vct::psub (r.begin (), tmp.begin (), r.esz (), 1, 1);
00117     };
00118 }

void mmx::tensor::subs0 ( Result *  result,
const monomials< Coeff > &  monoms,
const Parameters &  parameters 
) [inline]

Definition at line 154 of file tensor_monomials_fcts.hpp.

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

00155   { 
00156     subs0m( result, monoms.begin (), monoms.env, parameters ); 
00157   };

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.

00217 { 
00218   subs0b( result, controls.begin (), controls.env, parameters ); 
00219 };

void mmx::tensor::uscale ( C *  data,
const eenv &  env,
binomials< C > &  binoms 
) [inline]

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

Definition at line 228 of file tensor_eenv_loops.hpp.

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

00229   {
00230     const int *estr = env.str ();
00231     const int *eszs = env.szs ();
00232     const int envr = env.nvr ();
00233     const int esz = env.sz ();
00234     const C *bins = binoms[eszs[envr - 1] - 1];
00235     for (C * pdata = data; pdata < data + esz; pdata += estr[envr - 2])
00236       vct::pdiv (pdata, bins, eszs[envr - 1]);
00237     for (int v = 0; v < envr - 1; v++)
00238       {
00239         bins = binoms[eszs[v] - 1];
00240         //      int k = 0;
00241         for (int i = 0; i < esz; i += estr[v - 1])
00242           for (int j = 0; j < estr[v]; j++)
00243             vct::pdiv (data + i + j, bins, eszs[v], estr[v], 1);
00244       };
00245   };

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().

00021   {
00022     uscale (mpl.begin (), mpl.env, binomials < C >::default_);
00023   };

bool mmx::tensor::varindex ( int &  lv,
const monomials< C > &  mpl,
int  gv 
) [inline]

Definition at line 99 of file tensor_monomials_fcts.hpp.

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

00100   {
00101     return mpl.env.hasvar (lv, gv);
00102   }

void mmx::tensor::vswap ( C *  data,
const eenv &  env,
int *  perm,
int *  supp = 0,
int  nsupp = 0 
) [inline]

Definition at line 145 of file tensor_eenv_loops.hpp.

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

00146   {
00147     const int *szs = env.szs ();
00148     const int *str = env.str ();
00149     int ostr[env.nvr ()];
00150     int i;
00151     for (i = env.nvr () - 2, str[env.nvr () - 1] = 1; i >= -1;
00152          ostr[i] = szs[perm[i + 1]] * str[i + 1], i--) ;
00153     if (supp == 0)
00154       {
00155         int a, o, v;
00156         for (i = 0; i < env.esz (); i++)
00157           {
00158             for (a = i, v = env.nvr () - 1; a; a /= szs[v], v--)
00159               o += (a % szs[v]) * ostr[perm[v]];
00160             std::swap (data[i], data[o]) ;
00161           };
00162       }
00163     else
00164       {
00165         int a, o, v;
00166         for (i = 0; i < nsupp; supp[i++] = o)
00167           {
00168             for (a = supp[i], v = env.nvr () - 1; a; a /= szs[v], v--)
00169               o += (a % szs[v]) * ostr[perm[v]];
00170             std::swap (data[i], data[o]);
00171           };
00172       };
00173     env.vswap (perm);
00174   };

void mmx::tensor::waddm ( monomials< X > &  mpla,
const monomials< Y > &  mplb 
) [inline]

Definition at line 175 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().

00176   {
00177     assert (eenv::subset (mplb.env, mpla.env));
00178     unsigned *oadd = new unsigned[mplb.esz ()];
00179     eenv::oaddress (mpla.env, oadd, mplb.env, 0, 0);
00180     vct::ipadd (mpla.begin (), oadd, mplb.esz (), mplb.begin ());
00181     delete[]oadd;
00182   };

void mmx::tensor::wsubm ( monomials< X > &  mpla,
const monomials< Y > &  mplb 
) [inline]

Definition at line 238 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().

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


Generated on 6 Dec 2012 for realroot by  doxygen 1.6.1