## Monday, August 17, 2015

### TI-84 Plus: Picking List Elements Using a Logical List and Matrix By-Element Multiplication

Picking List Elements Using a Logical List

The program BOOLLIST picks out elements from a source list based on a logical list (a list that consists of 0s and 1s).  0 represents  FALSE (do not pick) and 1 represents TRUE (pick).

Note, that weird looking L is not the L character, but is represents the small "L" character.  This is accessed from [2nd], [stat] (list), OPS sub-menu, select B for "L" (the last option in this sub-menu).  On this listing, I will bold the "L".

TI-84 Plus:  BOOLLIST

Input "SOURCE LIST=",A
Input "LOGICAL LIST=",B
sum(B)→S
S→dim(C)
1→I
1→J
dim(A)→A
dim(B)→B
For(K,1,A)
If B(J)=1
Then
A(K)→C(I)
1+I→I
End
1+J→J
If J>B
1→J
End
Pause C

Matrix by Element Multiplication

In R, the multiplication operator (*) multiplies matrices element-by-element.  To get the proper linear-algebra multiplication of matrices, use the %*% operator.  The program MATMLEM implements the former method.

Example:
[A] = [[ 1, 2 ] [ 3, 4 ]]
[B] = [[ 4, 3 ] [ 2, 1 ]]
Running MATMELM returns the matrix [[ 4, 6 ][ 6, 4 ]].

Variables [H], [I], and [J] are used for calculations.  Also, like BOOLLIST above,  the weird looking L is not the L character, but is represents the small "L" character.  This is accessed from [2nd], [stat] (list), OPS sub-menu, select B for "L" (the last option in this sub-menu).  On this listing, I will bold the "L".

TI-84 Plus:  MATMELM

Disp "MATRIX MULTIPLY"
Disp "BY ELEMENT"
Input "[H]=",[H]
Input "[I]=",[I]
dim([H])→H
dim([I])→I
If H(1)≠I(1) or H(2)≠I(2)
Then
Disp "INVALID"
Stop
End
[H]→[J]
For(H,1,H(1))
For(I,1,H(2))
[H](H,I)*[I](H,I)→[J](H,I)
End
End
DelVar H
DelVar I
Disp "[J]="
Pause [J]

I am about half way through the R introduction programming course.  Time flies by when you are having fun.

Eddie

This blog is property of Edward Shore.  2015.