Pre-processing large mathematical expressions for gmp?

Jim Skea jimskea at gmail.com
Tue Jun 15 02:32:02 CEST 2010


Does anyone know of a pre-processor that would take a long mathematical
expression and convert it into the equivalent set of gmp function calls,
creating any temporary variables as necessary?

Something that would take, as a small example
y = y + h6*(k1+2*k2+2*k3+k4)

 and produce

 mpf_mul_ui(t0, k3, 2);
 mpf_mul_ui(t1, k2, 2);
 mpf_add(t2,t0,t1);
 mpf_add(t3,t2,k1);
 mpf_add(t4,t3,k4);
 mpf_mul(t5,t4,h6);
 mpf_add(y, y, t5);

 Failing that, any idea about how to do this (using yacc? bison?) other than
writing a dedicated program?

Thanks in advance.

Jim


More information about the gmp-discuss mailing list