Engee documentation

Correlation

Mutually correlated function of two input data.

correlation

Description

The Correlation block calculates the mutual correlation function of two input arrays of dimension N along the first dimension. The calculation can be performed in time or frequency domain. You can specify the domain using the Computation domain parameter.

In the time domain, the unit convolves the first input signal with the time-reversed complex conjugation of the second input signal .

In the frequency domain, to calculate the mutual correlation, the block:

  1. Performs a Fourier transform of both input signals, and .

  2. Multiplies and , where is the complex conjugation.

  3. Calculates the inverse Fourier transform for the product.

If you set Computation domain to Fastest, the block selects the domain with the minimum number of calculations.

Ports

Input

Port_1 - first data input
vector | matrix

The block accepts multi-channel and multi-dimensional input data with a real or complex value. The input signal can be a fixed point signal when you set the Computation domain to Time. When one or both input signals are complex, the output signal is also complex.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Fixed.

Support for complex numbers: Yes

Port_2 - second data input
vector | matrix

The block accepts multi-channel and multi-dimensional input data with a real or complex value. The input signal can be a fixed-point signal when you set Computation domain to Time. When one or both input signals are complex, the output signal is also complex.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Fixed.

Support for complex numbers: Yes

Output

Port_1 - mutually correlated output signal
vector | matrix

Mutually correlated output of two input signals.

When the input data are multidimensional arrays, the block outputs a multidimensional array where all dimensions except the first dimension are the same as the input array. For example,

  • When the inputs and have dimensions Mu by N by P and Mv by N by P, respectively, the Correlation block outputs the array Mu+Mv-1 by N by P.

  • When the input signals and have dimensions Mu by N and Mv by N, the block outputs the array Mu+Mv-1 by N.

When one input signal represents a column vector and the other input signal represents a multidimensional array, the correlation block calculates the mutual correlation of the vector with each column in the multidimensional array. For example:

  • When the input represents the vector-column Mu by 1 and represents the matrix Mv by N, the block outputs the matrix Mu+Mv-1 by N.

  • Similarly, when and are column vectors with lengths Mu and Mv respectively, the block performs vector mutual correlation.

Data types: Float64.

Support for complex numbers: Yes

Parameters

Main

Computation domain - area in which the block calculates autocorrelation
Time (by default) | Frequency | Fastest
  • Time - calculates mutual correlation in the time domain, which minimises memory usage.

  • Frequency - calculates the mutual correlation in the frequency domain. For more information, see [Алгоритмы].

  • Fastest - calculates mutual correlation with minimum number of calculations.

To process fixed point signals, set this parameter to Time.

Data Types

Rounding mode - rounding mode
Floor (by default) | Ceiling | Convergent | Nearest | Round | Simplest | Zero

Select the rounding mode for fixed point operations. You can select:

  • Floor - rounds both positive and negative numbers to negative infinity.

  • Ceiling - rounds both positive and negative numbers to positive infinity.

  • Convergent - rounds a number to the nearest representable value. If the fractional part of a number ends in 5, the number is rounded to the nearest even integer.

  • Nearest - rounds the number to the nearest imaginable value. If the fractional part of the number ends in 5, the number is rounded to the nearest even integer.

  • Round - rounds the number to the nearest imaginable value. If the fractional part of a number ends in 5, positive numbers are rounded to positive infinity and negative numbers to negative infinity.

  • Simplest - automatically selects between rounding Floor and rounding Zero, to generate a rounding code that is as efficient as possible.

  • Zero - rounds a number to zero.

The block parameters are always rounded to the nearest representable value.

The settings Rounding mode and Saturate on integer overflow do not affect the numerical results if the conditions are met:

  • Product output is set to Inherit: Inherit via internal rule.

  • The parameter Accumulator is set to Inherit: Inherit via internal rule.

  • The Output setting is set to Inherit: Same as accumulator.

With these data type settings, the unit operates in full accuracy mode.

Saturate on integer overflow - saturation to integer on overflow
выключено (by default) | включено

A checkbox which, when selected, uses saturation arithmetic for integers and fixed-point numbers: when an overflow occurs, the result is automatically replaced by the maximum possible (modulo) value for the data type.

Action Rationale Effect on overflow Example

The checkbox Saturate on integer overflow is checked (enabled).

Overflow is possible for your model and you want the generated code to have an explicit overflow protection.

If an overflow occurs, the result is automatically replaced by the maximum possible (modulo) value for the data type.

The maximum value that can be represented by the data type Int8 (signed, 8-bit integer) is 127.

Any result of a block operation that exceeds this maximum value results in an 8-bit integer overflow. When checked, the block output is saturated to 127. Similarly, the block output is saturated at a minimum output value of -128.

The Saturate on integer overflow checkbox is unchecked (disabled).

You want to optimise the efficiency of your generated code.

You want to avoid over-determining how the block handles out-of-range signals.

Overflows are carried in an appropriate value that can be represented by a data type.

The maximum value that can be represented by the data type Int8 (signed, 8-bit integer) is 127.

Any result of a block operation that exceeds this maximum value results in an 8-bit integer overflow. If the check box is unchecked, software interprets the value causing the overflow as Int8, which may cause an unintended result. For example, the result of block 130 (binary code 1000 0010) expressed as Int8, is -126.

When you select this check box, saturation is applied to all internal operations in the block, not just the input/output data or the result.

Usage in program code

Block parameter

