Texas Instruments TI-89 Tip List page 335

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

Number of rows
The overhead is about 0.7 seconds for the largest tested matrix. This may not be critical for single
function calls, but it is significant if the function is called repeatedly, as is the case when using the
numeric solver, performing numeric integration, or plotting the function. For example, if the 200 x 3
matrix is passed to a function which is plotted at each of the 240 display pixel columns of the TI-92
Plus, the overhead is about 2.7 minutes.
If more than one matrix is used as a function argument, the overhead predictably increases to about
the sum of the individual overheads of each matrix. For example, if the arguments are two matrices
with dimensions of 50 rows x 2 columns, and 50 rows x 3 columns, the total overhead is about 149 mS
+ 191 mS = 340 mS.
The overhead may be reduced by passing the matrix by reference, instead of by value. For the timing
results and model equation above, the matrix was passed by value, that is, the matrix itself was passed
as the function argument. A typical function call is
f(matrix)
To pass the matrix by reference instead of value, the function argument is the matrix name as a string:
f("mat_name")
With the value method, the element [2,3] is accessed with
mat[2,3]
With the reference method, the same element is accessed using indirection:
#mat_name[2,3]
where mat_name is the name of the matrix. Indirection, a feature built into TI Basic, is accomplished
when the number character '#' precedes a variable name, for example, #var. This expression does not
return the value of var, instead, it returns the value of the variable whose name is stored as a string in
var. For example, if var contains the string "var2", and the value of variable var2 is 7, then #var returns
7.
The reference method works only when the matrix is a global variable. A variable which is local in a
program or function cannot be accessed by any other function which is called.
These two test routines demonstrate the overhead reduction when using the reference method.
Number of columns
nr
nc
10
1
10
4
100
1
100
4
200
1
200
3
3
200
5
5
0
10
20
20
(call by value)
(call by reference)
(access by value)
(access by reference)
Execution time
per call
42.0 mS
66.9 mS
191 mS
438 mS
355 mS
685 mS
538 mS
50.5 mS
117 mS
373 mS
7 - 46

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents