Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how

Legacy Documentation

Mathematica 8 (2010)

This is documentation for Mathematica 8, which was
based on an earlier version of Wolfram Language.
View current documentation (Version 14.3)

Examples

The C code generator can be used to create standalone executables that link to the Wolfram runtime library.

Low-Pass Filter

This example creates a standalone C executable for a low-pass filter.

Building the Executable

First, you need to create a target directory for the output.
Out[6]=
Now a compiled function that implements a discrete low-pass filter is defined.
This uses the code generator to save the C source file and header file in the target directory.
Out[10]=
To run the code you need to embed it in a main program. The following is a suitable C function that calls the generated code.
Here, the main program is written into the target directory.
Out[12]=
Now you can build the standalone executable as in the following. Notice how it links in the static minimal library: this avoids a need to set up library paths. Since it uses a platform-independent name, this should work on all platforms. Note how the option is set to : this makes sure that MathLink libraries are not included in the link stage.
Out[15]=
This standalone executable can be used by itself, distributed to others, and incorporated into other systems.

Running the Standalone Program

Now you can run the standalone program. In a real application you would not run it from Mathematica as is done here. The following is really for the purpose of demonstration.
First, you need to make an input signal with several frequency components.
Out[19]=
The standalone program reads from its input in the following format.
nelems
elem #1
...
elem #n
dt
RC
Now you can create an input file of the appropriate format from the signal. This is shown below.
Out[21]=
This runs the standalone executable and loads back the result into Mathematica.
The result can be converted into a Mathematica expression and verified. Finally, you can extract the actual numbers.
Here the filtered signal is plotted in red along with the original input signal in blue.
Out[29]=
The standalone program does not have to be run from Mathematica; you can run it any way you wish. But you can test it from Mathematica and illustrate its output conveniently this way.
Finally, you can remove the example directory, if desired.

Standalone Lifting Wavelet Transforms

Examples of using standalone code generation are demonstrated in the documentation for LiftingFilterData . You can find these in "Applications".


ja zh

AltStyle によって変換されたページ (->オリジナル) /