Main Content

coder.LAPACKCallback Class

Namespace: coder

Abstract class for specifying the LAPACK library and LAPACKE header file for LAPACK calls in generated code

Description

coder.LAPACKCallback is an abstract class for defining a LAPACK callback class. A LAPACK callback class specifies the LAPACK library and LAPACKE header file to use for LAPACK calls in code generated from MATLAB® code. If you use MATLAB Coder™ to generate standalone code or generate code for the MATLAB Function block, for certain linear algebra function calls, you can generate LAPACK calls. To generate LAPACK calls, set the appropriate configuration parameter to the name of the LAPACK callback class.

  • For code generation with MATLAB Coder codegen command, set CustomLAPACKCallback.

  • For code generation with MATLAB Coder app, set Custom LAPACK library callback.

  • For code generation for a MATLAB Function block with Simulink® Coder, set Custom LAPACK library callback.

To define a LAPACK callback class with the name useMyLAPACK, make the following line the first line of your class definition file.

classdef useMyLAPACK < coder.LAPACKCallback

You must define all of the methods listed in Methods. These methods are static and are not compiled.

Methods

expand all

Examples

collapse all

This example shows how to write a LAPACK callback class.

Use this example LAPACK callback class as a template.

classdef useMyLAPACK < coder.LAPACKCallback
    methods (Static)
        function hn = getHeaderFilename()
            hn = 'mylapacke_custom.h';
        end
        function updateBuildInfo(buildInfo, buildctx)
            buildInfo.addIncludePaths(fullfile(pwd,'include'));
            libName = 'mylapack';
            libPath = fullfile(pwd,'lib');
            [~,linkLibExt] = buildctx.getStdLibInfo();
            buildInfo.addLinkObjects([libName linkLibExt], libPath, ...
                '', true, true);
            buildInfo.addDefines('HAVE_LAPACK_CONFIG_H');
            buildInfo.addDefines('LAPACK_COMPLEX_STRUCTURE');
            buildInfo.addDefines('LAPACK_ILP64'); 
        end
    end
end

Replace useMyLAPACK with the name of your callback class.

The getHeaderFilename method returns the name of the header file for the LAPACKE C interface to the LAPACK library. Replace mylapacke_custom.h with the name of your LAPACKE header file.

The updateBuildInfo method updates the build information with the locations of the header files and the name and location of the LAPACK library. Replace mylapack with the name of your LAPACK library.

If your compiler supports only complex data types that are represented as structures, include these lines in the updateBuildInfo method.

buildInfo.addDefines('HAVE_LAPACK_CONFIG_H');
buildInfo.addDefines('LAPACK_COMPLEX_STRUCTURE');

You must specify the integer type that your LAPACK library uses. Not specifying this integer type can result in incorrect behaviors or crashes. Do one of the following:

  • Include these lines in the updateBuildInfo method.

    buildInfo.addDefines('HAVE_LAPACK_CONFIG_H');
    buildInfo.addDefines('LAPACK_ILP64');

  • Alternatively, you can directly specify the integer type that your LAPACK library uses. For example, if the integer type is long long, include this line in the updateBuildInfo method.

    buildInfo.addDefines('lapack_int=long long');

Version History

Introduced in R2016a