Main Content

addAlgorithmProperty

Add algorithm properties for code replacement table entry

Description

addAlgorithmProperty(hEntry,Name,Value) adds algorithm property settings to the conceptual representation of a code replacement table entry. For example, use this function to adjust the algorithms applied by lookup table functions.

Examples

Configure Algorithm Properties for lookup1D Function

This example shows how to use the addAlgorithmProperty function to configure the code generator to apply these methods when replacing code for the lookup1D function:

  • Clip extrapolation

  • Linear interpolation

  • Binary or linear index search

hLib = RTW.TflTable;

hEnt = RTW.TflCFunctionEntry;
hEnt.setTflCFunctionEntryParameters( ...
                    'Key',                      'lookup1D', ...
                    'Priority',                 100, ...
                    'ImplementationName',       'my_Lookup1D_Repl', ...
                    'ImplementationHeaderFile', 'my_Lookup1D.h', ...
                    'ImplementationSourceFile', 'my_Lookup1D.c', ...
                    'GenCallback', 'RTW.copyFileToBuildDir');

arg = hEnt.getTflArgFromString('y1','double');
arg.IOType = 'RTW_IO_OUTPUT';
hEnt.addConceptualArg(arg);

arg = hEnt.getTflArgFromString('u1','double');
hEnt.addConceptualArg(arg);

arg = RTW.TflArgMatrix('u2','RTW_IO_INPUT','double');
arg.DimRange = [0 0; Inf Inf];
hEnt.addConceptualArg(arg);

arg = RTW.TflArgMatrix('u3', 'RTW_IO_INPUT', 'double');
arg.DimRange = [0 0; Inf Inf];
hEnt.addConceptualArg(arg);

hEnt.addAlgorithmProperty('ExtrapMethod', 'Clip');
hEnt.addAlgorithmProperty('InterpMethod', 'Linear point-slope');
hEnt.addAlgorithmProperty('IndexSearchMethod', 'Linear search');

Input Arguments

collapse all

Code replacement table entry, previously returned by calling the function RTW.TflCFunctionEntry or RTW.TflCOperationEntry.

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Name','y1'

The ExtrapMethod value specifies which method to use to extrapolate values for inputs that fall outside the range of a breakpoint data set.

Example: 'ExtrapMethod', 'Clip'

The IndexSearchMethod value specifies the method of calculating table indices. For evenly spaced breakpoint sets, you achieve optimal speed by selecting Evenly spaced points to calculate table indices. For unevenly spaced breakpoint sets, use Linear search or Binary search.

Example: 'IndexSearchMethod','Evenly spaced points'

The InterpMethod value specifies the method of interpolation between breakpoint values.

Example: 'InterpMethod', 'Linear point-slope'

The RemoveProtectionInput value specifies whether or not to include code that checks for out-of-range input values. If your input values are not out of range, you can set the RemoveProtectionInput to off.

Example: 'RemoveProtectionInput', 'off'

The RndMeth value specifies the rounding mode for fixed-point lookup table calculations.

Example: 'RndMeth', 'Zero'

The SaturateOnIntegerOverflow value specifies the method of overflow action. If you set the value to off, overflows wrap to the appropriate value that is represented by the data type. Otherwise, overflows saturate to either the minimum or maximum value that the data type can represent.

Example: 'SaturateOnIntegerOverflow', 'on'

If you want to enable tunable table size in the generated code, set the SupportTunableTableSize value to on.

Example: 'SupportTunableTableSize', 'on'

The UseLastTableValue value specifies the indexing convention to use to address the last element of a breakpoint set and its corresponding table value.

Example: 'UseLastTableValue', 'on'

Set the UseRowMajorAlgorithm value to on to enable using row-major algorithms. Set the value to off to use column-major algorithms.

Example: 'UseRowMajorAlgorithm', 'on'

Set the BPPower2Spacing value to on if you want to replace blocks whose breakpoints are the power of 2 spaced values by the user-defined function specified in the code replacement library. Set the value to off if you want to replace blocks whose breakpoints are not the power of 2 spaced values by the user-defined function specified in the code replacement library.

Introduced in R2014b