CMtx49 v2.93 - Matrix Utilities for the HP49

Luis Morales Boisset - Madrid. Spain. 2001/10/24

 

[New in this version: Bug fixing and better support for Exact mode ]

1. Overview

This is a library intended to manipulate matrix column and rows.

It allows applying formulas and programs on a column or row basis. To do it on all the elements of the array or to apply in a column or row way actions like the ones DOSUBS or STREAM do over lists.

 

2. Disclaimer

The library is distributed as is and is subject to change without notice. No warranty of any kind is made with regard to the software or documentation. The author shall not be liable for any incidental error or consequential damages in connection with the software and/or the documentation.

CMtx49 can be freely distributed provided this manual is distributed with it without any modification. CMtx49 cant be used for any commercial purpose without written permission from the author. This implies the user shouldnt be charged for the use of this software.

Remember as well that I only work on RPN mode so no test is made for ALG mode. But the few times I try to deal with matrix on this mode makes me suppose it will be very complex to use in ALG mode if it will run.

English is not my native language so please excuse all my linguistic mistakes.

 

3. Backup

This software has been tested by me and seems to be safe but like always please backup your memory before trying it. Its done 90% in SysRPL and 10% UserRPL (commands like COL ROW) with MASD so if there is any bug I havent detected you could loose you data L

 

4. History and Credits

This software is directly based in one done for the HP48sx long time ago: CMAT which is available in www.hpcalc.org and been done in User RPL its mainly compatible with the HP49.

So in May1994 I did my first SysRPL version of that software for my old sx and use it a lot in laboratory calculations. Many years late comes the 49 and I start porting it to my new calc but opening for more features. For doing so Ive take a look in the features of Array21 and Stat03 programs for the GX (I really didnt use them only read their documentations).

So my credit goes for:

        Wes Hubert ( CMAT in 1991 ).

        Daniel Lopez Sancho ( Array21 in 1996 )

        Christian Meland ( Stat03 in 1996)

 

4.1 Version History

v2.93 Some bug in the support of Exact Mode fixed (thanks to Hermes Hernandez which makes me look for bugs).

v2.92 Added the command FMtx.

v2.6 First release to public.

 

 

5. Installation

This program is a library. Its number is 1746 which I hope is not used. To install it you should transfer it to your HP in binary mode. Recall its contents and store it in any of your ports. Now you can purge the variable from where you download it. Then you should restart your HP.

At this point you could access to its menu in the Lib menu [LS][2] hint [NXT] if necessary. Or using 1746 MENU.

To uninstall it you should do:

1746 DEATTACH [ENTER]

:port:1746 PURGE [ENTER]

Other way of accessing and uninstalling this library is with the 49s Filer which is pretty good in this. Look for it in the port were you stored it.

6. Command Description

 

CMtx:

This command its the main command of the library. It allow to compute formulas or programs in a row/column basis using column/rows values.

Its stack diagram looks like this:

Level 3

Level 2

Level 1

 

Level 1

[[data]]

%destiny

Symbolic

[[data]]

[[data]]

%destiny

Program

[[data]]

 

[[data]]

Symbolic

[[data]]

 

[[data]]

Program

[[data]]

 

[[data]]

Equation

[[data]]

 

where [[]] means and real, complex or symbolic array, % means real (>0), symb is an algebraic and prg is a program. Equation means an algebraic with an = inside.

The matrix is the set of data over the symb/prg is going to be evaluated. The real represent the column/row in with the result values are going to be left. It could be any of the existing columns/rows or a bigger one (if its bigger than size + 1 zeroes columns/rows will be added. If its not provided the next new column is used. And the symb/prg is what is going to be evaluated.

The symbolic or program should use the next syntax to refer to the column or row values: C### or R###. For example:

will give

The reason of doing a row processing is the presence of C## values.

Instead if we do:

will give


So the command takes a look in the kind of values used to determine the way of processing. In the other hand you cant use C### and R### in the same symbolic or program.

You can use any type of array and it manages it properly. For example with exact mode we will get:

will return

Or in approx mode

returns

In the case of a program it should take no arguments and return one argument.

NOTE:

Really the stack level 1 is what its going to be kept. The rest of the stack its not modified nor used by the program during the process but cleaned before finish (cleaned the process stack, not the previous stack that remains unmodified). So really you can use it for your own. I dont have any example in mind but you can see it in the next example:

 

To show that the normal stack is protected if you do

you get an too few arguments error ;)

