Logical Operator
Perform the specified logic operation on the input signals.
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 |
---|---|
|
true if all inputs are false |
|
true if at least one input is true |
|
true if at least one input is false |
|
true when no input is true |
|
true if an odd number of inputs true |
|
true if even number of inputs true |
|
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 applyingAND
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
.
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.
Block parameter |
|
Value |
|
* By default * |
|
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
.
Block parameter |
|
Value |
|
By default |
|