var - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

evalhf/var

passing arrays by value/result; var(name)

Description

 • The var construct is a placeholder for Maple array arguments passed as parameters to functions evaluated by evalhf.
 • For example,

$A:=\mathrm{array}\left(\mathrm{....}\right);$

$\mathrm{evalhf}\left(f\left(\mathrm{var}\left(A\right)\right)\right);$

 • The var array arguments are converted to hardware floating point. Then evalhf evaluates the function with this float array, and on return, the arguments are converted back into the Maple array. This achieves an effect similar to var arguments in Pascal function calls, but in reality it does call by value/result.
 • The var mechanism is the only mechanism available that will obtain an array result from a computation done by evalhf other than individual calls to compute each array entry.
 • If desired, an evalhf call can be passed an hfarray or rtable with datatype=float[8] or datatype=complex[8] instead of an array. These are truly passed by reference, and result in negligible overhead on entry to and exit from the evalhf environment.
 • This conversion process is only necessary when passing an array from Maple to an evalhf function call. Calls within functions already under evalhf evaluation do not need the var(..) feature.

Examples

 > f := proc(A,B) B[1]:= A[2] end proc:
 > $A≔\mathrm{array}\left(1..2,\left[3,4\right]\right):$$B≔\mathrm{array}\left(1..2,\left[0,0\right]\right):$
 > $\mathrm{evalhf}\left(f\left(A,B\right)\right)$
 ${4.}$ (1)
 > $\mathrm{print}\left(B\right)$
 $\left[\begin{array}{cc}{0}& {0}\end{array}\right]$ (2)
 > $\mathrm{evalhf}\left(f\left(A,\mathrm{var}\left(B\right)\right)\right)$
 ${4.}$ (3)
 > $\mathrm{print}\left(B\right)$
 $\left[\begin{array}{cc}{4.}& {0.}\end{array}\right]$ (4)
 > det := proc(A::array)     A[1,1]*A[2,2] - A[1,2]*A[2,1]; end proc:
 > $M≔\mathrm{Matrix}\left(2,\left[\left[\frac{1}{2},\frac{1}{4}\right],\left[\frac{1}{2},\frac{1}{3}\right]\right]\right)$
 ${M}{≔}\left[\begin{array}{cc}\frac{{1}}{{2}}& \frac{{1}}{{4}}\\ \frac{{1}}{{2}}& \frac{{1}}{{3}}\end{array}\right]$ (5)
 > $\mathrm{evalhf}\left(\mathrm{det}\left(M\right)\right)$
 ${0.0416666666666666574}$ (6)
 > $M$
 $\left[\begin{array}{cc}\frac{{1}}{{2}}& \frac{{1}}{{4}}\\ \frac{{1}}{{2}}& \frac{{1}}{{3}}\end{array}\right]$ (7)
 > $\mathrm{evalhf}\left(\mathrm{det}\left(\mathrm{var}\left(M\right)\right)\right)$
 ${0.0416666666666666574}$ (8)
 > $M$
 $\left[\begin{array}{cc}{0.500000000000000}& {0.250000000000000}\\ {0.500000000000000}& {0.333333333333333}\end{array}\right]$ (9)