Question: Generating optimized C code from an array

Hi everybody.

 

I'm using Maple these days to generate C code. More precisely, I use Maple to calculate high order derivatives. For example, I know that :

dt( u(x,t) ) = a(x) * dx( u(x,t) ) + b(x) * dx( p(x,t) )

dt( p(x,t) ) = c(x) * dx( p(x,t) ) + d(x) * dx( u(x,t) )

and I ask Maple to calculate the 5th time-derivative of u using these 2 properties. But in fact, I use 8 variables instead of 2 and PDEs are far more complicated.

Finally, I get thanks to Maple expressions of time-derivatives for my 8 variables.

 

Now I want to generate C code from these expressions in order to calculate this quantities in a simulation code.

I create an array :

tab := convert( [dtu, dt2u ,dt3u, ..., dtp, dt2p, dt3p, ...], vector),

I transform it to a procedure :

tabproc := makeproc(tab);

and I ask Maple to generate optimized code using codegen :

C(tabproc,optimized);

 

But I get a problem here : Maple returns an error message like "improper subscript selector..." because of optimization. Without the 'optimized' option, it works fine. But I would like to have it optimized. Of course, I could create a procedure and generate code separatly for each expression (dtu, dt2u, ...). But the problem is that it would force me to compute several times the same variables in each procedure and I have strong cost constraints on my code.

 

I wonder if someone could help me solving this problem.

 

Thank you very much.

 

Marc

Please Wait...