END NOTE.

 

 

As you see you can specify the column or row where the results will be left or you can omit it and get the result in a new one. There is another way of set this. If you use the symbolic way you can define an equation (symbolic with = inside). If you provide an equation with C## or R## alone in one or the other side this will be interpreted like the destination set.

For example:

or

will return

 

 

The values ### should be in the range 0 .. Max. Where Max is the maximum of the array size (in the dimension of process) and the final column. Any other values with be rejected and treated as a constant C###. In this sense the first example have a max of 5 ( size 3 and final 5 -> max 5).

 

DOArray

This command is for an array that DOLIST is for a list. It applies to each element of the array the program provided. Its stack diagram is:

Level 2

Level 1

 

Level 1

[[data]]

Program

[[data]]

 

The program should take only one argument and return only one argument.

[Here take as well place the same noted above.]

Example:

 

RowSTREAM

This command does for each row of the array what STREAM does for a list. Leaving the result in the next column (new column added). It follows the same syntax that STREAM but with an array. For safety it really uses the STREAM command over a list with the row contents. The speed improvements is done in the way the matrix is manipulated from array to list for each row and reconstructed.

Stack Diagram:

Level 2

Level 1

 

Level 1

[[data]]

Program

[[data]]

 

Example

returns

ColSTREAM

This command is the same than the above but does the process over each column of the array. Its stack diagram is the same.

Level 2

Level 1

 

Level 1

[[data]]

Program

[[data]]

 

Example:

return

 

RowSUBS

Like you guest this is a command that applies a DOSUBS to each row of the array. Of course it uses the same stack diagram that DOSUBS except an array instead of a list. This one, like DOSUBS does, modifies the whole array.

Syntax:

Level 3

Level 2

Level 1

 

Level 1

[[data]]

%num

Program

[[data]]

 

example:

gives

In this one like I use the DOSUBS command you have access to the ENDSUBS and NSUB commands inside the program. For each row of course.

 

ColSUBS

This one does the same over each column.

Level 3

Level 2

Level 1

 

Level 1

[[data]]

%num

Program

[[data]]

 

 

 

FMtx

This program allow you to filter rows/columns by and algebraic or program which can use the values of the column/rows. It follows closely the functionality of CMtx. Allowing you to use all the power of that one. The difference is that the value or the program is used to filter instead of stored in a column/row. If the alg/prog return 0 the row/column is eliminated from the array in any other case its kept.

The syntax is pretty the same than CMtx except that you dont specify the final col/row like in that one.

Level 2

Level 1

 

Level 1

[[data]]

Symbolic

[[data]]

[[data]]

Program

[[data]]

 

 

For example:

gives

If no row/column pass the filter/condition the a real zero is returned:

returns

 

 

6.1 Utility Commands

Now comes a set of extra command that can only be used inside a program to be evaluated by the above commands. They are intended to extend the flexibility of them and to allow complex ideas.

They will return an error if executed outside the above processing commands.

ColCM

This command return the value of the column provided as argument in the row been processed. Really is the same as C### but with an argument. This really gives flexibility due to the possibility of calculate the column to be used in CMtx.

The syntax is

Level 1

 

Level 1

%col

inside CMtx or FMtx

Ob(col)

%col

inside CMtx or FMtx but if col doesnt exists

Error

%col

if outside CMtx or FMtx

Error

 

The first example I gave could be written:

gives

You can use C## and ColCM syntax in the same program but not R##.

One interesting example could be:

returns

This command can only be used inside CMtx programs.

 

RowCM

This is the same as above command but for column processing. Like R##.

So you can use C## and ColCM or R## and RowCM but not to mix them.

The syntax is

Level 1

 

Level 1

%row

inside CMtx or FMtx

Ob(row)

%row

inside CMtx or FMtx but if col doesnt exists

Error

%row

if outside CMtx or FMtx

Error

 

This command can only be used inside CMtx programs.

 

ColCMSto

This command is intended for complex trickies. It allow you to modify instead of retrieve the value of a column of the row been processed. With it you can apply more than one calculation to one process. Its useful in those cases with complex formulas where you want to keep and intermediate value and want to do it in one process.

The syntax is

Level 2

Level 1

 

Level 1

Ob

%col

inside CMtx or FMtx

Nothing

