Skip to main content

Digital Signal Processing - Circular Convolution

Convolution<title> <meta name="description" content="Digital Signal Processing (Linear Circular Convolution Using Circular Method),basics of convolution"> <meta name="keywords" content="Digital Signal Processing, Linear Circular Convolution Using Circular Method,Convolution,DSP"> </h1> <div> <div class="separator" style="clear: both; text-align: center;"> </div> <div style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"> <a href="about:invalid#zClosurez" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="about:invalid#zClosurez" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a>Convolution is a mathematical way of combining two signals to form a third signal. It is the single most important technique in Digital Signal Processing.</div> <div class="separator" style="clear: both; text-align: center;"> </div> <div class="separator" style="clear: both; text-align: center;"> <a href="about:invalid#zClosurez" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div> <div class="separator" style="clear: both; text-align: center;"> <a href="about:invalid#zClosurez" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvShePHbdaSmJJaSrY07RNemf-dbDuf7qDD4ZPCnb2EzUFQMXhlNeUGbInGyZeW2as2Z1G2Qieu1378lMh_vzPaaCnujHKx_po7Zm0kIhkbpBckfFYn5zLJinVfAhVxzjGpnY6IGFein5K/s1600/convol.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="about:invalid#zClosurez" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="about:invalid#zClosurez" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><img border="0" data-original-height="225" data-original-width="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvShePHbdaSmJJaSrY07RNemf-dbDuf7qDD4ZPCnb2EzUFQMXhlNeUGbInGyZeW2as2Z1G2Qieu1378lMh_vzPaaCnujHKx_po7Zm0kIhkbpBckfFYn5zLJinVfAhVxzjGpnY6IGFein5K/s1600/convol.png" style="cursor: move;" /><br /> Using the strategy of impulse decomposition, systems are described by a signal called the impulse response. Convolution is important because it relates the three signals of interest: the input signal, the output signal, and the impulse response. This chapter presents convolution from two different viewpoints, called the input side algorithm and the output side algorithm.<br /> <div class="separator" style="clear: both; text-align: center;"> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <br /> <div class="separator" style="clear: both; text-align: center;"> <a href="about:invalid#zClosurez" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div> <div class="separator" style="clear: both; text-align: center;"> <a href="about:invalid#zClosurez" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div> </div> <h1 class="firstHeading" id="firstHeading" lang="en" style="background-image: none; border-bottom: 1px solid rgb(162, 169, 177); font-family: "linux libertine", georgia, times, serif; font-size: 1.8em; font-weight: normal; line-height: 1.3; margin: 0px 0px 0.25em; overflow: visible; padding: 0px; text-align: left;"> <title class="Circular Method">"Circular convolution

Image result for circular convolutionThe circular convolution, also known as cyclic convolution, of two aperiodic functions (i.e. Schwartz functions) occurs when one of them is convolved in the normal way with a periodic summation of the other function. That situation arises in the context of the Circular convolution theorem.  The identical operation can also be expressed in terms of the periodic summations of both functions, if the infinite integration interval is reduced to just one period.  That situation arises in the context of the discrete-time Fourier transform(DTFT) and is also called periodic convolution.  In particular, the DTFT of the product of two discrete sequences is the periodic convolution of the DTFTs of the individual sequences.[1]
Let x be a function with a well-defined periodic summation, xT, where:
If h is any other function for which the convolution xT ∗ h exists, then the convolution xT ∗ h is periodic and identical to:

A simple way to calculate these is by using this link-https://www.rapidtables.com/calc/math/convolution-calculator.html
In this example we are gonna understand basic circular convolution suppose we have two functions i.e xn and hn
To perform convolution we need to multiply those i.e xn*hn by shifting xn by (size of xn+size of hn -1) positions.

x(n)=[1,2,3,4]            h(n)=[-3,2,1]
Size of xn=4.           Size of hn=3
Matrix length=4+3-1=6

Circular Matrix of x(n) created by shifting each position of xn.

 [1, 2, 3, 4, 0, 0]
 [0, 1, 2, 3, 4, 0]
 [0, 0, 1, 2, 3, 4]
 [4, 0, 0, 1, 2, 3]
 [3, 4, 0, 0, 1, 2]
 [2, 3, 4, 0, 0, 1]

Matrix for hn=
[-3,
2
1,
0,
0,
0]
Now we multiply each of the xn.hn by matrix multiplication and we get yn.
y(n)=[-3 -4 -4 -4 11 4]


Code:-

