forum.alglib.net http://forum.alglib.net/ |
|
Help. FFT in Delphi 7 http://forum.alglib.net/viewtopic.php?f=2&t=112 |
Page 1 of 2 |
Author: | littlefish [ Mon Nov 08, 2010 9:09 am ] |
Post subject: | Help. FFT in Delphi 7 |
Hello. I use ALGLIB for Delphi7. I have error when i specify the size of the array Buf (type of TReal1DArray): SetLength (Buf, N), I am using the function FFTR1D.Please, suggest me what could be the reason? |
Author: | Sergey.Bochkanov [ Mon Nov 08, 2010 11:36 am ] |
Post subject: | Re: Help. FFT in Delphi 7 |
What kind of error you have - compiler error, runtime error? Can you post here code which calls ALGLIB (and error message text)? |
Author: | littlefish [ Tue Nov 09, 2010 5:22 am ] |
Post subject: | Re: Help. FFT in Delphi 7 |
This problem goes away by itself, did not even understand how. Now another problem: the function FFTR1D (const A: TReal1DArray; N: AlglibInteger; var F: TComplex1DArray), returns an array of F values:"+NAN", instead of real numbers. how to get rid of, I do not know. |
Author: | littlefish [ Tue Nov 09, 2010 5:25 am ] |
Post subject: | Re: Help. FFT in Delphi 7 |
Suddenly do not understand the question! I need instead of "+ NAN" get real numbers. Thank you for your help! |
Author: | Sergey.Bochkanov [ Tue Nov 09, 2010 7:56 am ] |
Post subject: | Re: Help. FFT in Delphi 7 |
If you want to get help, you should post your code first. Code which calls ALGLIB functions and leads to incorrect results. How can someone tell what's wrong without looking at code? |
Author: | littlefish [ Tue Nov 09, 2010 8:14 am ] | |||
Post subject: | Re: Help. FFT in Delphi 7 | |||
unit fftun; interface uses Math, Sysutils, Ap, ftbase; ... procedure FFTC1D(var A : TComplex1DArray; N : AlglibInteger); var Plan : FTPlan; I : AlglibInteger; Buf : TReal1DArray; begin Assert(N>0, 'FFTC1D: incorrect N!'); // // Special case: N=1, FFT is just identity transform. // After this block we assume that N is strictly greater than 1. // if N=1 then begin Exit; end; // // convert input array to the more convinient format // GetMem(buf,2*n); SetLength(Buf, 2*N); I:=0; while I<=N-1 do begin Buf[2*I+0] := A[I].X; Buf[2*I+1] := A[I].Y; Inc(I); end; // // Generate plan and execute it. // // Plan is a combination of a successive factorizations of N and // precomputed data. It is much like a FFTW plan, but is not stored // between subroutine calls and is much simpler. // FTBaseGenerateComplexFFTPlan(N, Plan); FTBaseExecutePlan(Buf, 0, N, Plan);//After this procedure, the array is filled with the Buf "+ NAN". // // result // I:=0; while I<=N-1 do begin A[I].X := Buf[2*I+0]; A[I].Y := Buf[2*I+1]; Inc(I); end;
|
Author: | Sergey.Bochkanov [ Tue Nov 09, 2010 8:19 am ] |
Post subject: | Re: Help. FFT in Delphi 7 |
No, I talked about your code, which calls ALGLIB functions. Maybe you have subtle errors in the initialization of arrays.... And what about this GetMem(buf,2*n) call? There is no such code in the original library - looks like you've tweaked ALGLIB code a bit. I suspect that this call is the reason behind failure. Try once more with original, unmodified ALGLIB. |
Author: | littlefish [ Tue Nov 09, 2010 9:08 am ] |
Post subject: | Re: Help. FFT in Delphi 7 |
I am very grateful. getmem - it was my mistake, forgot to remove it. by getmem, I tried to solve the problem with the size of the array. Now everything works. Thank you again! |
Author: | littlefish [ Wed Nov 10, 2010 9:10 am ] | |||
Post subject: | Re: Help. FFT in Delphi 7 | |||
Hello! I have a question: When drawing the data obtained after converting the sinusoid, turns smooth peak, although it should be sharp. Why is this happening? sinusoid has a frequency of 2 kHz.
|
Author: | Sergey.Bochkanov [ Wed Nov 10, 2010 9:43 am ] |
Post subject: | Re: Help. FFT in Delphi 7 |
I don't think that it is error in the FFT - it looks like aliasing effect. |
Page 1 of 2 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |