Re: APL and (very) large arrays



In article <Xns9749A028140E7ramacd@xxxxxxxxxxxxxx>,
Randy Macdonald <ramacd@xxxxxxxxxxx> wrote:
>"Stefano \"WildHeart\" Lanzavecchia" <wildstf@xxxxxxxxxxx> wrote in
>news:dq2gee$aqps$1@xxxxxxxxxxxxxxxxx:
>
>>> 2) The two biggest elements of a vector (for instance to build the
>>> associated Huffman code. Surely there must be a better way than
>>> sorting the whole vector and then making a 2 take ?
>>
>> As far as I know, there's no better way. You can avoid the finally
>> indexing by doing the 2 take of the index vector, but I cannot really
>> see how to improve the algorithm given the overhead of the
>> interpreter. Of course some cleverer guy will prove me wrong
>> straight-away. I mean: you could always
>> max1<-ceiling/vec
>> max2<-ceiling/vec without max1
>> but you would still have to traverse the original vector three times
>> and make one almost full one copy of it so, unless you timed it
>> against your favourite implementation, you wouldn't know if that would
>> be faster than the gradedown for any size of vec.
>
>Channeling Bill Nye*, I just did some timing tests, comparing the (a) 2
>take sort vs. (b) biggest,biggest without biggest. (b) won. Finding the
>biggest, even twice, seems faster than doing a complete sort.
>
>--
>* One test is worth a thousand expert opinions.
> -- Bill Nye, The Science Guy.
>--
>-----------------------------------------------------------------------
>|\/| Randy A MacDonald | you can't pay for it,
>|/\| ramacd@xxxxxxxxxxx | even if you want to.
>BSc(Math) UNBF'83 Sapere Aude | APL: If you can say it, it's done..
>Natural Born APL'er |
>----------------------------------------------------(INTP)----{ gnat }-
These methods will give different answers when the biggest is not unique.


.



Relevant Pages

  • Re: collect-max for structs
    ... For the whole list, find the largest, then if it is not the first element, swap it with the first element. ... This allows you to use the first result immediately, instead of waiting for the sort to finish. ... "biggest" is very inefficient. ... (sort lst #'bigger))) ...
    (comp.lang.lisp)
  • RE: How to determine second (and then third) highest value in a list
    ... The process of finding the biggest, the second biggest, the third biggest, ... You can sort by either columns or rows. ... > I'd like a "2nd place score" column that would report 400 ...
    (microsoft.public.excel.misc)
  • Re: APL and (very) large arrays
    ... >> associated Huffman code. ... Channeling Bill Nye*, I just did some timing tests, comparing the 2 ... take sort vs. biggest,biggest without biggest. ... biggest, even twice, seems faster than doing a complete sort. ...
    (comp.lang.apl)
  • if
    ... then sort the data from smaller group in the anthor 6 ... % then compare three parameters:fitresults.caged_P ... % put the data from the biggest in another 6 ... % then we sort the caged group data on the first 6 ...
    (comp.soft-sys.matlab)