Question: piecewise and prep2trans troubles

Hi,

 

I'm using Maple versions 9.5 and 14.

 

I have a quite complicated functtion defined by means of a piecewise statement. Translation of that function into C code is required, so I tried to use CodeGeneration[C] and codegen[prep2trans]. The help of Maple version 9.5 tells me that the prep2trans command isneccessary to get the job done. It's about converting the MAPLE piecewise instruction into a  if ... then ... else if ... end if, that can be converted into C code.

 

It's no problem to reproduce the examples

codegen[prep2trans](proc(x) piecewise(x<0,x^2,2*x) end proc);

 

and

f := proc(x) piecewise(x<0,x^2,2*x) end proc;

codegen[prep2trans](f);

 

but I want something like

a := x->piecewise(x<0,x^2,2*x);

g := proc(x) a(x) end proc;

codegen[prep2trans](g);

 

I doesn't work, but I cannot see where's my mistake. Is there any way to fix it and use arbitrary functions like a(x)?

 

TIA

- Christoph

Please Wait...