Internally modifies the content of that column in the current row

Ob

%col

inside CMtx or FMtx but if col doesnt exists

Error

Ob

%col

if outside CMtx or FMtx

Error

 

As an example you can swap to columns:

returns

In this case you should care in the order of the action because the modification is done immediately. So:

returns

This command can only be used inside CMtx programs.

 

RowCMSto

The same but in the other direction.

The syntax is

Level 2

Level 1

 

Level 1

Ob

%row

inside CMtx or FMtx

Nothing

Internally modifies the content of that row the current column

Ob

%row

inside CMtx or FMtx but if col doesnt exists

Error

Ob

%row

if outside CMtx or FMtx

Error

 

This command can only be used inside CMtx programs.

 

EndCMtx

This command it the same than ENDSUBS but for CMtx, DOArray and the rest. It gives the number of sets to be processed. So if we use the C## way it will return the number of rows in CMtx. And the other way around.

In DOArray, RowSTREAM and RowSUBS it always gives the number of rows.

In ColSTREAM and ColSUBS it always gives the number of columns.

The syntax is

Level 1

 

Level 1

Nothing

inside CMtx (column proc), FMtx (column proc), DOArray, RowSTREAM, RowSUBS

%

Total number of rows

Nothing

inside CMtx (row proc), FMtx (row proc), ColSTREAM, ColSUBS

%

Total number of columns

Nothing

if outside the commands

Error

Really Ive doubt the proper name or way of doing this. But finally I decided this way maybe a bit cleaver but nearest the HP way of list processing.

An Example could be the one for ColCM:

result

 

NCMtx

Like NSUB this one give the index of the process of execution. In which row its now if we use C### or ColCM. In which column if I use R## or RowCM.

For DOArray, RowSTREAM and RowSUBS it always gives de actual row. And for ColSTREAM and ColSUBS the actual Column.

So the syntax is

Level 1

 

Level 1

Nothing

inside CMtx (column proc), FMtx (column proc), DOArray, RowSTREAM, RowSUBS

%

index of the current row

Nothing

inside CMtx (row proc), FMtx (row proc), ColSTREAM, ColSUBS

%

index of the current columns

Nothing

if outside the commands

Error

 

 

SizeCMtx

This one is the conjugate of EndCMtx. If the last give the row number this one gives you the size of each row.

The syntax is

Level 1

 

Level 1

Nothing

inside CMtx (column proc), FMtx (column proc), DOArray, RowSTREAM, RowSUBS

%

Total number of columns

Nothing

inside CMtx (row proc), FMtx (row proc), ColSTREAM, ColSUBS

%

Total number of rows

Nothing

if outside the commands

Error

 

An Example could be the one for ColCM:

gives

but now its size independent!

 

NDoa

This one could only be used in DOArray and give the column index of the process.

The syntax is

Level 1

 

Level 1

Nothing

inside DOArray

%

index of the current column

Nothing

if outside the commands

Error

Example:

result in

 

7. Final Remarks

Library is ID 1746. Its size is 3502 bytes and its checksum is #8EE6h.

The library have done in SysRPL but I use certain UserRPL command to assert that the process is general and deals properly with the 49 arrays types (I thinks that there isnt sufficient documentation of the 49s internals so the only way of support the generality is using some UserRPL commands).

Its completely done in the HP49 with Masd, Emacs and the help of Nosy.

I really hope this will useful for you.

 

8. Acknowledgements

I would like to thank to:

       Mika Heiskanen. His Entries.src discovered me the insides of my 48sx.

       Alex Ramos. His RPL++ compiler let me start to work in SysRPL without the complexities I found with HP ones.

       Detlef Mueller and Raymond Hellstern for RPL48

       C.Bourgeois (BOUHP). The Kernel stack replacement discovered me a new world and force me to do a really good job on my sx.

       Jean Yves Avenard. StringWriter! How do you do it?

       Bernard Parisse. The ALGB (the Erabless father) makes me realize that the 48 could do magic.

 

 

       ACO for the Hp49.

       Carsten Dominik and Peter Geelhoed for Emacs

       Jurjen N.E. Bos for Nosy.

 

 

9. Contact

As I explain in the disclaimers part this is freeware but I spent a lot of time on it so Ill really thank any email telling me what do you think about it of if you find any bug or have any idea to extend it.

Luis Morales Boisset

lboisset@arrakis.es