Divide
Performs multiplication and division of scalars and non-scalars.
blockType: Product
Divide Path in the library:
|
|
Product Path in the library:
|
|
Product of Elements Path in the library:
|
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 value of the parameters Multiplication and Number of inputs.
This table shows the output of the Divide block for approximate input data usage of the block parameters 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. |
Block Divide 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 parameters Multiplication. The block accepts one or more streams of input data, depending on the parameters Number of inputs. The Number of inputs parameters also define the operation to be performed for each input.
The input data for the block Divide 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(.*)
- processes non-scalar input data element by element. -
Matrix(*)
- processes non-scalar input data in the form of matrices.
Element-by-element mode
When you set Multiplication to Element-wise(.*)
, the Divide block works with the individual numeric elements of any non-scalar input data. In the Element-wise(.*)
the Divide block can perform various multiplication, division, and arithmetic inversion operations.
The value of the Number of inputs parameters determines both the number of input data and whether each will be multiplied or divided to form the output data.
When the Divide block is in the Element-wise(.*)
and has only one input, it operates as described in section Algorithms.
To compute the output, 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 example inputs usage of the specified values for the parameters Number of inputs.
Значения параметра | Example |
---|---|
Number of inputs: |
|
Number of inputs: |
|
Number of inputs: |
|
Number of inputs: |
|
Number of inputs: |
Matrix mode
When the value of the parameter Multiplication is equal to Matrix(*)
, the Divide block 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 parameters Number of inputs determines both the number of existing input data and whether each input matrix will be multiplied or divided to form the output data. The syntax of Number of inputs is the same as for mode Element-wise(.*)
. The difference between the modes is the type of multiplication and division.
Interactions between block inputs and modes
Interactions between the block inputs Divide and its modes Multiplication:
-
The parameters Number of inputs are set to
1
,*
or/
.The block has one input port. In mode
Element-wise(.*)
the block processes input data as described in the section Algorithms. In mode.Matrix(*)
, if the value of the parameters is1
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-by-element mode и Matrix mode. -
The parameters Number of inputs is set to an integer value > 1
The block has the number of input data specified by an integer value. The input data is multiplied together in the
Element-wise(.*)
or in modeMatrix(*)
, as specified by the parameters Multiplication. For more information, see sections Element-by-element mode и Matrix mode. -
The parameter Number of inputs specifies an unquoted string of two or more
*
and/
charactersThe 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. The operations are performed in the modeElement-wise(.*)
or in mode `Matrix(*)`as specified by the parameters *Multiplication. For more information, refer to Element-by-element mode и Matrix mode.
Ports
Output
#
OUT_1
—
output signal
scalar
| vector
| matrix
Details
An output signal calculated by multiplying or dividing input signals.
Data types |
|
Complex numbers support |
Yes |
Input
#
x
—
input signal for multiplication
scalar
| vector
| matrix
Details
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(.*)
.
To use one or more * ports, specify one or more characters for the *Number of inputs parameter and set the Multiplication parameters to .
Matrix(*)
.
Data types |
|
Complex numbers support |
Yes |
#
/
—
input signal for division or inversion
scalar
| vector
| matrix
Details
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(.*)
.
To use one or more Inv ports, specify one or more /
characters for the parameter Number of inputs and set the parameters Multiplication to . Matrix(*)
.
Data types |
|
Complex numbers support |
Yes |
Parameters
BaseSettings
# Number of inputs — number and names of input ports and type of operation
Details
Operations performed by the block: multiplication or division.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
#
Multiplication —
multiplication type
Element-wise(.)
| Matrix(
)
Details
Specify in which mode the unit performs multiplication or division Element-wise(.*)
or Matrix(*)
.
For more information, see Element Mode and Matrix Mode.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
Output settings
#
Output data type —
output data type
Inherit: auto
| Same as first input
| Float64
| Float32
| Float16
| Int8
| UInt8
| Int16
| UInt16
| Int32
| UInt32
| Int64
| UInt64
| Int128
| UInt128
| Fixed-point
Details
Specify the type of output data. The type can be inherited or specified directly.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
#
Output fixed-point type —
fixed-point output data type
Data type
Details
Specify the type of fixed-point output data.
Dependencies
To use this parameter, set the Output data type parameters to 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 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 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 |
|
Default value |
|
Program usage name |
|
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 |
Do not select this check box. |
You want to optimise the efficiency of the generated code. |
Overflows are wrapped in an appropriate value that can be represented by a data type. |
The number |
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
#
Require all inputs to have the same data type —
mode of the same data type for all inputs
Logical
Details
Select this check box to set the same data type for all input ports.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
Algorithms
The block Divide with one input in the mode Element-wise(.*)
uses the algorithms below to perform element-by-element operations on input data:
Input data | Piecewise operation | Algorithm |
---|---|---|
Real scalar, |
Multiplication |
|
Division |
|
|
A valid vector or matrix with elements, |
Multiplication |
|
Division |
|
|
Complex scalar, |
Multiplication |
|
Division |
|
|
Complex vector or matrix with elements, |
Multiplication |
|
Division |
|