Post Reply 
RPL mini-challenge: Create an anti-Identity Matrix
05-16-2018, 01:27 AM (This post was last modified: 05-16-2018 01:42 AM by DavidM.)
Post: #45
RE: RPL mini-challenge: Create an anti-Identity Matrix
(05-15-2018 06:48 PM)Claudio L. Wrote:  Now I can't fully understand why the code above, being the EXACT same commands except you added 2 ->LIST and replaced one DUP with one DUPDUP, would be 30% faster. Isn't it doing the same thing? Or are CON and IDN much faster when you use size arguments in lists?
I just can't explain it.

Load stack with:
{ 30. 30. }
1.


Then
<< CON >> TEVAL
Time: 0.0306

Load stack with:
30. IDN
1.


Then
<< CON >> TEVAL
Time: 0.9141

That's just one run, but the time difference is already apparent.

IDN with a single integer input was only slightly faster than with an array when I checked (0.0309s vs. 0.0399s).

I could understand the time difference for CON a little better if the matrix argument was type 29, because the internal data structure for that type of matrix doesn't have meta data for the matrix dimensions like a type 3 does. But in the above example, the input matrix is a type 3. So it's still a bit puzzling.

Regardless of the reason, the moral of this story is: always pass a list of dimensions to CON. Adding SIZE to the second version of the program yields a time result similar to David Hayden's:
Code:
IDN DUP SIZE 1. CON SWAP -
Time: 2.3818s (one attempt)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-16-2018 01:27 AM



User(s) browsing this thread: 1 Guest(s)