Developer documentation

tensor_convert.hpp
Go to the documentation of this file.
1 #ifndef realroot_MPOLDSE_MODULE_H
2 #define realroot_MPOLDSE_MODULE_H
3 //====================================================================
4 #include <realroot/tensor_eenv.hpp>
6 #include <realroot/binomials.hpp>
7 //====================================================================
8 namespace mmx {
9 
10 namespace tensor {
11 
12  typedef tensor::eenv eenv;
13 
14  template<class MPLBASE, class C >
15  void scadd (MPLBASE & mpl, const C & c)
16  {
17  vct::scadd (mpl.begin (), c, mpl.esz (), 1);
18  };
19 
20  template<class MPLBASE, class MPLBASE1, class C >
21  void scadd ( MPLBASE& r, const MPLBASE1 &a, const C & c)
22  {
23  if (r.env != a.env)
24  scadd (r = a, c);
25  else
26  vct::scadd (r.begin (), a.begin (), c, r.esz ());
27  };
28 
29  template<class MPLBASE0,class MPLBASE1>
30  void conv( MPLBASE0 &r, const MPLBASE1 &a );
31 
32  template<class MPLBASE0, class MPLBASE1, class MPLBASE2 >
33  void conv( MPLBASE0& r, const MPLBASE1& a, const MPLBASE2& b )
34  {
35  if (&a == &r) { conv (r, b); return; };
36  if (&b == &r) { conv (r, a); return; };
37  clear (r, eenv::mul (a.env, b.env));
38 
39  unsigned *oa = new unsigned[a.esz () + b.esz ()];
40  unsigned *ob = oa + a.esz ();
41 
42  eenv::oaddress (r.env, oa, a.env);
43  eenv::oaddress (r.env, ob, b.env);
44 
45  typedef typename MPLBASE0::value_type rreal;
46  typedef typename MPLBASE1::value_type areal;
47  typedef typename MPLBASE2::value_type breal;
48 
49  unsigned *ea;
50  unsigned *eb;
51  rreal * pr = r.begin();
52  const areal * pa;
53  const breal * pb;
54 
55  for (ea = oa, pa = a.begin (); ea != oa + a.esz (); ea++, pa++)
56  for (eb = ob, pb = b.begin (); eb != ob + b.esz ();
57  pr[*ea + *eb++] += (*pa) * (*pb++) ) ;
58  delete[]oa;
59  };
60 
61  template<class MPLBASE0,class MPLBASE1> void
62  conv( MPLBASE0 &r, const MPLBASE1 &a ) {
63  MPLBASE0 tmp;
64  r.swap (tmp);
65  conv (r, tmp, a);
66  };
67 
68 
72  template<class UPOL,class MPOL>
73  UPOL convert(const MPOL & p, unsigned v)
74  {
75  unsigned N = degree(p,v)+1;
76  UPOL r(N, AsSize());
77  for(unsigned i =0; i<N;i++) { slice(r[i].rep(),p.rep(),v,i); }
78  return r;
79  }
80 
81 } // namespace dense
82 //======================================================================
83 } //namespace mmx
84 #endif
static eenv mul(const eenv &a, const eenv &b)
Definition: tensor_eenv_fcts.hpp:246
static bool oaddress(const eenv &oenv, unsigned *osupp, const eenv &ienv, unsigned *isupp=0, unsigned nsp=0)
addresses translation from environment i to environment o
Definition: tensor_eenv_fcts.hpp:295
const C & b
Definition: Interval_glue.hpp:25
void clear(monomials< C > &monoms)
Definition: tensor_monomials_fcts.hpp:87
R & rep(R &r)
Definition: shared_object.hpp:180
TMPL int N(const MONOMIAL &v)
Definition: monomial_glue.hpp:60
void slice(C *dst, const eenv &a, const C *src, int v, int n)
Definition: tensor_eenv_loops.hpp:525
Definition: tensor_eenv.hpp:9
void scadd(MPLBASE &mpl, const C &c)
Definition: tensor_convert.hpp:15
int degree(const bernstein< C > &p)
Definition: tensor_bernstein.hpp:73
tensor::eenv eenv
Definition: tensor_convert.hpp:12
UPOL convert(const MPOL &p, unsigned v)
Definition: tensor_convert.hpp:73
Definition: shared_object.hpp:61
void scadd(A *a, const B &b, unsigned n, int s=1)
Definition: tensor_vctops.hpp:62
const C & c
Definition: Interval_glue.hpp:45
double C
Definition: solver_mv_fatarcs.cpp:16
Definition: array.hpp:12
void conv(MPLBASE0 &r, const MPLBASE1 &a)
Definition: tensor_convert.hpp:62
Home