hdl.treeprod
Product of array elements using tree architecture
Description
returns the product of the elements of A. B
= hdl.treeprod(A
)
If
A
is a vector, thenhdl.treeprod(A)
returns the product of the elements.If
A
is a matrix, thenhdl.treeprod(A)
returns a row vector containing the products of each column.
The function hdl.treeprod
uses a tree architecture to multiply
elements. The tree architecture multiplication yields a shorter critical path, which leads
to reduced latency when generating HDL code from a MATLAB Function block.
When generating HDL code, the function hdl.treeprod
reduces the amount
of matching delays required to multiply elements.
Examples
Product of Vector Elements
Create a vector and compute the product of its elements.
A = 1:5; B = hdl.treeprod(A)
B = 120
Product of Matrix Elements
Create a matrix and compute the product of its elements.
A = [1 3 2; 4 2 5; 6 1 4]
A = 3×3
1 3 2
4 2 5
6 1 4
B = hdl.treeprod(A,'all')
B = 5760
Product of Matrix Columns
Create a matrix and compute the product of the elements in each column.
A = [1 3 2; 4 2 5; 6 1 4]
A = 3×3
1 3 2
4 2 5
6 1 4
B = hdl.treeprod(A)
B = 1×3
24 6 40
Product of Matrix Rows
Create a matrix and compute the product of the elements in each row.
A = [1 3 2; 4 2 5; 6 1 4]
A = 3×3
1 3 2
4 2 5
6 1 4
B = hdl.treeprod(A,2)
B = 3×1
6
40
24