# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

# conv

Convolution and polynomial multiplication of `fi` objects

## Syntax

`c = conv(a,b)c = conv(a,b,'shape')`

## Description

`c = conv(a,b)` outputs the convolution of input vectors `a` and `b`, at least one of which must be a `fi` object.

`c = conv(a,b,'shape')` returns a subsection of the convolution, as specified by the `shape` parameter:

• `full` — Returns the full convolution. This option is the default shape.

• `same` — Returns the central part of the convolution that is the same size as input vector `a`.

• `valid` — Returns only those parts of the convolution that the function computes without zero-padded edges. In this case, the length of output vector `c` is ```max(length(a)-max(0,length(b)-1), 0)```.

The `fimath` properties associated with the inputs determine the `numerictype` properties of output `fi` object `c`:

• If either `a` or `b` has a local `fimath` object, `conv` uses that `fimath` object to compute intermediate quantities and determine the `numerictype` properties of `c`.

• If neither `a` nor `b` have an attached fimath, `conv` uses the default fimath to compute intermediate quantities and determine the `numerictype` properties of `c`.

If either input is a built-in data type, `conv` casts it into a `fi` object using best-precision rules before the performing the convolution operation.

The output `fi` object `c` always uses the default fimath.

Refer to the MATLAB® `conv` reference page for more information on the convolution algorithm.

## Examples

The following example illustrates the convolution of a 22-sample sequence with a 16-tap FIR filter.

• `x` is a 22-sample sequence of signed values with a word length of 16 bits and a fraction length of 15 bits.

• `h` is the 16 tap FIR filter.

``` u = (pi/4)*[1 1 1 -1 -1 -1 1 -1 -1 1 -1]; x = fi(kron(u,[1 1])); h = firls(15, [0 .1 .2 .5]*2, [1 1 0 0]); ```

Because `x` is a `fi` object, you do not need to cast `h` into a `fi` object before performing the convolution operation. The `conv` function does so using best-precision scaling.

Finally, use the `conv` function to convolve the two vectors:

``` y = conv(x,h); ```

The operation results in a signed `fi` object `y` with a word length of 36 bits and a fraction length of 31 bits. The default `fimath` properties associated with the inputs determine the `numerictype` of the output. The output does not have a local `fimath`.