SaturateOnIntegerOverflow

Value

выключено | включено

By default

выключено

Product output - work output type
Inherit: Same as input (by default) | fixdt([],16,0)

Specify the output data type of the work. You can set this parameter to the following values:

  • A rule that inherits a data type, for example, Inherit: Same as input.

  • An expression that results in a valid data type, for example, fixdt([],16,0).

Accumulator - battery data type
Inherit: Inherit via internal rule (by default) | Inherit: Same as input | fixdt([],16,0)

Accumulator specifies the data type of the output of the accumulation operation in the block. You can set this parameter to the following values:

  • Inherit: Inherit via internal rule - the block inherits the output data type of the work based on an internal rule.

  • Inherit: Same as input - block sets the accumulator data type to the same as the input data type.

  • fixdt(1,16,0) - block specifies an autosigned, binary, scaled fixed-point data type with a word length of 16 bits and a fractional length of 0.

Output data type - output data type
Float16 | Float32 | Float64 | Int8 | Int16 | Int32 | Int64 | Int128 | UInt8 | UInt16 | UInt32 | | UInt64 | UInt128 | Inherit: auto | Fixed point

Specify the type of output data.

The type can be inherited, specified directly, or expressed as a datatype object.

Usage in program code

Block parameter:

OutDataTypeStr

Value:

Float16 | Float32 | Float64 | Int8 | Int16 | Int32 | Int64 | Int128 | UInt8 | UInt16 | UInt32 | UInt64 | UInt128 | Fixed

By default:

Float64

Output minimum - minimum output data value
[] (by default) | скаляр

The default minimum output data value is [], which is equivalent to -Inf.

This number must be a finite real double scalar value.

If an object with the bus type is specified as the data type for this block, do not specify a minimum value for the data in this block. Engee ignores this setting. Instead, set minimum values for the elements of the object specified as the data type.

Engee uses this value for execution:

  • Simulation range checks.

  • Automatic scaling of fixed point data types.

  • Optimising the code you generate from the model. This optimisation can remove algorithmic code and affect the results of some simulation modes.

The parameter does not saturate or trim the actual output signal. Instead, use the block Saturation.

Usage in program code

Block parameter

OutMin

Value

[ ] | скаляр

By default

[ ]

Output maximum - maximum output data value
[] (by default) | скаляр

The default maximum output data value is [], which is equivalent to Inf.

This number must be a finite real double scalar value.

If an object with the bus type is specified as the data type for this block, do not specify a maximum value for the data in this block. Engee ignores this setting. Instead, set the maximum values for the elements of the object specified as the data type.

Engee uses this value for execution:

  • Simulation range checks.

  • Automatic scaling of fixed point data types.

  • Optimising the code you generate from the model. This optimisation can remove algorithmic code and affect the results of some simulation modes.

The parameter does not saturate or trim the actual output signal. Instead, use the block Saturation.

Usage in program code

Block parameter

OutMax

Value

[ ] | скаляр

By default

[ ]

Lock data type settings against changes by the fixed-point tools - block automatic scaling of data types
выключено (by default) | включено

A check box that blocks automatic scaling of fixed-point data types.

Usage in program code

Block parameter

LockScale

Value

выключено | включено

By default

выключено

Read More

Mutual correlation function

Mutually correlation function is a measure of the similarity of two sequences with discrete time depending on the lag of one relative to the other.

For two deterministic input data of length N or realisations of jointly stationary wideband random processes (WSS), and , the mutual correlation is calculated using the following relationship:

Where:

  • - delay

  • - complex conjugation.

If the input data are realisations of shared stationary random processes, is a non-normalised estimate of the theoretical mutual correlation:

ρ ,

where:

  • - operator of the mathematical expectation.

Algorithms

Computations in time domain

When you set the calculation area to Time, the algorithm calculates the mutual correlation of two signals in the time domain. The input signals can be fixed-point signals in this domain.

Correlation of two two-dimensional arrays

When the input data are two two-dimensional arrays, the -th column of the output data, , contains these elements:

Where:

  • - complex conjugation.

  • - input matrix Mu on N.

  • - input matrix Mv on N.

  • - matrix Mu+Mv-1 on N.

The inputs and are zero if they are indexed outside their valid ranges.

Correlation of a column vector with a two-dimensional array

When one input signal represents a column vector and the other input signal represents a two-dimensional array, the algorithm independently cross-correlates the input vector with each column of the two-dimensional array. -th column of the output data, contains these elements:

Where:

  • - complex conjugate.

  • - input matrix Mu by 1.

  • - input matrix Mv by N.

  • - matrix Mu+Mv-1 by N.

The inputs and are zero if they are indexed outside their valid ranges.

Correlation of two column vectors

When the input data are two column vectors, the -th column of the output data, , contains these elements:

Where:

  • - complex conjugate.

  • - input matrix Mu by 1.

  • - input matrix Mv by 1.

  • - matrix Mu+Mv-1 by 1.

The inputs and are zero if they are indexed outside their valid ranges.

Calculations in the frequency domain

When you set the frequency value for the computation domain, the algorithm computes the mutual correlation in the frequency domain.

To calculate the mutual correlation, the algorithm:

  • Takes the Fourier transform of both input signals, and .

  • Multiplies and , where is the complex pairing.

  • Calculates the inverse Fourier transform for the product.

In this area, depending on the length of the input data, the algorithm may require fewer calculations.