Question: ... use codegen without redundency in the code output...

We use maple to generate all of our computational bits, dump this out to header files, and include this in our code base. A lot of the code that is generated is redundant so it would be nice to have codegen[C] know, or at least be able to be told, to optimize the entire code being dumped to the same header file. Is this possible? Examples follow... " ..... DCb := array(1..3): lp:='lp':ip:='ip':m:='m':ap:='ap':jp:='jp':a:='a':l:='l':j:='j':i:='i':k:='k':kp:='kp': for ip from 1 to 3 do DCb[ip] := sum(sum(sum(sum(sum(gd[ip,jp]*gu[ap,lp]*jacu[m,lp]*jacu[a,ap]*dJ[jp,m,a],m=1..3),jp=1..3),lp=1..3),ap=1..3),a=1..3): od: DCx := array(1..3): for i from 1 to 3 do DCx[i] := DCA[i] - DCa[i]: od: DCr := array(1..3): for i from 1 to 3 do DCr[i] := DCB[i] - DCb[i]: od: codegen[C]([dest_comp[0] = DCx[1]],optimized,precision=double,filename=`transform_.h`): codegen[C]([dest_comp[1] = DCx[2]],optimized,precision=double,filename=`transform_.h`): codegen[C]([dest_comp[2] = DCx[3]],optimized,precision=double,filename=`transform_.h`): ..... " and when the code comes out, I have something like: " t1 = metric_fields[GXX]; t2 = metric_fields[GZZ]; t4 = metric_fields[GXZ]; t5 = t4*t4; t6 = t1*t2-t5; t7 = t1*t6; t8 = metric_fields[GYY]; t9 = t1*t8; t11 = metric_fields[GYZ]; t12 = t11*t11; t14 = metric_fields[GXY]; t15 = t14*t14; t17 = t14*t4; t22 = 1/(t9*t2-t1*t12-t15*t2+2.0*t17*t11-t5*t8); .... t303 = t146*t31; t331 = -t291*t115*t28*t241+2.0*t300*t301*t40*t303+2.0*t300*t301*t37*t303- t129*t115*t28*t169-t260*t186*t71-t260*t186*t100-t265*t221*t26*t90-t270*t186* t157-t270*t186*t170-t106*t35*t37*t108-t275*t221*t26*t180; dest_comp[0] = -t24*t27*t71+t7*t22*t75*t34*t90-t24*t27*t100-t106*t35*t40* t108+t114*t115*t39*t70-t121*t62*t122-t114*t115*t28*t99+t129*t115*t39*t137+2.0* t142*t143*t40*t147+orig_comp[2]*spher_a*t27+t245+t295+t331; " Now when it goes to generate dest_comp[1], the code is ~70% the same. How do I avoid this and just have the entire code bit optimized? Thanks, jon
Please Wait...