# OpenStax_CNX

You are here: Home » Content » Programs for Circular Convolution

### Recently Viewed

This feature requires Javascript to be enabled.

### Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

# Programs for Circular Convolution

Module by: Ivan Selesnick, C. Sidney Burrus. E-mail the authors

Note: You are viewing an old version of this document. The latest version is available here.

## Programs for Circular Convolution

To write a program that computes the circular convolution of hh and xx using the bilinear form Equation 24 in Bilinear Forms for Circular Convolution we need subprograms that carry out the action of PP, PtPt, RR, RtRt, AA and BtBt. We are assuming, as is usually done, that hh is fixed and known so that u=CtR-tPJhu=CtR-tPJh can be pre-computed and stored. To compute these multiplicative constants uu we need additional subprograms to carry out the action of CtCt and R-tR-t but the efficiency with which we compute uu is unimportant since this is done beforehand and uu is stored.

In Prime Factor Permutations we discussed the permutation PP and a program for it pfp() appears in the appendix. The reduction operations RR, RtRt and R-tR-t we have described in Reduction Operations and programs for these reduction operations KRED() etc, also appear in the appendix. To carry out the operation of AA and BtBt we need to be able to carry out the action of Ad1AdkAd1Adk and this was discussed in Implementing Kronecker Products Efficiently. Note that since AA and BtBt are block diagonal, each diagonal block can be done separately. However, since they are rectangular, it is necessary to be careful so that the correct indexing is used.

To facilitate the discussion of the programs we generate, it is useful to consider an example. Take as an example the 45 point circular convolution algorithm listed in the appendix. From Equation 19 from Bilinear Forms for Circular Convolution we find that we need to compute x=P9,5xx=P9,5x and x=R9,5xx=R9,5x. These are the first two commands in the program.

We noted above that bilinear forms for linear convolution, (Dd,Ed,Fd)(Dd,Ed,Fd), can be used for these cyclotomic convolutions. Specifically we can take Api=Dφ(pi)Api=Dφ(pi), Bpi=Eφ(pi)Bpi=Eφ(pi) and Cpi=GpiFφ(pi)Cpi=GpiFφ(pi). In this case Equation 20 in Bilinear Forms for Circular Convolution becomes

A = 1 D 2 D 6 D 4 ( D 2 D 4 ) ( D 6 D 4 ) . A = 1 D 2 D 6 D 4 ( D 2 D 4 ) ( D 6 D 4 ) .
(1)

In our approach this is what we have done. When we use the bilinear forms for convolution given in the appendix, for which D4=D2D2D4=D2D2 and D6=D2D3D6=D2D3, we get

A = 1 D 2 ( D 2 D 3 ) ( D 2 D 2 ) ( D 2 D 2 D 2 ) ( D 2 D 3 D 2 D 2 ) A = 1 D 2 ( D 2 D 3 ) ( D 2 D 2 ) ( D 2 D 2 D 2 ) ( D 2 D 3 D 2 D 2 )
(2)

and since Ed=DdEd=Dd for the linear convolution algorithms listed in the appendix, we get

B = 1 D 2 t ( D 2 t D 3 t ) ( D 2 t D 2 t ) ( D 2 t D 2 t D 2 t ) ( D 2 t D 3 t D 2 t D 2 t ) . B = 1 D 2 t ( D 2 t D 3 t ) ( D 2 t D 2 t ) ( D 2 t D 2 t D 2 t ) ( D 2 t D 3 t D 2 t D 2 t ) .
(3)

From the discussion above, we found that the Kronecker products like D2D2D2D2D2D2 appearing in these expressions are best carried out by factoring the product in to factors of the form IaD2IbIaD2Ib. Therefore we need a program to carry out (IaD2Ib)x(IaD2Ib)x and (IaD3Ib)x(IaD3Ib)x. These function are called ID2I(a,b,x) and ID3I(a,b,x) and are listed in the appendix. The transposed form, (IaD2tIb)x(IaD2tIb)x, is called ID2tI(a,b,x) .

To compute the multiplicative constants we need CtCt. Using Cpi=GpiFφ(pi)Cpi=GpiFφ(pi) we get

