Engee documentation

Prelookup

Calculates the number and fraction of the interval for interpolation.

blockType: PreLookup

Path in the library:

/Basic/Lookup Tables/Prelookup

Description

Block Prelookup calculates the number and fraction for the interval, which determine how its input value is correlates with a set of reference points.

Block Prelookup works best with a block Interpolation Using Prelookup. Submit the received number and fraction values to the block Interpolation Using Prelookup for interpolation - dimensional table. These two blocks have distributed algorithms. When combined together, they perform the same operation as the integrated algorithm in the block n-D Lookup Table. However, the blocks Prelookup and Interpolation Using Prelookup provide more flexibility and more efficient modeling and code generation than a block n-D Lookup Table.

Supported operations with blocks

To use the block Prelookup, a set of anchor point values must be specified. In this case, you can choose whether to specify the values of the reference points directly in the dialog box or transfer them via the bp input port by setting the parameter Source value Dialog or Input port.

Typically, a data set of reference points corresponds to one dimension of tabular data in a block Interpolation Using Prelookup.

Block Prelookup generates a pair of outputs for each input value by calculating:

  • reference point numbers whose value is less than or equal to and forms an interval containing .

  • fractions of an interval (fraction) in the range representing the normalized position on the interval between the reference point with the found number and the next reference point.

The number is counted from zero or from one, depending on the value of the parameter Indexing Mode:

  • Zero-based indexing — indexing of reference points starts with 0'. Example: if the set of reference points is `[0 5 10 20 50 100] and the input value If the interval is equal to 55, then the number is equal to 4, and the interval fraction is `0.1'.

  • One-based indexing — indexing of reference points starts with 1'. Example: if the set of reference points is `[0 5 10 20 50 100] and the input value If the interval is equal to 55, then the number is equal to 5, and the fraction of the interval is `0.1'.

The interval fraction may be negative or greater than 1 if the input signal is out of range.

Ports

Input

# u — input signal u
vector

Details

Block Prelookup accepts signals with real values of any numeric data type supported by Engee except Bool.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, UInt128.

Complex numbers support

No

# u — input signal u
scalar | vector | matrix

Details

Block Prelookup accepts signals with real values of any numeric data type supported by Engee except Bool.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, UInt128.

Complex numbers support

No

# bp — reference points
vector

Details

Block Prelookup accepts as reference points signals with real values of any numeric data type supported by Engee except Bool.

Dependencies

To use this port, set parameter Source value Input port.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, UInt128

Complex numbers support

No

Output

# k — number of the interval containing the input signal u
scalar | vector | matrix

Details

The number is a real integer defining the interval containing the input signal .

The number counts from zero or from one depending on the value of the parameters Indexing Mode.

Data types

Float64

Complex numbers support

No

# f — fraction representing the normalised position of the input in the interval
scalar | vector | matrix

Details

The fraction represents the normalised position of the input in the interval .

Data types

Float64.

Complex numbers support

No

Parameters

Breakpoints data

# Source — source of values for the reference points
Dialog | Input port

Details

Source of values for the datums:

  • Dialog - The reference point values are specified in the Value parameters.

  • Input port - The reference point values will be obtained via the corresponding input point.

Values

Dialog | Input port

Default value

Dialog

Program usage name

BreakpointsDataSource

Tunable

No

Evaluatable

No

# Value — datums
Array of real numbers

Details

Reference points. The set of anchor points must be a strictly monotonically increasing vector containing two or more elements.

Dependencies

To use this parameter, set the parameters to Source value Dialog.

Default value

10:10:110

Program usage name

BreakpointsData

Tunable

Yes

Evaluatable

Yes

# Indexing Mode — number value reference method
Zero-based indexing | One-based indexing

Details

The number value is counted from zero if the value is set to Zero-based indexing, or from one if the value is set One-based indexing.

Values

Zero-based indexing | One-based indexing

Default value

Zero-based indexing

Program usage name

IndexingMode

Tunable

No

Evaluatable

No

Algorithm

# Output selection — output signals
Index and fraction | Index only

Details

Options for selection:

  • Index only - outputs only the number, no share.

  • Index and fraction - Outputs the number and fraction as separate signals.

Values

Index and fraction | Index only

Default value

Index and fraction

Program usage name

OutputSelection

Tunable

No

Evaluatable

No

# Index search method — interval number search method
Evenly spaced points | Linear search | Binary search

Details

Each search method has speed advantages in different situations:

  • For evenly spaced anchor points (e.g., 10, 20, 30, and so on), optimal speed is achieved by choosing Evenly spaced points table numbers for the calculation. This algorithm uses only the first two anchor points of the set to determine the offset and distance between the remaining points.

  • For non-uniformly distributed landmark points, it is recommended:

    • Linear search - if the input values for do not change much between counting steps.

    • Binary search - if the input values for change by more than one or two table intervals per count step.

A suboptimal choice of number lookup method can lead to poor performance of models that rely heavily on lookup tables.

Values

Evenly spaced points | Linear search | Binary search

Default value

Binary search

Program usage name

IndexSearchMethod

Tunable

No

Evaluatable

No

# Extrapolation method — method of processing input values that are out of range
Clip | Linear

Details

The method used by the block to extrapolate values for all inputs outside the range of the dataset of reference points.

Read more about extrapolation methods here: Methods for approximating function values

Values

Clip | Linear

Default value

Linear

Program usage name

ExtrapMethod

Tunable

No

Evaluatable

No

Additional options

C code generation: Yes