Circular convolution code in python 3
"#python3 code for linear circular matrix made by Quid Zohar Morbiwala
from collections import deque
n1=int(input('Enter number of samples of x(n):'))      #input from user for number of elements of  x(n)
n2=int(input('Enter number of samples of h(n):'))      #input from user for number of elements of  h(n)
xn=[]
hn=[]
for i in range(n1):
x=int(input('Enter elements x(n):'))      #input from user for x(n) list
xn.append(x)                                     #append that input to x(n) list
for i in range(n2):
h=int(input('Enter elements h(n):'))      #input from user for h(n) liist
hn.append(h)                                     #append that input to h(n) list
pad=n1+n2-1
while len(xn)<pad:xn.append(0)      #adds 0 to make l#st equal for x(n)
while len(hn)<pad:hn.append(0)      #adds 0 to make list equal for h(n)
mul=[]
xn1 = deque(xn)                            #makes a circular queue of list
for i in range(len(xn)):
mul.append(list(xn1))
xn1.rotate(1)                        #shifts the elements by 1 for each iteration and appends it to list
print("Circular Matrix of x(n)\n",*mul,"\n*Matrix of h(n)\n",*hn,"\n\t=\n",sep='\n\t')
print("Matrix y(n):\n")
result=[]
for i in range(len(xn)):
result.append( list(mul[j][i]*hn[j] for j in range(len(hn)))) #multiplies Lists of mul and hn column wise
yn=[]
for i in range(len(xn)):
yn.append(sum(result[i]))                 #generates sum of list for y(n)
print(*yn,sep='\t\n')

Output:-

Enter number of samples of x(n):4
Enter number of samples of h(n):3
Enter elements x(n):1
Enter elements x(n):2
Enter elements x(n):3
Enter elements x(n):4
Enter elements h(n):1
Enter elements h(n):2
Enter elements h(n):3
Circular Matrix of x(n)

        [1, 2, 3, 4, 0, 0]
        [0, 1, 2, 3, 4, 0]
        [0, 0, 1, 2, 3, 4]
        [4, 0, 0, 1, 2, 3]
        [3, 4, 0, 0, 1, 2]
        [2, 3, 4, 0, 0, 1]

*Matrix of h(n)

        1
        2
        3
        0
        0
        0

        =

Matrix y(n):

1
4
10
16
17
12

Comments

Popular posts from this blog

Columnar Transposition Cipher

Columnar Transposition Cipher Introduction  The columnar transposition cipher is a fairly simple, easy to implement cipher. It is a transposition cipher that follows a simple rule for mixing up the characters in the plaintext to form the ciphertext. Although weak on its own, it can be combined with other ciphers, such as a substitution cipher, the combination of which can be more difficult to break than either cipher on it's own. The  ADFGVX cipher uses a columnar transposition to greatly improve its security. Example  The key for the columnar transposition cipher is a keyword e.g.  GERMAN . The row length that is used is the same as the length of the keyword. To encrypt a piece of text, e.g. defend the east wall of the castle we write it out in a special way in a number of rows (the keyword here is  GERMAN ): G E R M A N d e f e n d t h e e a s t w a l l o f t h e c a s t l e x x In the above example, the plaintext has been padded so that it neatly fits in a

UPD Attack in Python

UDP flood attack A UDP flood attack is a denial-of-service (DoS) attack using the User Datagram Protocol (UDP), a sessionless/connectionless computer networking protocol. Using UDP for denial-of-service attacks is not as straightforward as with the Transmission Control Protocol (TCP). However, a UDP flood attack can be initiated by sending a large number of UDP packets to random ports on a remote host. As a result, the distant host will: Check for the application listening at that port; See that no application listens at that port; Reply with an ICMP Destination Unreachable packet. Thus, for a large number of UDP packets, the victimized system will be forced into sending many ICMP packets, eventually leading it to be unreachable by other clients. The attacker(s) may also spoof the IP address of the UDP packets, ensuring that the excessive ICMP return packets do not reach them, and anonymizing their network location(s). Most operating systems mit

A Case Study On End-to-End Encryption Used In Whatsapp

A Case Study On End-to-End Encryption Used In Whatsapp 1.Introduction to End-to-End Encryption WhatsApp's end-to-end encryption is available when you and the people you message use the latest versions of the app. WhatsApp's end-to-end encryption ensures only you and the person you're communicating with can read what is sent, and nobody in between, not even WhatsApp. This is because your messages are secured with a lock, and only the recipient and you have the special key needed to unlock and read them. For added protection, every message you send has its own unique lock and key. WhatsApp, since its inception six years ago, has quickly grown into a global phenomenon, becoming one of the most popular mobile based communications applications in the world today. With a user base that eclipsed one billion in February, WhatsApp provides a service that potentially endangers the privacy of over 10% of the entire human population. In order to address these security concern