Engee documentation

Gain

Multiplies the input signal by a constant.

blockType: Gain

Path in the library:

/Basic/Math Operations/Gain

Description

Unit Gain multiplies the value of the input signal by a constant value (gain). The input signal and gain can be scalar, vector or matrix.

The gain is set by the parameters Gain. Parameters Multiplication parameter allows you to specify element-by-element or matrix multiplication. For matrix multiplication, this parameter also allows you to specify the order of multipliers.

When calculating the output signal, the block Gain uses the following rules:

  • If the input signal is of a real type and the gain is complex, the output signal type will be complex.

  • If the input signal type is different from the gain type, Engee tries to convert the gain type to the input signal type. If such a conversion is not possible, the calculation will be stopped and an error message will be displayed. This situation may occur, for example, if the input signal is an unsigned integer (Uint8), and the parameter Gain is set as a negative number.

Ports

Input

# IN_1 — input signal
scalar | vector | matrix

Details

Block Gain supports both real and complex scalar, vector or matrix input signals. If the block input signal Gain is real and the gain is complex, the output signal will be complex.

Data types

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

Complex numbers support

Yes

Output

# OUT_1 — input signal multiplied by the amplification factor
scalar | vector | matrix

Details

The input signal multiplied by the gain. If the block input signal Gain is real and the gain is complex, the output signal will be complex.

Data types

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

Complex numbers support

Yes

Parameters

Main

# Gain — coefficient by which the input signal should be multiplied
Scalar / array of real and/or complex numbers

Details

Specifies the factor by which to multiply the input signal. The gain can be a real or complex scalar, vector or matrix of any type except logic.

Default value

1.0

Program usage name

Gain

Tunable

Yes

Evaluatable

Yes

# Multiplication — multiplication mode
Element-wise(K.*u) | Matrix(K*u) | Matrix(u*K)

Details

Specify one of these multiplication modes:

  • Element-wise(K.*u) - each element of the input signal is multiplied by each element of the gain. If necessary, the unit performs expansions so that the input data and gain have the same size.

  • Matrix(K*u) - The input data and gain are multiplied by a matrix with usage of the input data as the second operand.

  • Matrix(u*K) - the input data and gain are multiplied by the matrix with usage of the input data as the first operand.

Values

Element-wise(K.*u) | Matrix(K*u) | Matrix(u*K)

Default value

Element-wise(K.*u)

Program usage name

Multiplication

Tunable

No

Evaluatable

No

Signal Attributes

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

Details

Sets the type of output data.

Values

Inherit: auto | Same as input | Float64 | Float32 | Float16 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Fixed-point

Default value

Inherit: auto

Program usage name

OutDataTypeStr

Tunable

No

Evaluatable

No

# Output fixed-point type — fixed-point output data type
Data type

Details

Specify the fixed-point output type.

Dependencies

To use this parameter, set parameter Output data type value Fixed-point.

Default value

fixdt(1, 16, 0)

Program usage name

OutDataTypeStrFixed

Tunable

No

Evaluatable

Yes

# Integer rounding mode — rounding mode for fixed-point operations
Ceiling | Convergent | Floor | Nearest | Round | Zero

Details

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

  • Ceiling - rounds both positive and negative numbers downwards (towards negative infinity).

  • Floor - rounds both positive and negative numbers upwards (towards positive infinity).

  • Convergent - rounds the 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 representable value. If the fractional part of the number ends in 5, the number is rounded upwards (towards positive infinity).

  • Round - rounds the number to the nearest representable value. If the fractional part of a number ends in 5, positive numbers are rounded upwards (towards positive infinity) and negative numbers are rounded downwards (towards negative infinity).

  • Zero - rounds the number towards zero.

Values

Ceiling | Convergent | Floor | Nearest | Round | Zero

Default value

Floor

Program usage name

RndMeth

Tunable

No

Evaluatable

No

# Saturate on integer overflow — overflow action method
Logical

Details

When checked, saturation is applied to all internal block operations, not just the output or result.

Action Reasons for taking this action What happens when overflows Example

Check this box.

Overflows are possible in your model and you need explicit saturation protection in the generated code.

Overflows are saturated to the minimum or maximum value that this data type can represent.

An overflow associated with a signed 8-bit integer may saturate to -128 or 127.

Do not select this check box.

You want to optimise the efficiency of the generated code.
You want to avoid over-specifying how the block handles out-of-range signals.

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

The number 130 does not fit into a signed 8-bit integer and is collapsed into -126

Default value

false (switched off)

Program usage name

SaturateOnIntegerOverflow

Tunable

No

Evaluatable

No

Parameter Attributes

# Parameter data type — parameter data type
Inherit: auto | Same as input | Float64 | Float32 | Float16 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Fixed-point

Details

Sets the data type of the parameters.

Values

Inherit: auto | Same as input | Float64 | Float32 | Float16 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Fixed-point

Default value

Inherit: auto

Program usage name

ParamDataTypeStr

Tunable

No

Evaluatable

No

# Parameter fixed-point type — fixed-point parameter data type
Data type

Details

Specify the data type of the fixed-point parameters.

Dependencies

To use this parameter, set parameter Parameter data type value Fixed-point.

Default value

fixdt(1, 16, 0)

Program usage name

ParamDataTypeStrFixed

Tunable

No

Evaluatable

Yes

Additional options

C code generation: Yes

Examples