Back to index

## Owner's Manual Addendum

Hidden Matrix Functions

By Joseph K. Horn

The HP-42S Owner's Manual
fails to mention the existence of three useful matrix functions:

[MIN] - Gets a column's smallest element.

[MAX] - Get a column's lagest element.

[FIND] - Searches a matrix for a given element.

Since these functions are not mentioned in the manual, it can be
assumed that they are not supported by Hewlett-Packard. They were
discovered independently on November 9, 1988 by Joseph K. Horn, who
also wrote this addendum.

Do not contact the Hewlett-Packard Company regarding these unsupported
functions. Further information about your HP-42S can be obtained from
user clubs.

These hidden matrix functions are described in detail below.

### Column Minimum

To find the value and location of the smallest
element in one column of a matrix use the [MIN] function. The
matrix to be searched is specified by the INDEX function (see the Owner's Manual, page 223). The
column to be searched is specified by the value of index J, and the search proceeds from
index I to the bottom of the
column.

To get a column's smallest element:

1. Index the matrix: INDEX (name).

2. Set IJ to
locate the beginning of the search: row
ENTER column
STOIJ

3. Execute [MIN].

4. Find the element's value in the X
register, and its row number in the Y
register.

The old X and Y are lifted to Z and T; the old Z and T are lost. Only
the element's row number is returned, because only one column (set by
pointer J ) is searched.

If the smallest element is found in more than one location, [MIN]
returns the location of the last
one found (nearest the bottom of the column).

If you wish to search more than one column (for example to find the
smallest element of an entire matrix) you may redimension the matrix,
search it, then redimension it back again. Redimensioning can be
performed by the DIM function (see page 217).

### Column Maximum

The [MAX] function operates exactly like [MIN] (see above), except that
it returns the largest element
in the column.

Combining these functions with the R<>R function allows rapid
sorting of the rows in a matrix into ascending or descending order
using one column as the sorting key.

### Matrix Search

To search for a particular value in a matrix and find out its location,
you can use the [FIND] function.

1. Index the matrix: INDEX (name).

2. Place the value to be searched for in the X register

3. Execute [FIND].

4. If performed from the keyboard, Yes
indicates that the number was found, and No indicates that the number was
not found.

5. If performed in a program, the do-if-true
rule is followed (see page 149); that is, if the value is not found then the next program
line is skipped.

6. If the value is found, then the pointers IJ are set to its location, and the
search immediately ends. If the value is not found, IJ are not affected.

Copyright
(C) 1988, Joseph K. Horn.

(This addendum was initially published in the HPX Exchange V1N6
August/December 1988 and in the HPCC Datafile V8N7. It is reproduced
here with the author's permission)