© Luis Morales
Boisset - Madrid. Spain.
2001/10/24
[New in this version: Bug fixing and
better support for Exact mode ]
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.
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 can’t be used for any commercial purpose without
written permission from the author. This implies the user shouldn’t 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.
This
software has been tested by me and seems to be safe but like always please
backup your memory before trying it. It’s done 90% in SysRPL and 10% UserRPL
(commands like COLà ROWà) with MASD so if there is any bug I haven’t
detected you could loose you data L
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 it’s mainly compatible with the HP49.
So
in May’1994 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
I’ve take a look in the features of Array21 and Stat03 programs for the GX (I
really didn’t 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)
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.
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:
:port:1746
PURGE [ENTER]
Other
way of accessing and uninstalling this library is with the 49’s Filer which is
pretty good in this. Look for it in the port were you stored it.
This
command it’s 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 it’s bigger than
size + 1 zeroes columns/rows will be added. If it’s 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 can’t 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
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 it’s 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 don’t 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
;)
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).
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:
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]]’ |
returns
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
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.
This
one does the same over each column.
Level 3 |
Level 2 |
Level 1 |
|
Level 1 |
[[data]] |
%num |
Program |
à |
[[data]]’ |
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 it’s kept.
The
syntax is pretty the same than CMtx except that you don’t 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
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.
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.
Level 1 |
|
Level 1 |
%col |
à inside CMtx or FMtx |
Ob(col) |
%col |
à inside CMtx or FMtx but if col doesn’t 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.
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.
Level 1 |
|
Level 1 |
%row |
à inside CMtx or FMtx |
Ob(row) |
%row |
à inside CMtx or FMtx but if col doesn’t exists |
Error |
%row |
à if outside CMtx or FMtx |
Error |
This
command can only be used inside CMtx programs.
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. It’s useful in those cases with complex formulas
where you want to keep and intermediate value and want to do it in one process.
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
doesn’t 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.
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 doesn’t exists |
Error |
Ob |
%row |
à if outside CMtx or FMtx |
Error |
This
command can only be used inside CMtx programs.
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.
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
I’ve 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
Like
NSUB this one give the index of the process of execution. In which row it’s 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.
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 |
This
one is the conjugate of EndCMtx. If the last give the row number this one gives
you the size of each row.
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 it’s size independent!
This
one could only be used in DOArray and give the column index of the process.
Level 1 |
|
Level 1 |
Nothing |
à inside DOArray |
% index of the current column |
Nothing |
à if outside the commands |
Error |
Example:
result in
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 isn’t sufficient documentation of the 49’s internals so the only way
of support the generality is using some UserRPL commands).
It’s
completely done in the HP49 with Masd, Emacs and the help of Nosy.
I
really hope this will useful for you.
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
Erables’s 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.
As
I explain in the disclaimers part this is freeware but I spent a lot of time on
it so I’ll 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