Version française
Home     About     Download     Resources     Contact us    
Browse thread
building fft
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] building fft
variables have to start with a lowercase letter. values starting with
uppercase are module names/type constructors.

On 6/2/06, otlore dolire <otlore@hotmail.fr> wrote:
> I have a problem with a basic fft function i'm tryin to build. I think it's
> right, yet it raises conflicts, as if it didn't recognize the "end" at the
> end of it. Can you please tell me if someone sees something wrong? thx in
> advance
>
> let rec fft N w y =
>        let Y = make_vect N {Re = 0. ; Im = 0.}
>        in
> if N = 1 then begin Y.(0) <- y.(0) end
>         else
>                begin   let m = div_int N 2;
>                        let l1 = make_vect m {Re = 0. ; Im = 0. }
>                        and l2 = make_vect m {Re = 0. ; Im = 0. }
>                        in for k = 0 to m - 1 do
>                           l1.(k) <- y.(2*k);
>                           l2.(k) <- y.(2*k + 1)
>                        done;
>                           let L1 = make_vect m {Re = 0. ; Im = 0. }
>                           and L2 = make_vect m {Re = 0. ; Im = 0. }
>                          in
>                                for i = 0 to m - 1 do
>                                  L1.(i) <- (fft m (prod w w) l1).(i);
>                                  L2.(i) <- (fft m (prod w w) l2).(i)
>                                done;
>                let wk = ref {Re = 1. ; Im = 0. }
>                   and P = ref {Re = 0. ; Im = 0. }
>                   and I = ref {Re = 0. ; Im = 0. }
>                in for k=0 to m - 1 do
>                    P := L1.(k);
>                    I := prod !wk L2.(k);
>                    Y.(k) <- prod (add !P !I) {Re = 0.5 ; Im = 0. };
>                    Y.(k + m) <- prod (sous !P !I) {Re = 0.5 ; Im = 0. };
>                    wk := prod !wk w
>                  done
>                end;
> Y;;
>
>
> PS: i defined the type cplx by type cplx = {Re : float ; Im : float}, prod,
> add and sous are respectively product, addition and substraction of cplx
> numbers
>
> _________________________________________________________________
> Windows Live Mail : découvrez et testez la version bêta !
> http://www.ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>