* building fft
@ 2006-06-02 11:07 otlore dolire
2006-06-02 11:21 ` [Caml-list] " Jonathan Roewen
2006-06-02 15:32 ` Shawn
0 siblings, 2 replies; 3+ messages in thread
From: otlore dolire @ 2006-06-02 11:07 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] building fft
2006-06-02 11:07 building fft otlore dolire
@ 2006-06-02 11:21 ` Jonathan Roewen
2006-06-02 15:32 ` Shawn
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Roewen @ 2006-06-02 11:21 UTC (permalink / raw)
To: otlore dolire; +Cc: caml-list
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] building fft
2006-06-02 11:07 building fft otlore dolire
2006-06-02 11:21 ` [Caml-list] " Jonathan Roewen
@ 2006-06-02 15:32 ` Shawn
1 sibling, 0 replies; 3+ messages in thread
From: Shawn @ 2006-06-02 15:32 UTC (permalink / raw)
To: otlore dolire; +Cc: caml-list
otlore dolire wrote:
>
> 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
>
Besides the syntax errors from using capital-letter identifiers as field
names, why are you reinventing the standard Complex module?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-06-02 15:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-02 11:07 building fft otlore dolire
2006-06-02 11:21 ` [Caml-list] " Jonathan Roewen
2006-06-02 15:32 ` Shawn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox