Divide
Multiplication and division of scalars and non-scalars.
|
|
|
|
|
Description
The Divide block outputs the result of multiplying or dividing the input signals.
The block icon, the operation to be performed and the number of ports change depending on the values of Multiplication and Number of inputs.
This table shows the output of the Divide block for approximate input data using the block parameter values:
-
Multiplication:
Element-wise(.*)
. -
Number of inputs:
*/
Input data | Block behaviour |
---|---|
scalar ÷ scalar |
Outputs the result of dividing the first input scalar by the second. |
scalar ÷ non-scalar |
Outputs a non-scalar that has the same dimensions as the input non-scalar. Each element of the output non-scalar is the result of division of the input scalar by the corresponding element of the input non-scalar. |
nonscalar ÷ nonscalar |
Outputs a nonscalar having the same dimensions as the input data. Each element of the output data is the result of dividing an element of the first input nescalar by the corresponding element of the second input nescalar. |
The Divide block can:
-
Numerically multiply and divide any number of scalar, vector or matrix inputs.
-
Perform matrix multiplication and division on any number of matrix inputs.
The Divide block performs piecewise or matrix multiplication or division, depending on the value of the Multiplication parameter. The block accepts one or more streams of input data, depending on the Number of inputs parameter. The Number of inputs parameter also determines the operation to be performed for each input.
The input data for the Divide block can be any combination of scalars, vectors and matrices for which the operation to be performed has a mathematically defined result. The block performs the specified operations on the input data, then outputs the result.
The Divide block has two modes:
-
Element-wise mode, which processes non-scalar input data element-by-element.
-
Matrix mode, which processes non-scalar input data as matrices.
Element-Wise Mode
When you set Multiplication to Element-wise(.)
, the *Divide block is in Element-wise mode, in which it operates on the individual numeric elements of any non-scalar input data. In Element-wise mode the Divide block can perform various multiplication, division and arithmetic inversion operations.
The Number of inputs determines both the number of inputs and whether each will be multiplied or divided to form the output.
When the Divide block is in Element-wise mode and has only one input, it operates as described in section [Алгоритмы].
To calculate the output data, the block first expands all inputs to a single size (using the standard broadcast) and then performs element-by-element operations.
This table shows the output of the Divide block for sample inputs using the specified values for the Number of inputs parameter.
Parameter values | Example |
---|---|
Number of inputs: |
|
Number of inputs: |
|
Number of inputs: |
|
Number of inputs: |
|
Number of inputs: |
Matrix Mode
When the value of Multiplication is Matrix()
, the *Divide block is in Matrix mode, in which it processes non-scalar input data in the form of matrices. In this mode, the Divide block can invert a single square matrix or multiply and divide any number of matrices whose dimensions are defined mathematically.
The value of the Number of inputs parameter determines both the number of inputs that exist and whether each input matrix will be multiplied or divided to form the output. The syntax of Number of inputs is the same as in Element-wise mode. The difference between the modes is the type of multiplication and division.
Interactions between block inputs and modes
The interactions between the Divide block inputs and its Multiplication modes:
-
* or /
The block has a single input port. In Element-wise mode, the block processes input data as described in section [Алгоритмы]. In Matrix mode, if the parameter value is
1
or*
, the block outputs the input value. If the value is/
, the input data must be a square matrix (including a scalar as a degenerate case), and the block outputs the inverse matrix. For more information, see Sections Element-Wise Mode и Matrix Mode. -
Total value > 1
The block has the amount of input data specified by an integer value. The input data is multiplied together in Element-wise mode or in Matrix mode as specified by the Multiplication parameter. For more information, see sections Element-Wise Mode и Matrix Mode.
-
A unquoted string of two or more characters * and /
The block has a number of inputs given by the length of the character vector. Each input signal corresponding to a
character is multiplied by an output signal. Each output signal corresponding to the symbol
/
is divided by the input signal. Operations are performed in *Element-wise mode or in Matrix mode as specified by the Multiplication parameter. For more information, see sections Element-Wise Mode и Matrix Mode.
Ports
Input
x - input signal for multiplication
scalar
| vector
| matrix
Input signal for multiplication with other input signals.
Dependencies
To use one or more x ports, specify one or more characters for the *Number of inputs parameter and set the Multiplication parameter to
Element-wise(.*)
.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, Int128
, UInt8
, UInt16
, UInt32
, UInt64
, UInt128
, Fixed
, Bool
.
Support for complex numbers: Yes
÷ - input signal for division
scalar
| vector
| matrix
Input signal for division or inversion operations.
Dependencies
To use one or more ÷ ports, specify one or more /
characters for the Number of inputs parameter and set the Multiplication parameter to Element-wise(.*)
.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, Int128
, UInt8
, UInt16
, UInt32
, UInt64
, UInt128
, Fixed
, Bool
.
Support for complex numbers: Yes
* - input signal for multiplication
scalar
| vector
| matrix
Input signal for multiplication with other input signals.
Dependencies
To use one or more * ports, specify one or more characters for the *Number of inputs parameter and set the Multiplication parameter to
Matrix(*)
.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, Int128
, UInt8
, UInt16
, UInt32
, UInt64
, UInt128
, Fixed
, Bool
.
Support for complex numbers: Yes
Inv - input signal for division or inversion
scalar
| vector
| matrix
Input signal for division or inversion operations.
Dependencies
To use one or more Inv ports, specify one or more /
characters for the Number of inputs parameter and set the Multiplication parameter to Matrix(*)
.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, Int128
, UInt8
, UInt16
, UInt32
, UInt64
, UInt128
, Fixed
, Bool
.
Support for complex numbers: Yes
Parameters
Main
Number of inputs - number and names of input ports and type of operation
*/ (By default)
Operations performed by the block: multiplication or division.
When you specify:
-
* or /*
Block parameter |
|
Values |
|
By default |
|
Multiplication - multiplication type
Element-wise(.) (by default)
| Matrix(
)
Specify in which mode the block performs multiplication or division of Element-wise(.)
or Matrix(
)
.
For more information, see sections Element-Wise Mode и Matrix Mode.
Block parameter |
|
Values |
|
By default |
|
Signal Attributes
Output data type - output data type
Inherit: auto
| Same as first input
| Int8
| Int16
| Int32
| Int64
| Int128
| UInt8
| UInt16
| UInt32
| UInt64
| UInt128
| Float16
| Float32
| Float64
| Bool
| Fixed point
Specify the output data type. The type can be inherited, specified directly, or expressed as a datatype object.
Block parameter |
|
Value |
|
* By default* |
|
Output fixed-point type - output fixed-point number type
Fixed{Int16, 0} (By default)
| description of fixed-point data type
Specify the output type of fixed-point numbers.
Dependencies
Turns ON when the Output data type parameter is set to Fixed point
.
Block parameter |
|
Value |
|
By default |
|
Integer rounding mode - rounding mode for fixed point operations
Floor (by default)
| Ceiling
| Convergent
| Nearest
| Round
| Zero
Select the rounding mode for fixed point operations. You can select:
-
Floor
- rounds both positive and negative numbers downwards (towards negative infinity). -
Ceiling
- rounds both positive and negative numbers upwards (towards positive infinity). -
Convergent
- rounds a 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 upwards (towards positive infinity). -
Round
- rounds the number to the nearest representable value. If the fractional part of the 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.
Block parameters are always rounded to the nearest representable value.
Block parameter |
|
Values |
|
* By default* |
|
Saturate on integer overflow - saturate to integer on overflow
Off (By default)
| On
A checkbox which, when checked, uses saturation arithmetic for integers and fixed-point numbers: when overflow occurs, the result is automatically replaced by the maximum possible (modulo) value for the data type.
Action | Rationale | Effect on overflow | Example |
---|---|---|---|
The Saturate on integer overflow checkbox is checked (enabled). |
Overflow is possible for your model, and you want the generated code to explicitly protect against overflow. |
When an overflow occurs, the result is automatically replaced with the maximum possible (modulo) value for the data type. |
The maximum value that the 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 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 |
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.
When the block’s input data type is a floating point type, the block ignores this setting.
Block parameter |
|
Values |
|
By default |
|
Require all inputs to have the same data type - same data type mode for all inputs
off (By default)
| on
Select this checkbox to set the same data type for all input ports.
Algorithms
A Divide block with a single input in `Element-Wise' mode uses the algorithms below to perform element-by-element operations on the input data:
Input data | Element operation | Algorithm |
---|---|---|
A valid scalar, |
Multiplication |
|
Division |
|
|
A valid vector or matrix with elements, |
Multiplication |
|
Division |
|
|
Complex scalar, |
Multiplication |
|
Division |
|
|
Complex vector or matrix with elements, |
Multiplication |
|
Division |
|