[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to use fft in c++
From: |
Pantxo |
Subject: |
Re: how to use fft in c++ |
Date: |
Thu, 8 Jun 2017 03:10:52 -0700 (PDT) |
Carlo de Falco-2 wrote
>> On 7 Jun 2017, at 21:27, Progressive <
> Progressive@
> > wrote:
>>
>> Hi,
>>
>> I have a c++ file with octave embedded in it. Calculating via Matrices
>> and
>> so on works fine but I don't get it how do I use functions, e.q. the fft
>> in
>> c++ / upon variables from/in c++ ?
>>
>> The documentation
>> https://www.gnu.org/software/octave/doc/v4.0.1/Signal-Processing.html
>> just
>> tells fft(x).
>>
>> Just briefly: I have an array in c++ and I want to apply fft on it. How
>> do I
>> do that?
>>
>> Thank you very much!
>>
>
> you could invoke the interpreter doing something like this (untested):
>
> ColumnVector x, y;
> octave_value_list in, out;
>
> in(0) = x;
> out = feval ("fft", in, 1);
> y = out(0).column_vector_value ();
>
> but if you are looking for performance you are probably better off using
> fftw's API directly.
>
> c.
>
>
>
>
> _______________________________________________
> Help-octave mailing list
> Help-octave@
> https://lists.gnu.org/mailman/listinfo/help-octave
Since fft and related function are builtin you probably can include
<octave/builtin-defun-decls.h> and call Ffft directly (without the need for
feval) in your code. As an example the following code can be compiled with
mkocfile and works for me:
//////////////////////////testfft.cc//////////////////
#include <octave/oct.h>
#include <octave/builtin-defun-decls.h>
DEFUN_DLD(testfft, args, nargout, "\
testfft\n\
")
{
octave_value_list retval;
int nargin = args.length ();
retval = Ffft (args);
return retval;
}
/////////////////////////////////////////////////////
Compile and test in Octave:
mkoctfile testfft.cc
x = 1:10;
all (testfft (x) == fft (x))
Pantxo
--
View this message in context:
http://octave.1599824.n4.nabble.com/how-to-use-fft-in-c-tp4683590p4683592.html
Sent from the Octave - General mailing list archive at Nabble.com.
- how to use fft in c++, Progressive, 2017/06/07
- Re: how to use fft in c++, Carlo De Falco, 2017/06/08
- Re: how to use fft in c++,
Pantxo <=
- Re: how to use fft in c++, Progressive, 2017/06/09
- Re: how to use fft in c++, Pantxo, 2017/06/09
- Re: how to use fft in c++, Progressive, 2017/06/09
- Re: how to use fft in c++, Pantxo, 2017/06/09
- Re: how to use fft in c++, Progressive, 2017/06/09
- Re: how to use fft in c++, Kire Pudsje, 2017/06/09
- Re: how to use fft in c++, Progressive, 2017/06/09
- Re: how to use fft in c++, Przemek Klosowski, 2017/06/09
- Re: how to use fft in c++, Progressive, 2017/06/12
- Re: how to use fft in c++, Kire Pudsje, 2017/06/09