<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Animation on Lloyd Rochester's Geek Blog</title><link>https://lloydroc.github.io/tags/animation/</link><description>Recent content in Animation on Lloyd Rochester's Geek Blog</description><generator>Hugo</generator><language>en</language><copyright>Copyright © 2025, Lloyd Rochester.</copyright><lastBuildDate>Tue, 21 Apr 2020 00:00:00 +0000</lastBuildDate><atom:link href="https://lloydroc.github.io/tags/animation/index.xml" rel="self" type="application/rss+xml"/><item><title>Simple Convolution in C</title><link>https://lloydroc.github.io/post/c/convolution/</link><pubDate>Wed, 17 Oct 2018 06:10:00 +0000</pubDate><guid>https://lloydroc.github.io/post/c/convolution/</guid><description>&lt;h1 id="hahahugoshortcode15s0hbhb">Simple Convolution in C&lt;/h1>
&lt;p>Updated April 21, 2020&lt;/p>
&lt;p>In this blog post we&amp;rsquo;ll create a simple 1D convolution in C. We&amp;rsquo;ll show the classic example of convolving two squares to create a triangle. When convolution is performed it&amp;rsquo;s usually between two discrete signals, or time series. In this example we&amp;rsquo;ll use C arrays to represent each signal.&lt;/p>
&lt;p>When implementing convolution it&amp;rsquo;s important to know the length of convolution result, since the resulting array is bigger than the two input arrays. This can cause memory problems. Computing the length of the convolution result is actually a simple computation. If you have array &lt;strong>H&lt;/strong> convolved with array &lt;strong>X&lt;/strong>, where the lengths are 5 and 5 respectively, the resulting size of &lt;strong>Y=H*X&lt;/strong> (&lt;strong>H&lt;/strong> convolved with &lt;strong>X&lt;/strong> to make &lt;strong>Y&lt;/strong>) will be &lt;strong>Length(H) + Length(X) - 1&lt;/strong>. For this example the resulting length of two size 5 arrays will be 5+5-1 = 9. This convolution is typically done where &lt;strong>H&lt;/strong> is a digital filter and &lt;strong>X&lt;/strong> is a time series to be filtered. The output array &lt;strong>Y&lt;/strong> is the time series that results after filtering. For our example we have input arrays &lt;strong>H&lt;/strong> and &lt;strong>X&lt;/strong>. The output of array of our convolution will be called &lt;strong>Y&lt;/strong>.&lt;/p></description></item></channel></rss>