RPL mini-challenge: Create an anti-Identity Matrix
|
05-13-2018, 08:48 PM
Post: #27
|
|||
|
|||
RE: RPL mini-challenge: Create an anti-Identity Matrix
(05-12-2018 09:07 PM)Gerald H Wrote: Very good, 3298.That can be fixed by using \->LIST in place of \->ARRY and the pair of commands \->LIST AXL in place of ROW\->. That speeds it up from around 1.38_s to around 1.20_s. The same change to the real number version would slow it down, though - by about 0.12_s. --- I also put some finishing touches like a size parameter into pier4r's program, including slight optimizations (loop counter value range, shuffling the size parameter through the stack intelligently). I avoided UserRPL loops in my own solution because I expected them to be too slow to be of any use (perhaps I'm too used to the speed of SysRPL, and even there I squeeze every last bit of performance out of the loop structure with e.g. runstream shenanigans) - but it seems that handling larger elements (like my matrix rows and eventually the wrongly dimensioned matrix) isn't actually better, whereas in this program the large object doesn't even exist up to the last command. The internal structure of real/complex number matrices (which enforces same-size elements) allows for a very efficient implementation of \->ARRY for that argument type too. Code: \<< (05-13-2018 07:32 PM)pier4r Wrote: Say I have 5 objects on the stack and I want to duplicate them, without using an explicit loop (surely the command internally will have a loop, like NDUPN). Is it possible?Sounds like NDUP, but I don't think it's worth the effort here. You could make 2 matrix rows from 1, but you cannot make N rows from 1 row without putting it into your own loop (like the one that currently houses NDUPN). You'd also have to retain the code for generating a single row so NDUP has something to duplicate. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 10 Guest(s)