makeparam - Maple Help

codegen

 makeparam
 change a variable to be a parameter
 makeglobal
 make a variable to be a global variable
 declare
 declare the type of a parameter

 Calling Sequence makeparam(x, f) makeparam(x::t, f) makeglobal(x, f) makeglobal(x::t, f) declare(x::t, f)

Parameters

 x - symbol (variable) or list of symbols t - type - declaration of the variable f - Maple procedure

Description

 • The makeparam and makeglobal functions are used to make a variable to be a parameter, respectively global variable in the Maple procedure. If a list of variables is given, then all the variables in the list are made into parameters, respectively globals.
 • If a type t is specified the variable is given the specified type.  This can be used to declare the type of a variable.
 • The declare function is used to specify the type t for a variable x which is a parameter in the Maple procedure f.

Examples

 > $\mathrm{with}\left(\mathrm{codegen}\right):$
 > f := proc() local A; A := array(1..2); A[1] := x^2; A[2] := x^2; A end proc:
 > $g≔\mathrm{makeparam}\left(x,f\right)$
 ${g}{≔}{\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{≔}{\mathrm{array}}{}\left({1}{..}{2}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{1}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{2}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)
 > $\mathrm{declare}\left(x::\mathrm{numeric},g\right)$
 ${\mathbf{proc}}\left({x}{::}{\mathrm{numeric}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{≔}{\mathrm{array}}{}\left({1}{..}{2}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{1}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{2}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (2)
 > $\mathrm{makeparam}\left(x::\mathrm{numeric},f\right)$
 ${\mathbf{proc}}\left({x}{::}{\mathrm{numeric}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{≔}{\mathrm{array}}{}\left({1}{..}{2}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{1}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{2}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (3)
 > $\mathrm{makeglobal}\left(A,f\right)$
 ${\mathbf{proc}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{global}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{≔}{\mathrm{array}}{}\left({1}{..}{2}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{1}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{2}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (4)
 > $g≔\mathrm{makeparam}\left(A,f\right)$
 ${g}{≔}{\mathbf{proc}}\left({A}{::}\left({\mathrm{array}}{}\left({1}{..}{2}\right)\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{1}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{2}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (5)
 > $\mathrm{declare}\left(A::\left('\mathrm{array}'\left(1..2,\mathrm{numeric}\right)\right),g\right)$
 ${\mathbf{proc}}\left({A}{::}\left({\mathrm{array}}{}\left({1}{..}{2}{,}{\mathrm{numeric}}\right)\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{1}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{2}{]}{≔}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (6)