11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

204 • Chapter 5: Numerical <strong>Programming</strong> in Maple23 a 2, 2 − 1 3If you call det from inside a call to evalhf, Maple uses the value 0for the unassigned entry, a[2,2].> evalhf( det(a) );−0.333333333333333314evalhf passes arrays by value, so the (2,2) entry of a is still unassigned.> a[2,2];a 2, 2If you want evalhf to modify an array that you pass as a parameterto a procedure, you must enclose the name of the array in a var construct.The var construct is special to evalhf and is necessary only if you wantevalhf to modify an array of numbers that is accessible at the sessionlevel.> evalhf( det( var(a) ) );−0.333333333333333314Now a is an array of floating-point numbers.> eval(a);[0.666666666666666629 , 0.750000000000000000][0.444444444444444420 , 0.]The evalhf command always returns a single floating-point number,but the var construct allows you to calculate a whole array of numberswith one call to evalhf. Section 6.7 illustrates the use of var to calculatea grid of function values for plotting.You can also create arrays of hardware floating-point values directlywith the Array command. Proper use of this command can save significantamounts of time, especially in plotting routines, which rely heavily on

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!