next up previous
Next: Where to Find It Up: How to Use the Previous: Arrays

Programming

Every program on the HP48G/GX must be inclosed by a pair of triangular braces, tex2html_wrap_inline1341 . This section has two demonstration programs. The first program will take a square matrix, A, a positive integer k, and compute the tex2html_wrap_inline1347 power of A. The second program will build a square matrix whose entries are the values of a function at prescribed points. Note, some of the program lines are ended with a dot and a phrase in italic font. These endings are for explanatory purposes only. They are not part of the code and should not be entered into a program.

<<
tex2html_wrap_inline1353 A K tex2html_wrap_inline1355 store matrix and power as local variables
<<
A SIZE 1 GET IDN tex2html_wrap_inline1355 determine dimension of A and get same
tex2html_wrap_inline1355 size identity matrix
K FOR I A * tex2html_wrap_inline1355 start FOR loop to compute powers of A
NEXT
>>
>>

The structure of the program is fairly simple, however there are several pieces of syntax that need some explanation. If the loop is read as, For I from 1 to K

that piece of the program becomes clear. Note: right after the local variables are created another pair of triangular braces appear. The local variables are recognized only within this succeeding pair of braces, and these braces must be placed after local variables are created. Save the program as A.K.

To use this program place the square matrix whose tex2html_wrap_inline1347 power you want to compute on stack level 2 and the integer k on level 1. Then push the menu botton corresponding to A.K.

Using the HP48G/GX debugger, it is possible to run this program a step at a time. Push the keys: tex2html_wrap1405 tex2html_wrap1103 tex2html_wrap1409 . Place a square matrix, 2 by 2 is convenient, in stack level 2, and the power k=3 in stack level 1. Now place A.K within tick marks on the command line. Push tex2html_wrap1411 and then repeatedly push tex2html_wrap1413 to step through the program one step at a time.

Our second program will construct a square matrix whose entry in the tex2html_wrap_inline1371 row and tex2html_wrap_inline1373 column is tex2html_wrap_inline1375 .

<<
tex2html_wrap_inline1353 N tex2html_wrap_inline1355 create local variable which equals size of matrix
<<
N FOR I
N FOR J ` tex2html_wrap_inline1385 ' tex2html_wrap_inline1387 NEXT
tex2html_wrap_inline1389 tex2html_wrap_inline1353 ARRY tex2html_wrap_inline1355 create tex2html_wrap_inline1395 row
NEXT
N ROW tex2html_wrap_inline1353 tex2html_wrap_inline1355 build a matrix of N rows
>>
>>

Examine this program with the the HP48G/GX debugger also.


next up previous
Next: Where to Find It Up: How to Use the Previous: Arrays

Mike Stecher
Thu Mar 21 09:53:31 CST 1996