ASTA@DULRUU51: matrix and list handling prgs for the HP48
Hello 48-Users,
This file contains some programs which handle with arrays and lists.
Short decsription:
------------------
A<-->L array to list and reverse
This program converts an array to the corresponding list and
viceversa, eg:
[[ 1 2 ] {{ 1 2 }
[ 3 4 ] <--> { 3 4 }
[ 5 6 ] { 5 6 }}
[ 3.5 -8 ] <--> { 3.5 -8 }
The format of the list must of course "looks" like an array, say
a list of list of numbers, each sublist with the same length.
trn Transponse
A generic transpose function for matrices and lists. The list must have
the format of a n*m-matrix, but is allowed to contain any object.
{{ 'foo' 'bar' 1.234 } {{ 'foo' << swap >> }
{ << swap >> { } "!" }} <--> { { } 'bar' }
{ "!" 1.234 }}
MOP Matrix Operation
Revised 'MOP' (Matrix OPeration): A program, which executes any
algebraic operation or program on every element of an 1 or 2
dimensional array.
usage:
======
2: <array>
1: <algebraic function> or <program>
MOP
2: <name of array>
1: <algebraic function> or <program>
MOP
e.g.:
=====
2: [[ 1 2.3 ]
[ -3 4.4 ]
[ 1 -1.1 ]]
1: 'LOG(SQR(X))-3'
MOP
2: [[ 1 2.3 ]
[ -3 4.4 ]
[ 1 -1.1 ]]
1: << IF X 1 < THEN X DUP R->C ELSE X END >>
MOP
2: '&DAT'
1: 'INV(X)'
MOP
2: '&DAT'
1: << X INV >>
MOP
The algebraic operation must have 'x' as argument. I know, this
sucks, but calling by reference like 'MOP(INV(<array>)*3-2)' is
not possible (or does anybody know a way ??)
& := the Sigma-sign
The name 'MOP' was created by Schrulli B. thanx ;-)
V<-->M vector to matrix and reverse
Converts a vector to a matrix and viceversa.
[ -9 2.3 4 ] <---> [[ -9 2.3 4 ]]
M->V matrix to vectors
Another "OBJ->" command. It puts all vectors of a matrix to the stack:
[[ 1 2.3 ] [ 1 2.3 ]
[ -3 4.4 ] ---> [ -3 4.4 ]
[ 1 -1.1 ]] [ 1 -1.1 ]
3
V->M vectors to matrix
The corresponding function to M->V It takes n vectors from the stack
and builds one matrix.
[ 1 2.3 ] [[ 1 2.3 ]
[ -3 4.4 ] ---> [ -3 4.4 ]
[ 1 -1.1 ] [ 1 -1.1 ]]
3
GETR get a row from a matrix
[[ 1 2.3 ]
[ -3 4.4 ] ---> [ 1 2.3 ]
[ 1 -1.1 ]]
1
GETC get a column from a matrix
[[ 1 2.3 ] [[ 1 ]
[ -3 4.4 ] ---> [ -3 ]
[ 1 -1.1 ]] [ 1 ]]
1
DELR delete a row from a matrix
[[ 1 2.3 ]
[ -3 4.4 ] ---> [[ -3 4.4 ]
[ 1 -1.1 ]] [ 1 -1.1 ]]
1
DELC delete a collumn from a matrix
[[ 1 2.3 ] [[ 2.3 ]
[ -3 4.4 ] ---> [ 4.4 ]
[ 1 -1.1 ]] [ -1.1 ]]
1
PUTR put a row to a matrix
Inserts or overwrites a vector into a matrix as a row.
A positive row-number indicates inserting, a negative overwriting.
[[ 1 2.3 ] [[ 0 0 ]
[ -3 4.4 ] [ 1 2.3 ]
[ 1 -1.1 ]] ---> [ -3 4.4 ]
1 [ 1 -1.1 ]]
[ 0 0 ]
[[ 1 2.3 ] [[ 0 0 ]
[ -3 4.4 ] ---> [ -3 4.4 ]
[ 1 -1.1 ]] [ 1 -1.1 ]]
-1
[ 0 0 ]
PUTC put a column to a matrix
Inserts or overwrites a vector into a matrix as a column.
A positive column-number indicates inserting, a negative overwriting.
[[ 1 2.3 ] [[ 0 1 2.3 ]
[ -3 4.4 ] ---> [ 0 -3 4.4 ]
[ 1 -1.1 ]] [ 0 1 -1.1 ]]
1
[ 0 0 0 ]
[[ 1 2.3 ] [[ 0 0 ]
[ -3 4.4 ] ---> [ 0 4.4 ]
[ 1 -1.1 ]] [ 0 -1.1 ]]
-1
[ 0 0 0 ]
-----------------------------------------------------------------------------
| General Student Board | asta@rz.uni-ulm.de | asta@rz.uni-ulm.dbp.de |
| c/o Ulli Horlacher | asta@dulruu51.bitnet | 50184::asta (DECnet/BelWUe) |
| University of Ulm | ----------------------------------------------------|
| D-7900 Ulm, Germany | "Waiting for the prompt" -Marillion |
-----------------------------------------------------------------------------