[7.26] Dim() Functions Slow Down With Lists And Matrices With Large Elements; [7.27] Getmode() Returns Strings In Capital Letters - Texas Instruments TI-89 Tip List

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

Advertisement

While entering the command lines, use [F2] [1] to make each line a command line. The first line sets
the folder to Main. The second line sets the mode to Approximate, which is how I want to test cnd().
The next three lines split the screen horizontally, and put the text editor in the top window, and the
home screen in the bottom window. This is just personal preference. The next four lines execute my
test calls. Note that I subtract the actual desired answer from the cnd() result, so I can quickly see if it
is working: all the results should be near zero. The last line sets the split screen mode back to Full.
Whenever I want to use this test script, I use [APPS] [8] [2] to open the cndtest text file, then [F4]
(Execute) to execute each line.
It is not necessary to enter each command line in the text file. Instead, you can use the instructions on
page 94 of the 89/92+ Guidebook to copy most of the commands from the home screen into a text file.
However, this won't necessarily work with the split screen commands, as the setMode() functions to
set the Split 1 application won't work, of course, if you haven't yet created the cndtest text file.
Of course, you can automate this testing in another way: by creating a program that does the same
operations as the text file.

[7.26] dim() functions slow down with lists and matrices with large elements

There are three 89/92+ functions that return the sizes of lists and matrices: dim(), rowdim() and
coldim(). These functions quickly return the dimensions, even for large lists and matrices, as long as
the elements in the list or matrix are relatively small. However, if the elements are large, these
instructions take a long time to return the dimensions. This is true even if the number of elements is
small. If the elements are too large, a "Memory" error message occurs.
As an example, I wrote a program that created a list with only 70 elements, but the size of the list is
about 24K bytes. The elements are high-order polynomials. On my 92+, HW2, AMS 2.04, dim() takes
over 33 seconds to return the size of this list. If I convert the list to a single-column matrix, rowdim()
takes over 35 seconds to return the row dimension. If the size of the list increases to 100 elements and
about 62K, dim() fails and returns a "Memory" error message.
This issue is particularly relevent if you create lists or matrices with large elements, and need to test
the dimension in a function that returns a list element, to verify that the matrix index is valid. The whole
point of saving large expressions in a list is to be able to quickly return them, instead of recalculating
them each time. The purpose is defeated if dim() takes 30 seconds to determine if the index is valid.
One potential solution to this dilemma is to use the conditional try...else...endtry structure, to access
the list element and trap the error if the index is out of range. However, try...endtry is not allowed in
functions!

[7.27] getMode() returns strings in capital letters

The setMode() documentation on page 496 of the 89/92+ User's Guide shows the setMode()
arguments as a mixture of upper-case and lower-case letters, for example, the settings strings for
"Angle" are "Radian" and "Degree". However, getMode("angle") returns the setting in all capital letters,
such as "RADIAN" and "DEGREE". This is significant if your program uses getMode() to test the
current mode setting. This code will never execute either subrad() or subdeg():
if getmode("angle")="radian" then
subrad()
elseif getmode("angle")="degree" then
7 - 25

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents