First Entry into Matrix Pushes Stack

Post here to share useful tips and tricks, to ask questions about using your DM42 or to report software-related problems
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: First Entry into Matrix Pushes Stack

Post by Thomas Okken »

The stack-lift-preservation behavior actually happens in EDIT and EDITN -- easy to overlook if you keep setting up your test case like 2 ENTER ENTER ENTER EDITN "M". So, still weird behavior, but at least a bit more consistent than I thought.
Release 2.0.19 coming up...
Epidiah
Posts: 21
Joined: Mon Jan 29, 2018 3:08 am

Re: First Entry into Matrix Pushes Stack

Post by Epidiah »

This is probably as it should be, then, but in case it matters, the stack lifts for the first entries into MATA, MATB, and MATX as well.
whuyse
Posts: 198
Joined: Thu Dec 21, 2017 1:23 pm

Re: First Entry into Matrix Pushes Stack

Post by whuyse »

Thomas Okken wrote:
Sat Mar 10, 2018 5:37 pm
Update: no, wait, it's even weirder. EDIT preserves the existing stack lift status. Hmm, and that's exactly what my old code did.
No, not quite.
With v2.0.17

Code: Select all

2
ENTER
ENTER
ENTER
NEWMAT
ENTER
EDIT
42
RDN
Gives 0 on Free42 and the matrix on a 42S
Cheers, Werner
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: First Entry into Matrix Pushes Stack

Post by Thomas Okken »

I stand corrected! This is an aspect of the matrix editor that was clearly not as well thought out and tested against the original as it should have been. But I think in 2.0.19 I finally got it right...

Well, except for MATA, MATB, and MATX in the SIMQ menu, which activate the matrix editor and exhibit the same stack lift behavior as EDIT and EDITN on the HP-42S, and not (yet) in Free42, as Epidiah pointed out.

So, the same patch will have to be applied there. It's not as important as the EDIT/EDITN fix, because MATA, MATB, and MATX are not programmable, but they should be fixed anyway for the sake of consistency.
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: First Entry into Matrix Pushes Stack

Post by Thomas Okken »

Thomas Okken wrote:
Sun Mar 11, 2018 12:50 pm
I stand corrected! This is an aspect of the matrix editor that was clearly not as well thought out and tested against the original as it should have been. But I think in 2.0.19 I finally got it right...

Well, except for MATA, MATB, and MATX in the SIMQ menu, which activate the matrix editor and exhibit the same stack lift behavior as EDIT and EDITN on the HP-42S, and not (yet) in Free42, as Epidiah pointed out.

So, the same patch will have to be applied there. It's not as important as the EDIT/EDITN fix, because MATA, MATB, and MATX are not programmable, but they should be fixed anyway for the sake of consistency.
Fixed in 2.0.20.
Epidiah
Posts: 21
Joined: Mon Jan 29, 2018 3:08 am

Re: First Entry into Matrix Pushes Stack

Post by Epidiah »

Apologies for resurrecting this thread, but I was playing around with matrices again and noticed some behavior that seems inconsistent.

So, I'm multiplying a couple 2×2 matrices. The easiest way, for me, seemed to be…

Code: Select all

2
ENTER
NEWMAT
EDIT
…then mess around inside the editor to fill my first matrix. After that…

Code: Select all

ENTER
EDIT
…to duplicate the first matrix and then edit it to change all of the values to those from my second matrix. Then I just exit the editor and hit that × key.

And it worked!

But it shouldn't have, right? Because when I changed that first value, it should have bumped the old value into ST Y, so hitting × right after exciting the editor should have multiplied my entire second matrix by the scalar that was in the first entry of the first matrix.

After a little more playing around, I discovered that changing the first entry in the matrix editor lifts they old value into the stack if ST Y has a real, complex, or alpha value, but not if it has another matrix.

That last bit seems inconsistent, which is why I bring it up, but it's also very useful, so I've got my fingers crossed, hoping it's meant to do that.

Along the same lines, EDITN doesn't lift the stack at all. It just replaces whatever's in ST X with the last element you were editing when you exited the editor. So if you have 2×2 matrix in ST X and use EDITN to edit a matrix variable, you'll lose your matrix in X.
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: First Entry into Matrix Pushes Stack

Post by Thomas Okken »

What happens is that EDIT and EDITN preserve the stack lift state. This is authentic HP-42S behavior, and I'm sure it's a bug, but Free42 emulates it for the sake of compatibility. See the change history:
2018-03-10: release 2.0.19

* Another EDIT/EDITN fix: in the real HP-42S, EDIT and EDITN don't actually disable stack lift; they preserve the stack lift state, which you can observe if you do ENTER vs. a stack-lift-enabling operation (say, X<>Y) just before invoking them. This behavior is not really useful, but it needs to be emulated anyway, since not doing so risks breaking HP-42S programs.
Epidiah
Posts: 21
Joined: Mon Jan 29, 2018 3:08 am

Re: First Entry into Matrix Pushes Stack

Post by Epidiah »

Oooooh! I think I get it. It's not the fact that a matrix is in ST Y, but the fact that I hit enter to put it there.

Yup, just double checked by STO ST Y instead of entering, and it lifts the first entry as expected.

And EDITN behaves the same way. I think what was throwing me off there was how EDITN doesn't lift what's initially in ST X when you first call it. It seems like hitting enter before editing matrices might just be a good habit to get into.

Well that's good news all around. Thank you!
Post Reply