HP Forums
42S Manual Addendum: Hidden Matrix Functions - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: Articles Forum (/forum-14.html)
+--- Thread: 42S Manual Addendum: Hidden Matrix Functions (/thread-8887.html)



42S Manual Addendum: Hidden Matrix Functions - Joe Horn - 08-23-2017 08:57 PM

                                HP-42S
                       Owner's Manual Addendum:

                     +-------------------------+
                     | Hidden Matrix Functions |
                     +-------------------------+

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

[MIN] Gets a column's smallest element.

[MAX] Gets a column's largest element.

[FIND] Searches a matrix for a given element.

Important note: the square brackets are included in the names of
these functions; in other words, it's not FIND, it's [FIND].

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].  (Note: the brackets are in the second alpha menu.)

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 any
desired 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 to be searched: 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 it 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 pointers IJ are set to its location,
   and the search immediately ends.  If the value is not found, IJ are
   not affected.