Documentation

coder.fftw.StandaloneFFTW3Interface class

Package:coder.fftw
Superclasses:

Abstract class for specifying an FFTW library for FFTW calls in generated code

Description

coder.fftw.StandaloneFFTW3Interfaceis an abstract class for defining an FFT library callback class. An FFT library callback class specifies an FFT library to use for C/C++ code generated for MATLAB®fast Fourier transform functions. To define an FFT callback class for the FFTW library, version 3.2 or later, use thecoder.fftw.StandaloneFFTW3Interfaceclass. For example, to define an FFT library callback class with the nameuseMyFFTW, make this line the first line of your class definition file:

classdef useMyFFTW < coder.fftw.StandaloneFFTW3Interface
For information about the FFTW library, seewww.fftw.org.

MATLAB fast Fourier transform functions includefft,fft2,fftn,ifft,ifft2, andifftn. The code generator produces FFTW library calls for these functions when all of these conditions are true:

  • You generate standalone C/C++ code (static library, dynamically linked library, or executable program) withMATLAB Coder™or generate C/C++ code from aMATLAB Functionblock with万博1manbetx®Coder.

  • You have access to an FFTW library installation, version 3.2 or later.

  • You specify the FFTW library installation in an FFT library callback class that derives fromcoder.fftw.StandaloneFFTW3Interface.

  • You set the appropriate configuration parameter to the name of the callback class.

    • For code generation with theMATLAB Codercodegencommand, setCustomFFTCallback.

    • For code generation with theMATLAB Coderapp, setCustom FFT library callback.

    • For code generation for aMATLAB Functionblock by usingSimulink Coder, setCustom FFT library callback.

You must implement theupdateBuildInfoandgetNumThreadsmethods.

Optionally, you can implement these methods:

  • getPlanMethod

  • lockandunlock

All methods are static.

Methods

getNumThreads Return number of threads to use for FFTW library calls
getPlanMethod Return FFTW planning method
lock Lock access to FFTW planning
unlock Unlock access to FFTW planning
updateBuildInfo Update the build information for linking to a specific FFTW library

Examples

collapse all

Specify a specific installed FFTW library in an FFT library callback class.

Use this example FFT library callback class as a template.

% copyright 2017 The MathWorks, Inc.classdefuseMyFFTW < coder.fftw.StandaloneFFTW3Interfacemethods(Static)functionth = getNumThreads coder.inline ('always'); th = int32(coder.const(1));endfunctionupdateBuildInfo(buildInfo, ctx) fftwLocation ='/usr/lib/fftw'; includePath = fullfile(fftwLocation,'include'); buildInfo.addIncludePaths(includePath); libPath = fullfile(fftwLocation,'lib');%DoublelibName1 =“libfftw3-3”; [~, libExt] = ctx.getStdLibInfo(); libName1 = [libName1 libExt]; addLinkObjects(buildInfo, libName1, libPath, 1000, true, true);%SinglelibName2 ='libfftw3f-3'; [~, libExt] = ctx.getStdLibInfo(); libName2 = [libName2 libExt]; addLinkObjects(buildInfo, libName2, libPath, 1000, true, true);endendend

Modify the template.

  • ReplaceuseMyFFTWwith the name of your callback class.

  • If your FFTW installation uses multiple threads, modify thegetNumThreadsmethod to return the number of threads that you want to use.

  • In theupdateBuildInfomethod, set:

    • fftwLocationto the full path for your installation of the library.

    • includePathto the full path of the folder that containsfftw3.h.

    • libPathto the full path of the folder that contains the library files.

Introduced in R2017b

Was this topic helpful?