C t = 1 F 2 t G 3 t F 6 t G 9 t F 4 t G 5 t ( F 2 t G 3 t F 4 t G 5 t ) ( F 6 t G 9 t F 4 t G 5 t ) = 1 F 2 t G 3 t F 6 t G 9 t F 4 t G 5 t ( F 2 t F 4 t ) ( G 3 t G 5 t ) ( F 6 t F 4 t ) ( G 9 t G 5 t ) . C t = 1 F 2 t G 3 t F 6 t G 9 t F 4 t G 5 t ( F 2 t G 3 t F 4 t G 5 t ) ( F 6 t G 9 t F 4 t G 5 t ) = 1 F 2 t G 3 t F 6 t G 9 t F 4 t G 5 t ( F 2 t F 4 t ) ( G 3 t G 5 t ) ( F 6 t F 4 t ) ( G 9 t G 5 t ) .
(4)

The Matlab function KFt carries out the operation Fd1FdKFd1FdK. The Matlab function Kcrot implements the operation Gp1e1GpKeKGp1e1GpKeK. They are both listed in the appendix.

### Common Functions

By recognizing that the convolution algorithms for different lengths share a lot of the same computations, it is possible to write a set of programs that take advantage of this. The programs we have generated call functions from a relatives small set. Each program calls these functions with different arguments, in differing orders, and a different number of times. By organizing the program structure in a modular way, we are able to generate relatively compact code for a wide variety of lengths.

In the appendix we have listed code for the following functions, from which we create circular convolution algorithms. In the next section we generate FFT programs using this same set of functions.

• Prime Factor Permutations: The Matlab function pfp implements this permutation of Prime Factor Permutations. Its transpose is implemented by pfpt .
• Reduction Operations: The Matlab function KRED implements the reduction operations of Reduction Operations. Its transpose is implemented by tKRED . Its inverse transpose is implemented by itKRED and this function is used only for computing the multiplicative constants.
• Linear Convolution Operations: ID2I and ID3I are Matlab functions for the operations ID2IID2I and ID3IID3I. These linear convolution operations are also described in the appendix Bilinear Forms for Linear Convolution.' ID2tI and ID3tI` implement the transposes, ID2tIID2tI and ID3tIID3tI.

### Operation Counts

Table 1 lists operation counts for some of the circular convolution algorithms we have generated. The operation counts do not include any arithmetic operations involved in the index variable or loops. They include only the arithmetic operations that involve the data sequence xx in the convolution of xx and hh.

The table in [2] for the split nesting algorithm gives very similar arithmetic operation counts. For all lengths not divisible by 9, the algorithms we have developed use the same number of multiplications and the same number or fewer additions. For lengths which are divisible by 9, the algorithms described in [2] require fewer additions than do ours. This is because the algorithms whose operation counts are tabulated in the table in [2] use a special Φ9(s)Φ9(s) convolution algorithm. It should be noted, however, that the efficient Φ9(s)Φ9(s) convolution algorithm of [2] is not constructed from smaller algorithms using the Kronecker product, as is ours. As we have discussed above, the use of the Kronecker product facilitates adaptation to special computer architectures and yields a very compact program with function calls to a small set of functions.

 N muls adds N muls adds N muls adds N muls adds 2 2 4 24 56 244 80 410 1546 240 1640 6508 3 4 11 27 94 485 84 320 1712 252 1520 7920 4 5 15 28 80 416 90 380 1858 270 1880 9074 5 10 31 30 80 386 105 640 2881 280 2240 9516 6 8 34 35 160 707 108 470 2546 315 3040 13383 7 16 71 36 95 493 112 656 2756 336 2624 11132 8 14 46 40 140 568 120 560 2444 360 2660 11392 9 19 82 42 128 718 126 608 3378 378 3008 16438 10 20 82 45 190 839 135 940 4267 420 3200 14704 12 20 92 48 164 656 140 800 3728 432 3854 16430 14 32 170 54 188 1078 144 779 3277 504 4256 19740 15 40 163 56 224 1052 168 896 4276 540 4700 21508 16 41 135 60 200 952 180 950 4466 560 6560 25412 18 38 200 63 304 1563 189 1504 7841 630 6080 28026 20 50 214 70 320 1554 210 1280 6182 720 7790 30374 21 64 317 72 266 1250 216 1316 6328 756 7520 38144

It is possible to make further improvements to the operation counts given in Table 1[1], [2]. Specifically, algorithms for prime power cyclotomic convolution based on the polynomial transform, although more complicated, will give improvements for the longer lengths listed [1], [2]. These improvements can be easily included in the code generating program we have developed.

## References

1. Nussbaumer, H. J. (1980, April). Fast Polynomial Transform Algorithms for Digital Convolution. IEEE Trans. Acoust., Speech, Signal Proc., 28(2), 205-215.
2. Nussbaumer, H. J. (1982). Fast Fourier Transform and Convolution Algorithms. Sringer-Verlag.

## Content actions

### Give feedback:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks