[GiNaC-list] operations modulo 2

Chris Dams Chris.Dams at mi.infn.it
Wed Jan 4 11:19:48 CET 2006


Dear Kostas,

On Wed, 2006-01-04 at 05:31 +0200, Kostas Patsakis wrote:

If you post code, could you please post compilable code? I.e., inclucing
a main function.

> ex expr_simpl(const ex & e){

Why not ex expr_simpl(ex e) and have the compiler make a local copy of e
instead of yourself?
    
>     ex a;
>     a=expand(e);
>     map_rem_quad_evens rem_quad_evens(g_smbl("k0"));    
>     a=rem_quad_evens(e);

I think this should have been a=rem_quad_evens(a).

>         a=simpl(a);
>         a=rem_quad_evens(e);

Insert same remark here.

>     return a;    
> }

> lst expr_simpl(const lst & a){
>     int i;
>     lst tmp;
>     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;
>     for (i=0;i<word_len;i++)
>         tmp[i]=expr_simpl(a[i]);
>     return tmp;
> }

This looks error-prone and strange. Why not write

lst expr_simpl(const lst & a){
    lst tmp;
    for (lst::const_iterator i=a.begin(); i!=a.end(); i++)
        tmp.append(expr_simpl(*i));
    return tmp;
}

instead?

Best,
Chris



More information about the GiNaC-list mailing list