Skip to content

Commit 7c19ec6

Browse files
authored
small changes to convolutional theorem chapter and code to make things more reproduceable (#872)
1 parent 448a796 commit 7c19ec6

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using FFTW
2+
using LinearAlgebra
23
using DelimitedFiles
34

45
# using the convolutional theorem
@@ -8,11 +9,9 @@ end
89

910
function main()
1011

11-
# Random distribution in x
12-
x = rand(100)
13-
14-
# Gaussian signals
15-
y = [exp(-((i-50)/100)^2/.01) for i = 1:100]
12+
# sawtooth functions for x and y
13+
x = [float(i)/200 for i = 1:200]
14+
y = [float(i)/200 for i = 1:200]
1615

1716
# Normalization is not strictly necessary, but good practice
1817
normalize!(x)
@@ -22,6 +21,10 @@ function main()
2221
fft_output = convolve_fft(x, y)
2322

2423
# outputting convolutions to different files for plotting in external code
25-
writedlm("fft.dat", fft_output)
24+
# note: we are outputting just the real component because the imaginary
25+
# component is virtually 0
26+
writedlm("fft.dat", real(fft_output))
2627

2728
end
29+
30+
main()

contents/convolutions/convolutional_theorem/convolutional_theorem.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,20 @@ Also note that the Fourier Transform is a periodic or cyclic operation, so there
3939

4040
## Example Code
4141

42+
For this example code, we will be using two sawtooth functions as we did in the chapter on [one-dimensional convolutions](../1d/1d.md):
43+
4244
{% method %}
4345
{% sample lang="jl" %}
4446
[import, lang:"julia"](code/julia/convolutional_theorem.jl)
4547
{% endmethod %}
4648

49+
This should produce the following output:
50+
51+
<p>
52+
<img class="center" src="../res/cyclic.png" style="width:75%">
53+
</p>
54+
55+
4756
<script>
4857
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
4958
</script>
@@ -54,6 +63,11 @@ MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
5463

5564
The code examples are licensed under the MIT license (found in [LICENSE.md](https://github.com/algorithm-archivists/algorithm-archive/blob/master/LICENSE.md)).
5665

66+
##### Images/Graphics
67+
68+
- The image "[Cyclic](../res/cyclic.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
69+
70+
5771
##### Text
5872

5973
The text of this chapter was written by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).

0 commit comments

Comments
 (0)