Raph,

I have to admit to being a little dense at first on this one
(per my previous post), but I finally realized what the Collector is
doing, 
and how it can be used to constrain the autocorrelation sequence
returned by the function (as opposed to passing in a parameter,
as in the proc I had defined).

For my current problem, I want all of the values returned in the
sequence to
be the same.  However, for other problems, I may want to constrain that
sequence of values differently.
So, allowing the Autocorrelate function to collect results in a vector,
and then separately constraining the results is more flexible/general
purpose.

Once I realized this, and called it properly (see the snippet),
everything works as I expected.

---------- snippet ---------------------

AutoCorrelationSequence = {Autocorrelate {Append [0] {Record.toList
Histogram}}}

for S in AutoCorrelationSequence
do
   S=: (2*T - 1)
end

----------end snippet-------------------

Thanks again for your help!

George

> >
> > {Autocorrelate Count (2*T - 1)}
> >
> > It fails with a red square, as opposed to a light green diamond.
> >
> >
> > ---------- begin code ------------------
> > proc {Autocorrelate Xs Val}
> >      NumberOfShifts = {List.length Xs} - 1
> >  in
> >     for I in 1..NumberOfShifts do
> >        %rotate the list Xs by: splitting the list at position I
> >        %then slicing the list back together with the parts swapped
> >     CopyOfXsRotatedISlots={Append {List.drop Xs I} {List.take Xs I}}
> >     Matches={List.zip Xs CopyOfXsRotatedISlots fun {$ X Y} X=:Y end}
> >      in
> >         {FD.decl Val}
> >     {FD.sum Matches '=:' Val}
> >     {Browse Matches}
> >         end
> > end
> 
> George, you are constraining *all* the shifted dot products to be
equal
> to Val.  Is this what you meant?
> 
> You can make Autocorrelate return a list of the products by using the
> 'collect' feature of the for loop as:
> 
> fun {Autocorrelate Xs}
>     NumberOfShifts = {List.length Xs} - 1
> in
>     for
>        I in 1..NumberOfShifts
>        collect:Collect
>     do
>        %% rotate the list Xs by: splitting the list at position I then
>        %% slicing the list back together with the parts swapped
>        CopyOfXsRotatedISlots={Append {List.drop Xs I} {List.take Xs
I}}
>        Matches={List.zip Xs CopyOfXsRotatedISlots fun {$ X Y} X=:Y
end}
>        Val
>     in
>        {FD.decl Val}
>        {FD.sum Matches '=:' Val}
>        {Collect Val}
>     end
> end
> 
> 
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to