Option hfloat in Procedures - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Procedures and Functions : options : option_hfloat

Option hfloat in Procedures

Calling Sequence

option hfloat   or   options hfloat



The hfloat option to a procedure forces all floating-point operations in a procedure to be performed using hardware floating-point values. Depending on the operations performed, this can significantly speed up execution of the procedure, at the cost of floating-point accuracy. Procedures that perform many floating-point operations or manipulate the contents of Arrays, Matrices, or Vectors of hardware floating-point values will benefit the most from this option.


Specifically, the hfloat option causes the following differences in the procedure's definition and execution:


Any floating-point constants appearing in the procedure body are converted into hardware floating-point values when the procedure is first created.


Numeric arguments passed to the procedure are converted into hardware floating-point values when the procedure is invoked.


Calls to evalhf made from within the procedure will return a hardware floating-point value, and thus will not incur a conversion to arbitrary precision floating-point form.


The differences, together with the rules for contagion of hardware floating-point values in expressions (see HFloat), will usually cause arithmetic operations in the procedure to be performed using hardware floating-point arithmetic.


The use of the hfloat option differs from using evalhf in a few ways:


When a procedure is executed within the evalhf environment, everything is performed using hardware floats, and the operations available are restricted to those that can be done using hardware floats. No other basic data types, such as integers or strings, are available.


The only data structures available within the evalhf environment are Arrays.


Performance of a procedure having option hfloat will generally be better than one operating with arbitrary precision floats, but usually not as good as a procedure operating within evalhf. But, a procedure with option hfloat has the full power of Maple available to it. All Maple operations, data types (except arbitrary precision software floating point), and data structures can be used in such a procedure.


The hfloat option cannot be used in conjunction with any of these other options: autocompile, builtin, call_external, and inline.


SineSignal := proc( freq :: numeric := 261.6255652,
                   amp :: numeric := 1.0,
                 { duration :: numeric := 1.0,
                   rate :: integer := 44100 } )
   option hfloat;
   local freq2pi := evalhf(freq * 2.0 * Pi);
                         sample->sin(freq2pi*(sample-1)/rate) * amp);





SlowSineSignal:=procfreq::numeric:=261.6255652,amp::numeric:=1.0,duration::numeric:=1.0,rate::integer:=44100optionno_options;localfreq2pi;freq2pi:=evalhf6.283185308*freq;AudioTools:-Create':-duration'=duration,':-rate'=rate,sample→sinfreq2pi*sample1/rate*ampend proc





See Also

evalhf, HFloat, Procedure options, Procedures

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam