coder.ignoreSize - Prevent code generator from creating function specializations for constant-size

  expressions - MATLAB ([original](http://www.mathworks.com/help/coder/ref/coder.ignoresize.html)) ([raw](?raw))

Main Content

Prevent code generator from creating function specializations for constant-size expressions

Syntax

Description

coder.ignoreSize([expression](#mw%5Fb38acd98-bb99-4e9f-ad22-91c3e18afc9d)) declares that the code generator must not use the constant size of an expression to create function specializations.

example

Examples

collapse all

If your MATLABĀ® code calls a function multiple times and passes inputs of different sizes, the code generator can create function specializations for each size. To avoid this issue, use coder.ignoreSize on the function input. For example, this code uses coder.ignoreSize to avoid creating multiple copies of the function indexOf:

function [out1, out2] = test1(in) a = 1:10; b = 2:40; % Without coder.ignoreSize duplicate functions are generated out1 = indexOf(coder.ignoreSize(a), in); out2 = indexOf(coder.ignoreSize(b), in); end

function index = indexOf(array, value) coder.inline('never'); for i = 1:numel(array) if array(i) == value index = i; return end end index = -1; return end

To generate code, enter:

codegen test1 -config:lib -report -args {1}

Input Arguments

collapse all

Example: foo(coder.ignoreSize(1:10))

More About

collapse all

Version of a function in which an input type, size, complexity, or value is customized for a particular invocation of the function.

Function specialization produces efficient C code at the expense of code duplication. The code generation report shows all MATLAB function specializations that the code generator creates. However, the specializations might not appear in the generated C/C++ code due to later transformations or optimizations.

Tips

Extended Capabilities

Version History

Introduced in R2019b