sorry for bothering the list again but I would appreciate some help.<br>
I'm trying to do operation(addition,multiplications) with multivariate
polynomials. The variables cat take values 0 and 1 and I'm working with
about 30 variables k0,k1...<br>
So since 0^2=0 and 1^1=1<br>
I make the following substistution(written for ginsh) subs(e,$0^$1==$0).<br>
Since 2*x=0 mod 2 I need to do parse all the coeffiients mod 2.<br>
The problem is that even if I expand the expressions ginac(or at least
my code to be honest) does not appear to expand my expressions halting
immediately all my calculations<br>
e.g. this list of expressions is an output that was supposed to have been expanded and have been reduced mod 2<br>
temp={1+k4+k5,(1+k5)*(1+k4)+k6,(1+k5)*(1+k6)*(1+k4)+k7,(1+k7)*(1+k5)*(1+k6)*(1+k4)+k8,1+k9+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4),1+k10+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4)),k10+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10,1+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10*(1+k10+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4)))+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10,k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10*(1+k10+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4)))+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10,k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10*(1+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10)*(1+k10+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))),k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10*(1+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10)*(1+k10+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))),k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10*(1+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10)*(1+k10+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))),k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10*(1+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10)*(1+k10+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))),1+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10*(1+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))*k10)*(1+k10+k9*(1+(1+k7)*(1+k8)*(1+k5)*(1+k6)*(1+k4))),0,0,1,0,1,0,1,0,0,1,1,1,0,k0,k1,k2,k3,1+k4}
<br>
Using ginsh is obvious that this has not happened.<br>
Cutting and pasting code from manual has done some work but not much:(<br>
<br>
This is what I've got so far:<br>
<br>
const symbol & g_smbl(const string & s){<br>
static map<string, symbol> directory;<br>
map<string, symbol>::iterator i = directory.find(s);<br>
if (i != directory.end())<br>
return i->second;<br>
else<br>
return directory.insert(make_pair(s, symbol(s))).first->second;<br>
}<br>
<br>
struct map_rem_quad_evens : public map_function {<br>
ex var;<br>
ex tmp,tmp1;<br>
numeric coeff;<br>
<br>
map_rem_quad_evens(const ex & var_) : var(var_) {} <br>
ex operator()(const ex & e){<br>
if (is_a<add>(e))<br>
return e.map(*this); <br>
if (is_a<mul>(e))<br>
return e.map(*this);<br>
else if (is_a<power>(e) && e.op(0).is_equal(var))<br>
return e.op(0);<br>
else if (is_a<numeric>(e)){<br>
coeff=ex_to<numeric>(e);<br>
if (coeff>0) return mod(coeff,2);<br>
else return e.map(*this);<br>
}<br>
else<br>
return e;<br>
}<br>
};<br>
<br>
<br>
ex simpl(const ex & e){<br>
ex tmp;<br>
tmp=subs(expand(e),pow(wild(),wild(1))==wild());<br>
return tmp;<br>
}<br>
<br>
ex expr_simpl(const ex & e){<br>
<br>
ex a;<br>
a=expand(e);<br>
map_rem_quad_evens rem_quad_evens(g_smbl("k0")); <br>
a=rem_quad_evens(e);<br>
a=simpl(a);<br>
a=rem_quad_evens(e);<br>
return a; <br>
}<br>
<br>
lst expr_simpl(const lst & a){<br>
int i;<br>
lst tmp;<br>
tmp= 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;<br>
for (i=0;i<word_len;i++)<br>
tmp[i]=expr_simpl(a[i]);<br>
return tmp;<br>
}<br>
<br>