Brian wrote:
>  Does the filter (%+./) solve the big and 
>  fractional weights issue? 

It definitely solves the fractional weights issue, by normalizing everything
to integers.  I'll have to remember that, that's a neat tool.

However, it doesn't solve the big weights issue, as e.g. one of the weights
may be a large prime (so GCD is <: 1, meaning in the best case the numbers
get no larger).  Actually, because +. is a fairly expensive operation, it
may have exacerbated the performance issue (as opposed to, e.g., Roger's
[0,1)-scaling mechanism which relies on the cheap + function).

Here's a demonstration of the performance issue:

           wP =: (([?@#+/@]){(;@((#~)</.]# ;@(i.@#)))@])

           0 ": (%"1<./)ts&> '100 wP 5 3 4 2 * ' ,L:0 ] 10 <@":@^ 1+i.5
           1    1
           3    7
          35   56
         190  841
        2346 6847

BTW, without thinking about it too much, I believe your code is equivalent
to  wPE =: (?@# +/) { I.@]   , or with your scaling mechanism as a
preprocessor, wPES =: wPE (% +./) .

-Dan


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to