Add
Performs addition or subtraction of input signals.
blockType: Sum
Add Path in the library:
|
|
Sum of Elements Path in the library:
|
Description
Block Add performs addition or subtraction of input signals. This unit can add or subtract scalar, vector, or matrix signals. It can also summarize the elements of the signal.
Block operations are set using the parameter List of Signs. Available operations and symbols:
-
Addition (+).
-
Subtraction (−).
-
The number of characters + and − is equal to the number of input ports of the block.
For example, if you specify for the parameter List of Signs The value is −, the block will have three input ports. The block subtracts the second (middle) input signal from the first (upper) one, and then adds the third (lower) one.
-
If only addition is performed, then you can set a numeric value equal to the number of input data.
Calculating the output value
Calculating the output value for a block Add depends on the number of block inputs and the sign of the input ports:
If the block has | I… | The formula for calculating the output value… | * Where…* |
---|---|---|---|
One input port |
Input port sign |
|
|
Input port sign |
|
||
Two or more input ports |
All input port signs are |
|
|
The kth input port is the first port with a |
|
Ports
Output
#
OUT_1
—
Output signal
scalar
| vector
| matrix
Details
The output signal obtained as a result of addition and/or subtraction operations. The output signal has the same size as the input signals.
Data types |
|
Complex numbers support |
Yes |
Input
#
In_1
—
the first input signal
scalar
| vector
| matrix
Details
An input signal for an addition or subtraction operation. If there is only one input signal, then addition or subtraction is performed for all its elements.
Data types |
|
Complex numbers support |
Yes |
#
In_n
—
the nth input signal of the operand
scalar
| vector
| matrix
Details
the nth input signal for operations. The number of input signals corresponds to the number of characters in the parameter List of Signs. The block applies operations to the input data in the specified order.
All non-scalar input data must have the same dimensions. Scalar inputs are expanded to have the same dimensions as other inputs.
Data types |
|
Complex numbers support |
Yes |
Parameters
Main
# List of Signs — operations performed on input data
Details
Enter the addition and subtraction operations performed on the input data. An input port is created for each operation.
Addition is the default operation. The operations are performed in the specified order.
For a single vector input + or − adds or subtracts elements in all dimensions.
If only addition is performed, then you can set a numeric value equal to the number of input data.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
#
Apply over —
applying a function to specified measurements
All dimensions
| Specified dimension
Details
Specify how to use the function:
-
All dimensions
— Apply the function to all input values for all measurements.For example, if in the parameter List of Signs the value is set to
+
, and for the parameter Apply over — valueAll dimensions
, then the block returns the sum of all input values across all dimensions. If the input is a two-dimensional matrix[1 2 3; 4 5 6]
, then the output will be `21'. -
Specified dimension
— apply the function to all input values for the specified measurement.
Dependencies
To use this parameter, set for the parameter List of Signs just one sign.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
#
Dimension —
the dimension that will be used for summation
Integer
Details
Specify the dimension for which the summation will be performed as a positive integer.
Let’s assume that — a 2 by 3 matrix:
-
if for the parameter Dimension if the value is set to
1
, then the resulting sum is :
-
if for the parameter Dimension if the value is set to `2', then the resulting sum is :
For example, if in the parameter List of Signs the value +
is set for the parameter Apply over — value Specified dimension
, and for the parameter Dimension — the value is 2', then the block returns the sum of all input values of each row. If the input is a two-dimensional matrix `[1 2 3; 4 5 6]
, then the output will be `[6; 15]'.
If the specified dimension is greater than the dimension of the input data, an error message appears.
Dependencies
To use this parameter, set for the parameter Apply over meaning Specified dimension
.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
Accumulator settings
#
Accumulator data type —
storage data type
Inherit: auto
| Same as first input
| Float64
| Float32
| Float16
| Int8
| UInt8
| Int16
| UInt16
| Int32
| UInt32
| Int64
| UInt64
| Int128
| UInt128
| Fixed-point
Details
Select the data type for the drive.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
#
Accumulator fixed-point type —
fixed point data type for the drive
Data type
Details
Specify the fixed-point data type for the drive.
Dependencies
To use this parameter, set for the parameter Accumulator data type meaning Fixed-point
.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
Output settings
#
Output data type —
type of output data
Inherit: auto
| Same as accumulator
| Same as first input
| Float64
| Float32
| Float16
| Int8
| UInt8
| Int16
| UInt16
| Int32
| UInt32
| Int64
| UInt64
| Int128
| UInt128
| Fixed-point
Details
Select the type for the output data.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
#
Output fixed-point type —
the type of fixed-point output
Data type
Details
Specify the fixed-point data type for the output data.
Dependencies
To use this parameter, set for the parameter Output data type meaning Fixed-point
.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
Main
#
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 choose:
-
Floor
— rounds down both positive and negative numbers (towards negative infinity). -
Ceiling
— rounds up both positive and negative numbers (towards positive infinity). -
Convergent
— rounds the number to the nearest representable value. If the fractional part of the 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 up (towards positive infinity). -
Round
— rounds the number to the nearest integer.
-
Zero
— rounds the number towards zero.
The block parameters are always rounded to the nearest representable value.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
#
Saturate on integer overflow —
method of action in case of overflow
Logical
Details
When this option is selected, saturation is applied to all internal block operations, not just the output or result.
Action | Reasons for making this decision | What happens when there is an overflow | Example |
---|---|---|---|
Check this box. |
Overflow is possible in your model, and you need explicit protection against saturation in the generated code. |
Overflows are saturated to the minimum or maximum value that a given data type can represent. |
Overflow associated with a signed 8-bit integer can saturate to |
Do not check this box. |
You want to optimize the efficiency of the generated code. |
Overflows are wrapped into an appropriate value, which can be represented by a data type. |
The number |
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |