Engee documentation

Logical Operator

Perform the specified logic operation on the input signals.

logical operator

Description

The Logical Operator block performs the specified logical operation on one or more operands. The input value is interpreted as true (1) if it is not equal to zero, and false (0) if it is equal to zero.

The specific logical operation can be selected in the block settings using the Operator parameter.

The table shows the supported logical operations:

Operation Description

AND

true if all inputs are false

OR

true if at least one input is true

NAND

true if at least one input is false

NOR

true when no input is true

XOR

true if an odd number of inputs true

NXOR

true if even number of inputs true

NOT

true if the input is false

The block icon changes depending on the logical operation selected in the Operator parameter. The number of input ports is set in the Number of input ports parameter.

The size of the output depends on the size of the input vector and the operator selected:

  • If a block has more than one input, the dimensionality of the remaining ports is expanded to the maximum possible using broadcast operations. For example, if the signals on the input have dimensions 4 by 1, 1 by 5, and 1 by 1, broadcast will produce an array of size 4 by 5 on the output. This process automatically expands the arrays along dimensions equal to one to match the dimensions of the input data for computation.

    Broadcast is the process of automatically bringing arrays to compatible dimensions for operations. Broadcast works according to the rules of "propagation" along dimensions equal to one: if arrays have mismatched dimensions but at least one of the dimensions is 1, then the operation is performed, with the array expanded along the appropriate dimension.

    The dimensionality of scalar input signals is expanded to the dimensionality of non-scalar input signals, which is also achieved with the broadcast operation. If a block has several inputs and one of them is scalar, broadcast automatically expands it to the same dimension as the other inputs.

    If a block has more than one input, the output has the same dimensions as the inputs, and each output element is the result of applying the specified logical operation to the corresponding input elements. For example, if the AND operation is specified and the input data are 2 by 2 arrays, the output will be a 2 by 2 array whose upper left element is the result of applying AND to the upper left elements of the input data, and so on.

  • For a single input vector, the block applies an operation (other than the NOT operator) to all elements of the vector. The output in this case is always a scalar.

  • The NOT operator takes only one input, which can be a scalar or a vector. If the input represents a vector, the output represents a vector of the same size containing the logical complements of the elements of the input vector.

Ports

Input

Port_1 - first input signal
scalar | vector | matrix

First input signal. Scalar, vector or matrix.

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

Port_2 - second input signal
scalar | vector | matrix

Second input signal. Scalar, vector or matrix.

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

Port_N - N-th input signal
scalar | vector | matrix

N-th input signal. Scalar, vector or matrix.

Dependencies

To use additional input ports, use the Number of input ports parameter.

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

Output

Port_1 - output signal
scalar | vector | matrix

Output signal consisting of zeros and ones with the same dimensions as the input.

Data types: Bool.

Parameters

Operator - logical operator
AND (by default) | OR | NAND | NOR | XOR | NXOR | NOT

Select the logic operator to be applied to the input signals of the block.

  • AND - true if all inputs are true.

  • OR - true if at least one input is true.

  • NAND - true if at least one input is false.

  • NOR - true when there is no input true.

  • XOR - true if an odd number of inputs are true.

  • NXOR - true if an even number of inputs are true.

  • NOT - true when the input is false.

Usage in program code

Block parameter

Operator

Value

AND | OR | NAND | NOR | XOR | NXOR | NOT

* By default *

AND

Number of input ports - number of inputs
2 (By default) | `positive number

Set the number of input ports of the block as a positive integer.

Dependencies

This parameter is not available when Operator is set to NOT.

Usage in program code

Block parameter

Inputs

Value

positive integer

By default

2

Additional options

C code generation: Yes