Texas Instruments TI-89 Tip List page 98

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

Advertisement

Find the factorial of each integer element
Find the sine of each element
(also works for cos(), ln(), etc)
Differentiate each array element with respect to x
In general, more complex operations may be handled by nested for-loops that manipulate each array
element. Or, in some cases, it is more efficient to process the list elements in sequence. The function
below, transpos(), shows this approach.
transpos(arr,dims,i1,i2)
Func
©Example that transposes a rank-3 array on indices i1 and i2
©Bhuvanesh Bhatt (bbhatt1@towson.edu), Nov2000
Local i,tmp,arr2,dims2
If max(i1,i2)>dim(dims) or min(i1,i2)≤0:Return "Error: invalid indices"
newList(dim(arr))→arr2
listswap(dims,i1,i2)→dims2
For i,1,dim(arr)
m3aind(i,dims)→tmp
m3sto(m3rcl(tmp,dims,arr),listswap(tmp,i1,i2),dims2,arr2)→arr2
EndFor
arr2
EndFunc
Note that transpos() calls m3aind(), m3rcl() and m3sto(), as well as the listswap() function described in
tip 3.18. These examples show typical results for transpos().
transpos({a,b,c,d,e,f,g,h},{2,2,2},2,3)
transpos({a,b,c,d,e,f,g,h},{2,2,2},1,2)
transpos() is limited to rank-3 arrays, but it can be extended by changing the function references
m3aind() and so on, as needed. Note that no error checking is done on the dims list or on the i1 and i2
input arguments, so make sure they are integers. As with a rank-2 array, the transpose function
changes the dimensions of the array: if a 1x2x3 array is transposed on the second and third indices,
the result is a 1x3x2 array. The dims2 variable in transpos() above gives the dimensions of the
resulting array.
If you are using Mathematica, note that regular cubic arrays in Mathematica can be converted to the
storage format used in this tip, with Flatten[array].
Bhuvanesh Bhatt has coded quite a few tensor functions and programs which use the representation
described in this tip. You can find them at his site, http://triton.towson.edu/~bbhatt1/ti/, in the Arrays
package. These functions include:
aInd(i,{dims})
Returns the array location corresponding to the ith list index for an array of dimensions dims
m1!→m3
sin(m1)→m3
(m1,x)→m3
{a,c,b,d,e,g,f,h}
returns
{a,b,e,f,c,d,g,h}
returns
3 - 16

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents