Cumulative Product

Compute cumulative product of channel, column, or row elements

Library

Math Functions / Math Operations

dspmathops

Description

The Cumulative Product block computes the cumulative product of elements in each channel, column, or row of the M-by-N input matrix.

The inputs can be sample-based or frame-based vectors and matrices. The output always has the same dimensions, rate, frame status, data type, and complexity as the input.

The Cumulative Product block accepts real and complex fixed-point and floating-point inputs except for complex unsigned fixed-point inputs.

Valid Input

The block computes the cumulative product of both sample- and frame-based vector and matrix inputs. Inputs can be real or complex. When multiplying along channels or columns, 1-D unoriented vectors are treated as column vectors. When multiplying along rows, 1-D vectors are treated as row vectors.

Valid Reset Signal

The optional reset port, Rst, accepts scalar values, which can be any built-in Simulink® data type including boolean. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input.

Output Characteristics

The output always has the same dimensions, rate, frame status, data type, and complexity as the data signal input.

Multiplying Along Channels of Frame-Based Inputs

For frame-based inputs, the block treats each input column as an independent channel. As the following figure and equation illustrate, the output has the following characteristics:

Given an M-by-N frame-based input, u, the output, y, is a frame-based M-by-N matrix whose first row has elements

Multiplying Along Channels of Sample-Based Inputs

For sample-based inputs, the block treats each element of the input matrix as an independent channel. As the following figure and equation illustrate, the output has the following characteristics:

Given an M-by-N sample-based input, u, the output, y, is a sample-based M-by-N matrix with the elements

For convenience, length-M 1-D vector inputs are treated as M-by-1 column vectors when multiplying along channels, and the output is a length-M 1-D vector.

Resetting the Cumulative Product Along Channels

When you set the Multiply input along parameter to Channels (running product), you can set the block to reset the running product whenever it detects a reset event at the optional Rst port. The reset sample time must be a positive integer multiple of the input sample time. The input to the Rst port can be of the Boolean data type.

When the block is reset for sample-based inputs, the block initializes the current output to the values of the current input. For frame-based inputs, the block initializes the first row of the current output to the values in the first row of the current input.

The Reset port parameter specifies the reset event, which can be one of the following:

Multiplying Along Columns

When the Multiply input along parameter is set to Columns, the block computes the cumulative product of each column of the input, where the current cumulative product is independent of the cumulative products of previous inputs.

y = cumprod(u)						% Equivalent MATLAB code

The output has the same size, dimension, frame status, data type, and complexity as the input. The mth output row is the element-wise product of the first m input rows.

Given an M-by-N input, u, the output, y, is an M-by-N matrix whose jth column has elements

The block treats length-M 1-D vector inputs as M-by-1 column vectors when multiplying along columns.

Multiplying Along Rows

When the Multiply input along parameter is set to Rows, the block computes the cumulative product of the row elements, where the current cumulative product is independent of the cumulative products of previous inputs.

y = cumprod(u,2)						% Equivalent MATLAB code

The output has the same size, dimension, frame status, and data type as the input. The nth output column is the element-wise product of the first n input columns.

Given an M-by-N input, u, the output, y, is an M-by-N matrix whose ith row has elements

The block treats length-N 1-D vector inputs as 1-by-N row vectors when multiplying along rows.

Fixed-Point Data Types

The following diagram shows the data types used within the Cumulative Product block for fixed-point signals.

The output of the multiplier is in the product output data type when at least one of the inputs to the multiplier is real. When both of the inputs to the multiplier are complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication performed, see Multiplication Data Types. You can set the accumulator, product output, intermediate product, and output data types in the block dialog as discussed in Dialog Box.

Dialog Box

The Main pane of the Cumulative Product block dialog appears as follows.

Multiply input along

The dimension along which to compute the cumulative products. The options allow you to multiply along Channels (running product), Columns, and Rows. For more information, see the following sections:

Reset port

Determines the reset event that causes the block to reset the product along channels. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input. This parameter is enabled only when you set the Multiply input along parameter to Channels (running product). For more information, see Resetting the Cumulative Product Along Channels.

The Fixed-point pane of the Cumulative Product block dialog appears as follows.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Intermediate product

As shown in Fixed-Point Data Types, the output of the multiplier is cast to the intermediate product data type before the next element of the input is multiplied into it. Use this parameter to specify how you would like to designate the intermediate product word and fraction lengths:

Product output

Use this parameter to specify how you would like to designate the product output word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block:

Accumulator

Use this parameter to specify how you would like to designate the accumulator word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the accumulator data type in this block. Note that the accumulator data type is only used when both inputs to the multiplier are complex:

Output

Choose how you specify the word length and fraction length of the output of the block:

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling tool in the Fixed-Point Tool.

Supported Data Types

Input and Output PortsSupported Data Types

Data input port, In

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Reset input port, Rst

All built-in Simulink data types:

  • Double-precision floating point

  • Single-precision floating point

  • Boolean

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Output port

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

See Also

Cumulative SumSignal Processing Blockset
Matrix ProductSignal Processing Blockset
cumprodMATLAB

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS