Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from scipy.fft import fft, ifft
import numpy as np

# using the convolutional theorem
def convolve_fft(signal1, signal2):
return ifft(np.multiply(fft(signal1),fft(signal2)))

# Sawtooth functions
x = [float(i)/200 for i in range(1,101)]
y = [float(i)/200 for i in range(1,101)]

x /= np.linalg.norm(x)
y /= np.linalg.norm(y)

# Convolving the two signals
fft_output = convolve_fft(x, y)

np.savetxt("fft.dat", np.real(fft_output))

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ For this example code, we will be using two sawtooth functions as we did in the
{% method %}
{% sample lang="jl" %}
[import, lang:"julia"](code/julia/convolutional_theorem.jl)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[import, lang:"julia"](code/julia/convolutional_theorem.jl)
[import, lang:"julia"](code/julia/convolutional_theorem.jl)
{% sample lang="py" %}
[import, lang:"python"](code/python/convolutional_theorem.py)

{% sample lang="py" %}
[import, lang:"python"](code/python/convolutional_theorem.py)
{% endmethod %}

This should produce the following output:
Expand All @@ -52,7 +54,6 @@ This should produce the following output:
<img class="center" src="../res/cyclic.png" style="width:75%">
</p>


<script>
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
</script>
Expand Down