|Subject:||Re: how to use fft in c++|
|Date:||Fri, 9 Jun 2017 15:00:23 -0400|
|User-agent:||Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0|
On 06/09/2017 02:19 PM, Progressive wrote:
Sorry for being pedantic but I think we're going in circles, so let's rewind to the beginning. Octave code can be used in one of two ways: either by letting Octave have control, or controlling Octave code from your own code.At first thank you! What do you mean by "DEFUN is defining a function"?
The former way is more common: Octave provides the main() function that sets things up and goes into a REPL---Read Evaluate Print Loop. You can add new functionality to Octave by either writing code in its interpreted language (.m files) or in C/C++; the latter requires you to use Octave ABI conventions that are easier to satisfy if you use the DEFUN_DLD macro---its function is to declare an Octave function to the compiler, which then adds it to Octave binary so that it can be called just like any other Octave builtin function.
You can also treat Octave as a library, providing your own main() and control loop. You don't need DEFUN_DLD then, because you will be calling your own code, not Octave (you'll still need to follow Octave's conventions to call Octave's functions, of course, and you may still need DEFUN_DLD if you design your program to call main()->YourCode()->OctaveCode()->yourCode() )
People who are new to interpreted languages tend to instinctively gravitate towards the second model, to retain control of the main loop, but I believe that in most cases writing Octave extensions is simpler and more productive. I think the main case for the first model is for existing programs that already have their own control loop that is too hard to get rid of.
If you do insist, take look at /usr/share/doc/octave/examples/code/standalonebuiltin.cc
|[Prev in Thread]||Current Thread||[Next in Thread]|