Main Content

mpy

Multiply two arrays using fimath object

Description

c = mpy(F,a,b) performs elementwise multiplication on a and b using fimath object F. This is helpful in cases when you want to override the fimath objects of a and b, or if the fimath properties associated with a and b are different. The output c has no local fimath.

example

Examples

collapse all

In this example, c is the 40-bit product of a and b with fraction length 30.

a = fi(pi);
b = fi(exp(1));
F = fimath('ProductMode','SpecifyPrecision',...
		'ProductWordLength',40,'ProductFractionLength',30);
c = mpy(F,a,b)
c = 

    8.5397

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 40
        FractionLength: 30

Input Arguments

collapse all

fimath object to use for addition.

Operands, specified as scalars, vectors, matrices, or multidimensional arrays.

a and b must have the same dimensions unless one is a scalar. If either a or b is scalar, then c has the dimensions of the nonscalar object.

If a or b is a fi object, then both a and b must be fi objects.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
Complex Number Support: Yes

Algorithms

When you use the mpy function, the fimath properties of a and b are not modified, and the output c has no local fimath.

c = mpy(F,a,b)
is equivalent to
c = removefimath(setfimath(a,F) .* setfimath(b,F))

Extended Capabilities

Version History

Introduced before R2006a