Dan, Raul, Roger, thanks! I'm amazed that I still learn new nice things
after so many years :)

Dan,
I think it indeed matters how each of the parts is obtained. If you
could help me making this more elegantly (execution time does not
matter) that would be great. 
The application is about image quantisation based on a parallel
simulated annealing scheme, see below. (This scheme is actaully
implemented on a massively // system with 8K simple processors.)
Globals T and Gh are precalculated nouns, which are now passed as
globals. Is it e.g. possible to pass these globals to f without f having
a notion of the index and of course the explicit code to pass these to
f?
(Rolling random states in a function cuts code size but is considered
bad programming practise).

Thanks for your help!
Jan.


delta=:-.@:+:@:=
lhood=:3 : '*: origIm - y.{MU'          NB.     compute likelihood
prior=:4 : '+/ x. delta"2 Cs |. y.'             NB.     compute prior
f=:3 : 0
        'state index'=.y.
        stateNew=.index{Gh
        TEMP=.index{T
        energy=. (lhood state) + BETA * state prior state
        energyNew=. (lhood stateNew) + BETA * stateNew prior state
        deltaE=. energyNew - energy
        accept=. deltaE <: - TEMP * ^. ALPHA
        state=.accept}state,:stateNew
        state;>:index
)
NB.     Globals: origIm, MU, Gh, T, L
g0=:?($origIm)$L
NB. first random state
d'preparing array of random states...'
Gh=:?(n,$origIm)$L                                              NB.
prepare array of random states
f^:n (g0;0)

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


This message and attachment(s) are intended solely for use by the addressee and 
may contain information that is privileged, confidential or otherwise exempt 
from disclosure under applicable law.

If you are not the intended recipient or agent thereof responsible for 
delivering this message to the intended recipient, you are hereby notified that 
any dissemination, distribution or copying of this communication is strictly 
prohibited.

If you have received this communication in error, please notify the sender 
immediately by telephone and with a 'reply' message.
  
Thank you for your co-operation.


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

Reply via email to