codegen[prep2trans] - prepare a Maple procedure for translation
codegen[split] - prepare a Maple procedure for automatic differentiation
codegen[horner] - convert formulae in a procedure to horner form
|
Calling Sequence
|
|
prep2trans(f)
horner(f, x)
split(f)
split(f, x)
|
|
Parameters
|
|
f
|
-
|
Maple procedure
|
x
|
-
|
list or set of symbols
|
|
|
|
|
Description
|
|
•
|
The prep2trans function is used to transform certain symbolic expressions into forms suitable for translation into a target language such as C or Fortran. For example, piecewise expressions are translated into if statements, symbolic sums are translated into for loops.
|
•
|
The horner function takes as input a Maple procedure and a variable or list or set of variables, and converts all formulae in the procedure to Horner form in x.
|
•
|
The split function is used to break up certain symbolic expressions into computation sequences suitable for automatic differentiation. Long products and complicated compositions are broken up into computation sequences. If the second argument x is specified, it specifies the independent variables, the variables that the function f will be differentiated in.
|
•
|
The command with(codegen,prep2trans) allows the use of the abbreviated form of this command.
|
•
|
The command with(codegen,split) allows the use of the abbreviated form of this command.
|
•
|
The command with(codegen,horner) allows the use of the abbreviated form of this command.
|
|
|
Examples
|
|
>
|
|
>
|
f := proc(x) piecewise(x<0,0,x<1,x,x>1,2-x,0) end proc;
|
| (1) |
>
|
|
| (2) |
>
|
f := proc(x) local s; sum(x^i/i!,i=0..n) end proc;
|
| (3) |
>
|
|
| (4) |
>
|
f := proc(n,A) local i,j; sum(sum(A[i,j],i=1..n),j=1..n) end proc;
|
| (5) |
>
|
|
| (6) |
>
|
h := proc(x,y,z) 1-2*x*y-x*y^2*z*(1-x) end proc;
|
| (7) |
>
|
|
| (8) |
>
|
|
| (9) |
>
|
|
| (10) |
>
|
g := proc(x,y,t) 2*sin(x^2*y)*exp(-t^2) end proc;
|
| (11) |
>
|
|
| (12) |
>
|
|
| (13) |
|
|