1 #include <bernstein/bernstein.h>
2 #include "ex_convert.h"
5 using namespace bernstein
;
7 #define ALLOC(type) (type*)malloc(sizeof(type))
9 static evalue
*ex2evalue(const ex
& poly
, const exvector
& params
, int pos
)
11 if (pos
>= params
.size()) {
12 evalue
*c
= ALLOC(evalue
);
15 assert(is_a
<numeric
>(poly
));
16 numeric2value(ex_to
<numeric
>(poly
).numer(), c
->x
.n
);
17 numeric2value(ex_to
<numeric
>(poly
).denom(), c
->d
);
21 evalue
*v
= evalue_var(pos
);
22 evalue
*sum
= ex2evalue(poly
.coeff(params
[pos
], poly
.degree(params
[pos
])),
24 for (int i
= poly
.degree(params
[pos
])-1; i
>= 0; --i
) {
25 evalue
*t
= ex2evalue(poly
.coeff(params
[pos
], i
), params
, pos
+1);
34 evalue
*ex2evalue(const ex
& poly
, const exvector
& params
)
36 return ex2evalue(poly
, params
, 0);