Post Reply 
Little explorations with HP calculators (no Prime)
04-19-2017, 09:58 PM
Post: #196
RE: Little explorations with the HP calculators
Note about SORT.

SORT seems to be a merge-sort based method. This takes order N*log(N) time to sort. A selection sort (hardware, software, by hand....) takes order N^2 time and thus for anything more than around 10 elements will lose badly.

I did lots of tests of list-based, array-based, loop-based, (FOR START DO) and firmware routines (matrix and vector and the like). For some things, the clever routines were best. For others (and there was no way to guess ahead of time), just a loop was best.

One common (actually the first routine I wrote) was to fill a list with numbers from 1 to N. A loop was the fastest; I tried using SEQ but that was slower. My fastest was:
<< -> N << 1 N FOR I I NEXT N ->LIST >>>>

The list-processing capabilities are rather limited on the HP50. (Defaults for Sumlist and Prodlist are incorrect and mean that these need a wrapper around them to check the inputs and they do not have all the list commands needed.) There are two type of list commands, multiple list and reduction. MAX could be the maximum between lists or the maximum of a list (I wrote a listmax using STREAM but it again needs a complicated wrapper to handle cases of 1 element or 0 elements or non-list or empty stack or the like.) These cause a big performance hit and complicate programs.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Little explorations with the HP calculators - ttw - 04-19-2017 09:58 PM



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