-
×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center
-
-
×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center
-
- HP Community
- >
- Other Products
- >
- Calculators
- >
- HP 50g - create matrix variable with userrpl and run matrix ...
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Create an account on the HP Community to personalize your profile and ask a question

Solved!
HP 50g - create matrix variable with userrpl and run matrix writer
12-03-2016 01:08 AM - edited 12-03-2016 01:12 AM

Hello together,
i like to create a multipication table and save this in a matrix variable. Afterwards i like to run the matrix writer with the created matrix variable. Have someone a idea how can this make this a userrpl script? At least, ceate a multipication table via userrpl?
Many thanks for help.
Kind regards
joeres
Solved! Go to Solution.
12-03-2016 03:53 AM

Hi!, joeres:
Welcome to HP Forum !.
Can you explained better with an example, for your question ?.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
12-03-2016 04:27 AM - edited 12-03-2016 05:08 AM

Hi Maké,
thanks for you answer.
Ok, i like to create a UserRPL script that automatically create a matrix variable. The content of the matrix variable is also generated by the script, e.g. this multiplication table:
× 1 2 3 4 5 6 7 8 9 10 11 12
1 1 2 3 4 5 6 7 8 9 10 11 12
2 2 4 6 8 10 12 14 16 18 20 22 24
3 3 6 9 12 15 18 21 24 27 30 33 36
4 4 8 12 16 20 24 28 32 36 40 44 48
5 5 10 15 20 25 30 35 40 45 50 55 60
6 6 12 18 24 30 36 42 48 54 60 66 72
7 7 14 21 28 35 42 49 56 63 70 77 84
8 8 16 24 32 40 48 56 64 72 80 88 96
9 9 18 27 36 45 54 63 72 81 90 99 108
10 10 20 30 40 50 60 70 80 90 100 110 120
11 11 22 33 44 55 66 77 88 99 110 121 132
12 12 24 36 48 60 72 84 96 108 120 132 144
Or in a other case, a UserRPL script generate random values, e.g.:
× 1 2 3 4
1 3 5 8 1
2 7 9 6 4
3 4 2 2 2
4 9 1 0 5
5 3 7 1 7
6 2 9 4 6
After generating the matrix variable with the content through the UserRPL script, the tool "Matrix writer" (APPS 8 F6) should be startet automaticlly, also through the UserRPL script and the Matrix writer shows the content of the generated matrix variable.
I have no ideas, how we can make it.
Hope, this helps.
Thanks and kind regards,
joeres
12-03-2016 06:07 AM

Hi!, @joeres:
See, this link, if serve for you ... http://h20564.www2.hp.com/hpsc/doc/public/display?docId=emr_na-c01941333-1
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
12-03-2016 11:17 AM

Did you read the user guide?
http://h10032.www1.hp.com/ctg/Manual/c00748644
Suppose M is the matrix you want to use.
Then you first have to create a matrix which has the right number of rows and columns.
Suppose you want to have 6 rows and 7 columns, then you could use CON({6,7},0) to create such a matrix with all elements being 0, and store it in variable M.
Then you can use PUT(M,{i,j},i*j) to let the element in row i and column j be i*j.
12-04-2016 02:38 AM

Hi Maké and Jan_D,
many thanks for your help.
Now i have a solution for my exercise (Dimension and name of matrix variable read from stack):
\<< \-> DIM VNAME
\<< { DIM DIM } 0 CON VNAME STO
1 DIM FOR I
1 DIM FOR J
VNAME { I J } I J * PUT
NEXT
NEXT
VNAME VISITB
\>>
\>>
With VISITB can you call the matrix writer for the given variable.
Kind regards,
joeres
12-04-2016 11:51 AM

That's actually very close to the solution I had in mind, especially considering the second part of your request (the random number part). One suggestion: putting the data on the stack and building the array with ->ARRY is considerably faster:
\<<
\-> dim vname \<<
1 dim FOR row
1 dim FOR col
row col *
NEXT
NEXT
dim DUP 2 \->LIST \->ARRY
vname SWAP OVER STO
VISITB
\>>
\>>
12-05-2016 01:47 PM

It's actually easier to answer a slightly different question: why is the other method much slower?
Short answer: PUT is a complex command that has to do a lot of checking before actually storing a single value into its target location.
Longer answer: Besides the inherent type checking that takes place initially (list? matrix? global?), there's also index checking (does the identified index already exist?). Basically a lot of things have to be verified and determined before PUT can actually PUT something. Then consider that all of that overhead occurs for each and every element you are adding to the matrix (array). You start to get an idea why it can take a while.
The version I proposed limits its inner loop to the simplest operation (multiplying the indices). Since the majority of processing time for the program is in that loop structure, keeping it simple has a nice payoff in execution time.
When you only need to change an item or two in a pre-existing array, PUT is probably the best choice. When building the array from scratch, loading the stack and using ->ARRY will almost always be faster. And generally speaking, keeping inner loops as simple as possible should always be a design consideration since the code they contain can be repeated many times.
Hope this helps!
- David
Didn't find what you were looking for? Ask the community