The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

ROW- behaves differently in the HP49G
Message #1 Posted by Vieira, Luiz C. (Brazil) on 1 Dec 2004, 6:25 a.m.

Hi, all RPL users and programmers;

as it's been mentioned here from time to time, I am aware of the fact that there are altready other specific forums to debate HP48G and HP49G related subjects, but I'd like to ask you please to consider the fact that most of the minds visiting the MoHPC Forum behave so gently and politely that I feel sort of "compelled" to post here. Can you forgive me?

Maybe this is something you already know, and I must confess I saw this particular different behavior when I got my HP49G a couple of years ago, but I did not took it so seriously at that time.

Consider a matrix with a single line, even a single element, and try removing this line with ROW- by using an HP48G. A 'Invalid Dimension' error is generated and no element is extracted. A different approach, that I consider a better behavior, is observed in the HP49G/G+. The single element is removed and an empty matrix is returned to level 1. Try this:

[[2]] 1 ROW-

The HP48G returns a Invalid Dimension, and the HP49G returns:

2: []
1: [2]

I'd like to hear from you about this (if privately, please be my guest: lcvieira at quantica dot com dot br): what do you think? Based on what I saw, in some circumstances it's necessary to add error traps to avoid problems in the HP48G, while in the HP49G the action is taken naturally.

Cheers.

Luiz (Brazil)

Edited: 1 Dec 2004, 6:28 a.m.

      
Re: ROW- behaves differently in the HP49G
Message #2 Posted by James M. Prange on 1 Dec 2004, 8:30 a.m.,
in response to message #1 by Vieira, Luiz C. (Brazil)

Interesting. Note that it works that way only with a symbolic (type 29.) matrix, not with a real (type 3) or complex (type 4) matrix.

Also note that it won't accept an empty matrix [] or [[]] from the command line.

If I run SIZE on the resulting [], then it returns { 0. 0. }. Shouldn't it return just { 0. }?

Somehow, the idea of an array with 0 rows or 0 columns seems rather strange to me.

Regards,
James

            
Re: ROW- behaves differently in the HP49G
Message #3 Posted by Valentin Albillo on 1 Dec 2004, 10:12 a.m.,
in response to message #2 by James M. Prange

Hi, James:

James M. Prange posted: "Somehow, the idea of an array with 0 rows or 0 columns seems rather strange to me."

It has its uses, and the idea of such arrays goes back to the times of the HP-85, if not further. As you may know, there was a Matrix ROM for the HP-85, from which the best algorithms were incorporated into the HP-71B Math ROM, from which the best code was adapted for such machines as the HP-42S and the 48/49 models.

See what the HP-85 Matrix ROM manual has to say about these "empty" arrays (HP-85 Matrix ROM Owner's Handbook, page 46):

  "Arrays with zero rows or zero columns can be considered 
   to be "empty", since they contain no elements [...] 
   Empty arrays can be specified in subsequent statements
   and functions with meaningful results [...] 
   The following situations are of particular interest: [...]

For example, if the operand array has been redimensioned to be 0x3, the statement MAT A=B would redimension the result array to be 0x3, while the statement MAT A=TRN(B) would redimension the result array to be 3x0

The matrix multiplication statement, if both operand arrays are empty, can yield a result array that is *not* empty [...]

For example, if matrix B has been redimensioned to be 3x0, and matrix C has been redimensioned to be 0x1, the statement MAT A=B*C redimensions matrix A to be (3x0)x(0x1) = 3x1. The result array is not empty, since neither the number of rows nor the number of columns is zero"

So you see, it seems you can matrix multiply a, say, 5x0 empty matrix and a 0x5 empty matrix and get a 5x5 non-empty matrix ! :-)

The Matrix ROM Owner's Handbook discusses the topic further and gives an example where this behavior is advantageous. I don't know (but mostly doubt) if the 48/49 models do allow for such operations on empty arrays, so perhaps this useful and advanced feature was lost in the way.

Best regards from V.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall