@@ -56,6 +56,8 @@ With this in mind, we can almost directly transcribe the discrete equation into
5656[ import:27-46, lang:"julia"] ( code/julia/1d_convolution.jl )
5757{% sample lang="cs" %}
5858[ import:63-84, lang:"csharp"] ( code/csharp/1DConvolution.cs )
59+ {% sample lang="py" %}
60+ [ import:18-27, lang:"python"] ( code/python/1d_convolution.py )
5961{% endmethod %}
6062
6163The easiest way to reason about this code is to read it as you might read a textbook.
@@ -189,6 +191,8 @@ Here it is again for clarity:
189191[ import:27-46, lang:"julia"] ( code/julia/1d_convolution.jl )
190192{% sample lang="cs" %}
191193[ import:63-84, lang:"csharp"] ( code/csharp/1DConvolution.cs )
194+ {% sample lang="py" %}
195+ [ import:18-27, lang:"python"] ( code/python/1d_convolution.py )
192196{% endmethod %}
193197
194198Here, the main difference between the bounded and unbounded versions is that the output array size is smaller in the bounded case.
@@ -199,6 +203,8 @@ For an unbounded convolution, the function would be called with a the output arr
199203[ import:58-59, lang:"julia"] ( code/julia/1d_convolution.jl )
200204{% sample lang="cs" %}
201205[ import:96-97, lang:"csharp"] ( code/csharp/1DConvolution.cs )
206+ {% sample lang="py" %}
207+ [ import:37-38, lang:"python"] ( code/python/1d_convolution.py )
202208{% endmethod %}
203209
204210On the other hand, the bounded call would set the output array size to simply be the length of the signal
@@ -208,6 +214,8 @@ On the other hand, the bounded call would set the output array size to simply be
208214[ import:61-62, lang:"julia"] ( code/julia/1d_convolution.jl )
209215{% sample lang="cs" %}
210216[ import:98-99, lang:"csharp"] ( code/csharp/1DConvolution.cs )
217+ {% sample lang="py" %}
218+ [ import:40-41, lang:"python"] ( code/python/1d_convolution.py )
211219{% endmethod %}
212220
213221Finally, as we mentioned before, it is possible to center bounded convolutions by changing the location where we calculate the each point along the filter.
@@ -218,6 +226,8 @@ This can be done by modifying the following line:
218226[ import:35-35, lang:"julia"] ( code/julia/1d_convolution.jl )
219227{% sample lang="cs" %}
220228[ import:71-71, lang:"csharp"] ( code/csharp/1DConvolution.cs )
229+ {% sample lang="py" %}
230+ [ import:22-22, lang:"python"] ( code/python/1d_convolution.py )
221231{% endmethod %}
222232
223233Here, ` j ` counts from ` i-length(filter) ` to ` i ` .
@@ -252,6 +262,8 @@ In code, this typically amounts to using some form of modulus operation, as show
252262[ import:4-25, lang:"julia"] ( code/julia/1d_convolution.jl )
253263{% sample lang="cs" %}
254264[ import:38-61, lang:"csharp"] ( code/csharp/1DConvolution.cs )
265+ {% sample lang="py" %}
266+ [ import:5-15, lang:"python"] ( code/python/1d_convolution.py )
255267{% endmethod %}
256268
257269This is essentially the same as before, except for the modulus operations, which allow us to work on a periodic domain.
@@ -269,6 +281,8 @@ For the code associated with this chapter, we have used the convolution to gener
269281[ import, lang:"julia"] ( code/julia/1d_convolution.jl )
270282{% sample lang="cs" %}
271283[ import, lang:"csharp"] ( code/csharp/1DConvolution.cs )
284+ {% sample lang="py" %}
285+ [ import, lang:"python"] ( code/python/1d_convolution.py )
272286{% endmethod %}
273287
274288At a test case, we have chosen to use two sawtooth functions, which should produce the following images:
0 commit comments