Engee documentation

Prelookup

Calculates the number and fraction of the interval to be interpolated.

prelookup

Description

Block Prelookup calculates a number and a fraction for the interval that define how its input value relates to a set of reference points.

The block Prelookup works best with the Interpolation Using Prelookup block. Feed the resulting number and fraction values into the Interpolation Using Prelookup block to interpolate an n-dimensional table. These two blocks have distributed algorithms. When combined together, they perform the same operation as the integrated algorithm in block n-D Lookup Table. However, the blocks Prelookup and Interpolation Using Prelookup provide more flexibility and more efficient modelling and code generation than the block n-D Lookup Table.

Supported block operations

To use a block Prelookup*you must specify a set of reference point values. You can choose whether to specify the datum values directly in the dialogue box or to transmit them via the *bp input port by setting the parameters to Source value Dialog or Input port.

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

The block Prelookup generates a pair of outputs for each input value by calculation:

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

  • the fraction of the interval (fraction) in the range , representing the normalised position of 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 parameters Indexing Mode:

  • Zero-based indexing - indexing of reference points starts from 0. Example: if the set of reference points is [0 5 10 20 50 100] and the input value of is 55, the number is 4 and the interval fraction is 0.1.

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

The interval fraction may be negative or greater than 1 in case 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 of approximation of function values

Values

Clip | Linear

Default value

Linear

Program usage name

ExtrapMethod

Tunable

No

Evaluatable

No

Additional options

C code generation: Yes