The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

Matrix/Array 28/48/50 Question
Message #1 Posted by Matt Agajanian on 4 June 2012, 2:37 p.m.

Hello all

Can I dynamically access an array or matrix element by simply accessing it these ways:

matrix/array name[var]

or

matrix/array name[row, col]

Or am I only to use GET and PUT?

Edited: 4 June 2012, 2:41 p.m. after one or more responses were posted

      
Re: Matrix/Array 28/48/50 Question
Message #2 Posted by Oliver Unter Ecker on 4 June 2012, 2:40 p.m.,
in response to message #1 by Matt Agajanian

Sadly not. You'll need to use GET or GETI.

            
Re: Matrix/Array 28/48/50 Question
Message #3 Posted by Matt Agajanian on 4 June 2012, 2:43 p.m.,
in response to message #2 by Oliver Unter Ecker

Okay. Besides, that does follow the Postfix structure so, no matter. Just a thought.

                  
Re: Matrix/Array 28/48/50 Question
Message #4 Posted by Oliver Unter Ecker on 4 June 2012, 3:00 p.m.,
in response to message #3 by Matt Agajanian

Quote:
Just a thought.

And not a bad one either! I picked it up in RPL+ where you can use the array syntax you suggest. You also have a choice of 1-based or 0-based indices, and automatic support for circular arrays. (But RPL+ is not available on those HP calcs.)

                        
Re: Matrix/Array 28/48/50 Question
Message #5 Posted by Matt Agajanian on 4 June 2012, 10:28 p.m.,
in response to message #4 by Oliver Unter Ecker

Well, this is a new one...RPL+. Hmm. Which calcs employ RPL+ ?

                              
Re: Matrix/Array 28/48/50 Question
Message #6 Posted by Oliver Unter Ecker on 4 June 2012, 10:39 p.m.,
in response to message #5 by Matt Agajanian

So far, RPL+ is only implemented in one iPhone app: ND1 (ND0 is a free version to try out.)

If you visit the forum, you can learn about what other devices are planned to be supported in the future.

If you know RPL and are just curious about what's new: RPL+ for RPL Users

      
Re: Matrix/Array 28/48/50 Question
Message #7 Posted by Karl-Ludwig Butte on 4 June 2012, 3:53 p.m.,
in response to message #1 by Matt Agajanian

Hello Matt,

I found the following process working for me:

'M(row,column)' EVAL @ to extract a matrix element N 'M(row, column)' STO @ to store a number N into a matrix element

Instead of EVAL in the first case you can use \->NUM, too.

I've tried this on the HP-49G, 49G+ and 50G.

Hope this helps

Regards

Karl

            
Re: Matrix/Array 28/48/50 Question
Message #8 Posted by Gilles Carpentier on 4 June 2012, 4:41 p.m.,
in response to message #7 by Karl-Ludwig Butte

Hi

I also use this and it works fine (49/50).

Exemple to try :

 { 5 5 } RANM  'Mat' STO         @ Create a 5x5 random matrix and store it
2 'a' STO
'Mat(a,2)' EVAL @ Return the value
99 'Mat(a,2)' STO @ Store 99 in a,2 cell
'Mat(a,2)' EVAL 'Mat(5,5)' STO @ Put value of a,2 in 5,5
IF 'Mat(a,2)==Mat(5,5)' THEN "Equal value " MSGBOX END Mat @ Show result

It also works with 'vector'
[ 1 2 3 4 5 ] 'Vect' STO
'Vect(3)' EVAL
99 'Vect(5)' STO

Edited: 4 June 2012, 4:59 p.m.

            
Re: Matrix/Array 28/48/50 Question
Message #9 Posted by Oliver Unter Ecker on 4 June 2012, 5:26 p.m.,
in response to message #7 by Karl-Ludwig Butte

Apologies. I had forgotten about this option.

Know though that it runs almost an order of magnitude slower!

From another discussion elsewhere:

Quote:
<< [1 2 3] -> x << 1. 1000. START 'x(1)' EVAL DROP NEXT >> >>
runs 6.5x slower than
<< [1 2 3] -> x << 1. 1000. START x 1 GET DROP NEXT >> >>

And that's 9x slower if you factor out the time for << 1. 1000. START NEXT >> as one should.

(On Emu-48/HP-49G.)


                  
Re: Matrix/Array 28/48/50 Question
Message #10 Posted by Matt Agajanian on 4 June 2012, 10:31 p.m.,
in response to message #9 by Oliver Unter Ecker

Not certain which post to post this under. Thanks for all your brilliant methods to accomplish the functionality I needed.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall