[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can I de-loop?



In article <7mje9s$263$1@nnrp1.deja.com>,
  throop@colorado.edu wrote:>For instance, given
>
>A = [0,1,2]
>N = [2,2,2]
>K = 4
>
>I want the result A = [0,1,14], not A = [0,1,6]


I'll take this one guys (using the non-gender-specific meaning!).
Woohoo! My first "use histogram" posting!


A = [0,1,2]
N = [2,2,2]
n = n(sort(n)) ; you may need this, not sure of your application
K = 4

print,a
a =a+k*histogram(n,binsize=1,min=0,max=n_elements(a)-1)
print,a

This may not be general enough for your application, but
you get the idea.  Always use histogram if possible.

Cheers,
bob




Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.