Hi,
currently I am programming a integer factorization program for fun.
The resulting factors including the integer value being factorization
as first element should be inserted into a [n,1] matix an passed to
the user when the program has done its work.
Roughly I do this:
GROW
1
1
DIM "factors"
INDEX "factors"
...
RCL01
->
...
LBL 00
<do factorization of one factor here>
RCL "factor"
->
...
GTO 00
But I am always ending with a additional "0" in the matrix.
Since the loop should run as fast as possible I want to
avoid expensive handling of I and J inside it.
Is there a way to insert an element into the matrix by using GROW mode
without creating a new one afterwards ?
Is there a way to first create a new empty matrix element and then insert
the new value right into it?
Thanks a lot for any help in advance!
Cheers,
Meino
Adding elements to matrix programmatically
Adding elements to matrix programmatically
DM 42 - SN: 00373, Firmware release v.:3.22. / DMCP 3.24. as compiled by SwissMicros
Re: Adding elements to matrix programmatically
I would say no to these two questions, but you can simply add DELR at the end of your loop, after GTO 00.
DM42: 00425 - DM41X: β00066 - WP43: 00042
Re: Adding elements to matrix programmatically
1. You can avoid the extra row by careful placing of the -> commands in your program, since that is what creates a new row when the last one is full.
2. Can't you create a new matrix using by placing the rows and columns in the x and y registers, and using the NEWMAT command?
2. Can't you create a new matrix using by placing the rows and columns in the x and y registers, and using the NEWMAT command?
HP50G HP35s Free42 DM42.
Testing WP43S, C43.
Testing WP43S, C43.
-
- Posts: 1100
- Joined: Tue May 02, 2017 5:48 pm
- Location: Netherlands
- Contact:
Re: Adding elements to matrix programmatically
You can prevent the creation of the superfluous row by creating new rows just before you need them, and skipping that step on the first iteration since matrices always start out with at least one row:
1
1
DIM "factors"
INDEX "factors"
GROW
SF 00
... start loop ...
FC?C 00
J+
STOEL
... end loop ...
Note the use of J+ and STOEL, instead of →, so you don't have to worry about the contents of the previous element.
1
1
DIM "factors"
INDEX "factors"
GROW
SF 00
... start loop ...
FC?C 00
J+
STOEL
... end loop ...
Note the use of J+ and STOEL, instead of →, so you don't have to worry about the contents of the previous element.
Re: Adding elements to matrix programmatically
Hi all,
thanks a lot for you help.
I will enter (it) The Matrix, hehehe :::)))
Cheers!
Meino
thanks a lot for you help.
I will enter (it) The Matrix, hehehe :::)))
Cheers!
Meino
DM 42 - SN: 00373, Firmware release v.:3.22. / DMCP 3.24. as compiled by SwissMicros