<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://kilinco.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kilinco.github.io/" rel="alternate" type="text/html" /><updated>2025-06-27T08:54:55+00:00</updated><id>https://kilinco.github.io/feed.xml</id><title type="html">osman cihan kilinc</title><subtitle>Building the backbone of autonomy.</subtitle><entry><title type="html">Summed Area Table</title><link href="https://kilinco.github.io/summed-area-table/" rel="alternate" type="text/html" title="Summed Area Table" /><published>2021-09-13T00:00:00+00:00</published><updated>2021-09-13T00:00:00+00:00</updated><id>https://kilinco.github.io/summed-area-table</id><content type="html" xml:base="https://kilinco.github.io/summed-area-table/"><![CDATA[<p>Suppose you have a very large matrix <em>A</em> and you would like to calculate the sum of a submatrix that resides within <em>A</em>. How would you do that?</p>

<p>It would be relatively straightforward, if you had do it just once. You would sum up all the elements in that submatrix which would be of <em>O(m*n)</em> time complexity, where m is the number of rows and n is the number of columns in the submatrix. The question becomes a bit more complex if you have to query the sum of different submatrices multiple times. Unsurprisingly, such use-cases do come up in Computer Vision and Computer Graphics, and <em>O(m*n)</em> time complexity can get incredibly disturbing for repetitive calls. <!--more--></p>

<p>Perhaps on such a disturbed day in 1984, Frank Painter rose to the challenge and wondered if he could somehow preprocess matrix <em>A</em> so that it would take constant time to retrieve the sum of any submatrix. The answer was yes. Not only the sum, but you can preprocess your matrix to efficiently retrieve any other statistics such as mean or standard deviation for its submatrices. When I first came across this problem, I got completely befuddled and my first thought was to calculate all of the sums for all the submatrices and store it by some index. Needless to say that would have been an astonishingly inefficient solution and Frank did not go that way. Now let’s follow Frank’s footsteps and ponder together…</p>

<p>In order to query the sum of a submatrix, we first need to define it. The submatrix can be defined by 4 arguments. Let’s call them <em>x_low</em>, <em>x_high</em>, <em>y_low</em> and <em>y_high</em>. If we were to draw a straight line for each of them, the submatrix would be the rectangular area constrained by these 4 lines. The number of elements in this submatrix would be <em>(x_high - x_low + 1)</em> * <em>(y_high - y_low + 1)</em> and we need to return the sum of all elements. It is clear that we have to scan the matrix, make some computations and then store the results to decrease time complexity. What if we calculate and store the submatrix sums for all submatrices defined by <em>(0,0)</em> and <em>(x,y)</em>? Compared to storing the results for each and every possible submatrix, this would be much more efficient. Let’s see if this would work.</p>

<p>Suppose that we can only query this interface for <em>(x,y)</em> which then would return the sum of the submatrix defined by <em>(0,0)</em> and <em>(x,y)</em>. How can we use this method to calculate the submatrix defined by <em>(x_low,y_low)</em> and <em>(x_high,y_high)</em>? The answer becomes apparent when you draw and visualize the problem…</p>

<p><img src="https://raw.githubusercontent.com/kilinco/kilinco.github.io/master/_data/summed-area-table-1.gif" alt="Summed Area Table" /></p>

<figure class="highlight"><pre><code class="language-cpp" data-lang="cpp"><span class="c1">// returns the sum of all elements in submatrix defined by x_low = 0, y_low = 0, x_high = x &amp; y_high = y</span>
<span class="kt">int</span> <span class="nf">sum_submatrix</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">);</span> 

<span class="kt">int</span> <span class="nf">sum_submatrix</span><span class="p">(</span><span class="kt">int</span> <span class="n">x_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x_high</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_high</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">return</span> <span class="n">sum_submatrix</span><span class="p">(</span><span class="n">x_high</span><span class="p">,</span> <span class="n">y_high</span><span class="p">)</span> <span class="o">-</span> <span class="n">sum_submatrix</span><span class="p">(</span><span class="n">x_high</span><span class="p">,</span> <span class="n">y_low</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">-</span> <span class="n">sum_submatrix</span><span class="p">(</span><span class="n">x_low</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">y_high</span><span class="p">)</span> <span class="o">+</span> <span class="n">sum_submatrix</span><span class="p">(</span><span class="n">x_low</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">y_low</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span> 
<span class="p">}</span></code></pre></figure>

<p>Now let’s move on to calculating the submatrix sum for submatrices defined by <em>(0,0)</em> and <em>(x,y)</em>. It is best to simplify the problem and visualize the solution with a 1D array. Suppose that the 1D array below is the first row of <em>A</em> and that we need to calculate all the submatrix sums from <em>(0,0)</em> to <em>(0,4)</em>.</p>

<figure class="highlight"><pre><code class="language-text" data-lang="text">[1,5,1,6,8] ---&gt; [1,6,7,13,21]</code></pre></figure>

<p>Notice the pattern in the 1D case? It all comes down to calculating the submatrix sum cumulatively. We can generalize this solution to the 2D case as below. Note that we subtract <code class="language-plaintext highlighter-rouge">dp[i-1][j-1]</code> to prevent it to be counted twice (which is easy to figure when you visualize your solution).</p>

<figure class="highlight"><pre><code class="language-cpp" data-lang="cpp"><span class="k">class</span> <span class="nc">SummedAreaTable</span> <span class="p">{</span>
  <span class="nl">public:</span>
    <span class="n">SummedAreaTable</span><span class="p">(</span><span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;&gt;</span> <span class="o">&amp;</span> <span class="n">A</span><span class="p">)</span> <span class="p">{</span>
        <span class="kt">int</span> <span class="n">M</span> <span class="o">=</span> <span class="n">A</span><span class="p">.</span><span class="n">size</span><span class="p">(),</span> <span class="n">N</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="n">size</span><span class="p">();</span>
        <span class="n">dp</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;&gt;</span> <span class="p">(</span><span class="n">M</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class="p">(</span><span class="n">N</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">));</span>
        <span class="k">for</span><span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;=</span> <span class="n">M</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span>
            <span class="k">for</span><span class="p">(</span><span class="kt">int</span> <span class="n">j</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">j</span> <span class="o">&lt;=</span> <span class="n">N</span><span class="p">;</span> <span class="o">++</span><span class="n">j</span><span class="p">)</span>
                <span class="n">dp</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">dp</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">+</span> <span class="n">dp</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">dp</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="n">j</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="n">j</span><span class="o">-</span><span class="mi">1</span><span class="p">];</span>
    <span class="p">}</span>
    
    <span class="kt">int</span> <span class="n">get_submatrix_sum</span><span class="p">(</span><span class="kt">int</span> <span class="n">x_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x_high</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_high</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
  <span class="nl">private:</span>
    <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;&gt;</span> <span class="n">dp</span><span class="p">;</span>
<span class="p">}</span></code></pre></figure>

<p>Now let’s rewrite <code class="language-plaintext highlighter-rouge">sum_submatrix</code> using <code class="language-plaintext highlighter-rouge">dp</code>. This way we can retrieve the sum of all elements in the submatrix in constant time.</p>

<figure class="highlight"><pre><code class="language-cpp" data-lang="cpp"><span class="kt">int</span> <span class="n">SummedAreaTable</span><span class="o">::</span><span class="n">get_submatrix_sum</span><span class="p">(</span><span class="kt">int</span> <span class="n">x_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x_high</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_high</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span>
    <span class="k">return</span> <span class="n">dp</span><span class="p">[</span><span class="n">x_high</span><span class="o">+</span><span class="mi">1</span><span class="p">][</span><span class="n">y_high</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">dp</span><span class="p">[</span><span class="n">x_high</span><span class="o">+</span><span class="mi">1</span><span class="p">][</span><span class="n">y_low</span><span class="p">]</span> <span class="o">-</span> <span class="n">dp</span><span class="p">[</span><span class="n">x_low</span><span class="p">][</span><span class="n">y_high</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">dp</span><span class="p">[</span><span class="n">x_low</span><span class="p">][</span><span class="n">y_low</span><span class="p">];</span>
<span class="p">}</span></code></pre></figure>

<p>Remember that this algorithm can also be used to retrieve stastics like mean and standard deviations. When you have the sum for the submatrix, it is straightforward to retrieve the mean. You only need to calculate the number of elements in the submatrix.</p>

<figure class="highlight"><pre><code class="language-cpp" data-lang="cpp"><span class="k">class</span> <span class="nc">SummedAreaTable</span> <span class="p">{</span>
  <span class="nl">public:</span>
    <span class="n">SummedAreaTable</span><span class="p">(</span><span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;&gt;</span> <span class="o">&amp;</span> <span class="n">A</span><span class="p">)</span> <span class="p">{</span>
        <span class="kt">int</span> <span class="n">M</span> <span class="o">=</span> <span class="n">A</span><span class="p">.</span><span class="n">size</span><span class="p">(),</span> <span class="n">N</span> <span class="o">=</span> <span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="n">size</span><span class="p">();</span>
        <span class="n">dp</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;&gt;</span> <span class="p">(</span><span class="n">M</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class="p">(</span><span class="n">N</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">));</span>
        <span class="k">for</span><span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;=</span> <span class="n">M</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span>
            <span class="k">for</span><span class="p">(</span><span class="kt">int</span> <span class="n">j</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">j</span> <span class="o">&lt;=</span> <span class="n">N</span><span class="p">;</span> <span class="o">++</span><span class="n">j</span><span class="p">)</span>
                <span class="n">dp</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">dp</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">+</span> <span class="n">dp</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">dp</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="n">j</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="n">j</span><span class="o">-</span><span class="mi">1</span><span class="p">];</span>
    <span class="p">}</span>
    
    <span class="kt">int</span> <span class="n">get_submatrix_sum</span><span class="p">(</span><span class="kt">int</span> <span class="n">x_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x_high</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_high</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">get_num_elements</span><span class="p">(</span><span class="kt">int</span> <span class="n">x_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x_high</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_high</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
    <span class="kt">double</span> <span class="n">get_submatrix_mean</span><span class="p">(</span><span class="kt">int</span> <span class="n">x_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x_high</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_high</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span>
  <span class="nl">private:</span>
    <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;&gt;</span> <span class="n">dp</span><span class="p">;</span>
<span class="p">}</span>

<span class="kt">int</span> <span class="n">SummedAreaTable</span><span class="o">::</span><span class="n">get_submatrix_sum</span><span class="p">(</span><span class="kt">int</span> <span class="n">x_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x_high</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_high</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span>
    <span class="k">return</span> <span class="n">dp</span><span class="p">[</span><span class="n">x_high</span><span class="o">+</span><span class="mi">1</span><span class="p">][</span><span class="n">y_high</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">dp</span><span class="p">[</span><span class="n">x_high</span><span class="o">+</span><span class="mi">1</span><span class="p">][</span><span class="n">y_low</span><span class="p">]</span> <span class="o">-</span> <span class="n">dp</span><span class="p">[</span><span class="n">x_low</span><span class="p">][</span><span class="n">y_high</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">dp</span><span class="p">[</span><span class="n">x_low</span><span class="p">][</span><span class="n">y_low</span><span class="p">];</span>
<span class="p">}</span>

<span class="kt">int</span> <span class="n">SummedAreaTable</span><span class="o">::</span><span class="n">get_num_elements</span><span class="p">(</span><span class="kt">int</span> <span class="n">x_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x_high</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_high</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">x_high</span> <span class="o">-</span> <span class="n">x_low</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="n">y_high</span> <span class="o">-</span> <span class="n">y_low</span> <span class="o">+</span> <span class="mi">1</span><span class="p">);</span>
<span class="p">}</span>
    
<span class="kt">double</span> <span class="n">SummedAreaTable</span><span class="o">::</span><span class="n">get_submatrix_mean</span><span class="p">(</span><span class="kt">int</span> <span class="n">x_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_low</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x_high</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y_high</span><span class="p">)</span> <span class="k">const</span> <span class="p">{</span>
    <span class="k">return</span> <span class="n">std</span><span class="o">::</span><span class="k">static_cast</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;</span><span class="p">(</span><span class="n">get_submatrix_sum</span><span class="p">(</span><span class="n">x_low</span><span class="p">,</span> <span class="n">y_low</span><span class="p">,</span> <span class="n">x_high</span><span class="p">,</span> <span class="n">y_high</span><span class="p">))</span> <span class="o">/</span> <span class="n">get_num_elements</span><span class="p">(</span><span class="n">x_low</span><span class="p">,</span> <span class="n">y_low</span><span class="p">,</span> <span class="n">x_high</span><span class="p">,</span> <span class="n">y_high</span><span class="p">);</span>
<span class="p">}</span></code></pre></figure>

<p>Lastly, you can find the much better illustrated solution <a href="https://nayan.co/blog/AI/Integral-Image/">here</a>.</p>

<p>Next, I will look into its more advanced use-cases.</p>]]></content><author><name></name></author><category term="blog" /><category term="algorithms" /><category term="matrix sum query" /><category term="technical questions" /><summary type="html"><![CDATA[Suppose you have a very large matrix A and you would like to calculate the sum of a submatrix that resides within A. How would you do that? It would be relatively straightforward, if you had do it just once. You would sum up all the elements in that submatrix which would be of O(m*n) time complexity, where m is the number of rows and n is the number of columns in the submatrix. The question becomes a bit more complex if you have to query the sum of different submatrices multiple times. Unsurprisingly, such use-cases do come up in Computer Vision and Computer Graphics, and O(m*n) time complexity can get incredibly disturbing for repetitive calls.]]></summary></entry><entry><title type="html">C++ Conferences - Optimization</title><link href="https://kilinco.github.io/cpp-conferences-on-optimization/" rel="alternate" type="text/html" title="C++ Conferences - Optimization" /><published>2021-05-18T00:00:00+00:00</published><updated>2021-05-18T00:00:00+00:00</updated><id>https://kilinco.github.io/cpp-conferences-on-optimization</id><content type="html" xml:base="https://kilinco.github.io/cpp-conferences-on-optimization/"><![CDATA[<p>In this age of abundance, who really cares about optimization? It turns out some people do. They even presented on several different conferences. 
Interested? <a href="https://www.youtube.com/playlist?list=PLj_YJdJ3zwup-HpcNwqzf18bgGNlhd3kt">Follow the white rabbit.</a></p>

<p>I will probably extend this blog post with a summary from all these videos. I am currently on video 9, so that will take a long time.</p>]]></content><author><name></name></author><category term="blog" /><category term="C++ Optimization" /><category term="watch list" /><summary type="html"><![CDATA[In this age of abundance, who really cares about optimization? It turns out some people do. They even presented on several different conferences. Interested? Follow the white rabbit.]]></summary></entry><entry><title type="html">C++ Essential Reading List</title><link href="https://kilinco.github.io/cpp-essential-reads/" rel="alternate" type="text/html" title="C++ Essential Reading List" /><published>2021-05-14T00:00:00+00:00</published><updated>2021-05-14T00:00:00+00:00</updated><id>https://kilinco.github.io/cpp-essential-reads</id><content type="html" xml:base="https://kilinco.github.io/cpp-essential-reads/"><![CDATA[<p>My first experience with C++ was around highschool, when I got a book to see if I could learn how to program on my own. I either downloaded Dev-C++ or the book came with a CD. I don’t remember.
Unfortunately, I couldn’t make much progress as I couldn’t figure out how to stop the console application from exiting immediately. I had some programming experience before with Visual Basic 6.0, but I didn’t have anyone to show me the way for C++. At the time Youtube was fresh and wasn’t as lively as it is now. Internet was dead-slow.. I gave up, picked up a bass guitar and joined a band. That was my first C++ book, it had not helped me much. <!--more--></p>

<p>It was in freshmen college (2011), where I really had to learn C++ via a required class. It wasn’t through books. I learnt C++ by trial &amp; error. Endless hours in front of the computer. Sweat &amp; tears. It was a gradual process. I wasn’t just learning C++, but I was learning how to program. Everything, from scratch! Classes, labs, assignments &amp; on paper midterm/final… Nowadays it seems like most schools actually teach Java or Python for programming. I was lucky. I got to use C++ throughout college and later at work.</p>

<p>It’s been about 10 years since I have started learning C++. I never got to learn Modern C++, as I never had to use it. I still exclusively use classic C++. That will probably change as more people/companies adopt Modern C++. Until this year (2021), I had never actually read any language-specific guidelines. All my C++ knowledge was based on my practical experience.</p>

<p>Books can be helpful, but I am not sure how much one can gather from them. You can’t learn a human language just from the books. It won’t workout (if you are not some sort of a savant). It doesn’t happen overnight either. Anyhow I want to give it a try - read a few books and maybe pick something along the path. I first read C++ Coding Standards for some reason, but it seems like ‘A Tour of C++’ would have been a better first book.</p>

<p>Here is my reading list:</p>

<ol>
  <li>A Tour of C++ (Second Edition)</li>
  <li>C++ Coding Standards</li>
  <li>Effective C++ (Third Edition)</li>
  <li>Effective Modern C++</li>
  <li>Large Scale C++ : Process &amp; Architecture (Volume I)</li>
</ol>]]></content><author><name></name></author><category term="blog" /><category term="C++" /><category term="reading list" /><summary type="html"><![CDATA[My first experience with C++ was around highschool, when I got a book to see if I could learn how to program on my own. I either downloaded Dev-C++ or the book came with a CD. I don’t remember. Unfortunately, I couldn’t make much progress as I couldn’t figure out how to stop the console application from exiting immediately. I had some programming experience before with Visual Basic 6.0, but I didn’t have anyone to show me the way for C++. At the time Youtube was fresh and wasn’t as lively as it is now. Internet was dead-slow.. I gave up, picked up a bass guitar and joined a band. That was my first C++ book, it had not helped me much.]]></summary></entry><entry><title type="html">Books and Films</title><link href="https://kilinco.github.io/books-and-movies/" rel="alternate" type="text/html" title="Books and Films" /><published>2021-04-21T00:00:00+00:00</published><updated>2021-04-21T00:00:00+00:00</updated><id>https://kilinco.github.io/books-and-movies</id><content type="html" xml:base="https://kilinco.github.io/books-and-movies/"><![CDATA[<p>Books and films are an indispensable part of my life. I had long wanted to keep track of the films I watch and the books that I read as they can be a window to the past, and perhaps the future. I decided to share what I read/watch with the world. I am not entirely sure what my motive is. Perhaps someone will see the book list and reach out. Maybe I will respond to them. Maybe it will help drive some insightful discussions. Maybe it’s the geek in me. Maybe I’m following <a href="https://www.gatesnotes.com/Books">Bill Gates’ footsteps</a>. Maybe I am trying to promote the books/films that I like. Who knows?! <!--more--></p>

<p>For books, I usually delve into one topic and read everything I can find on that topic. I first make a list of books in the topic that I’d like to learn more about and batch order them. For films, I usually watch a whole series of films from one director/genre/country/era. I have accounts on both <a href="https://mubi.com/">Mubi</a> &amp; <a href="https://www.criterionchannel.com/">Criterion Channel</a>. I’d highly recommend both if you like films. I read/watch to pass/enjoy time and maybe pick up something along the path. I don’t take notes unless I really have/want to learn something.</p>

<p>I wanted to keep my reading/watch list on this website, but that’s just unnecessary since I already have <a href="https://www.imdb.com/user/ur22343877">IMDb</a> and <a href="https://www.goodreads.com/user/show/122558299-osman-cihan-kilinc">Goodreads</a> accounts.</p>]]></content><author><name></name></author><category term="blog" /><category term="lists" /><category term="reading list" /><category term="book list" /><category term="films" /><category term="movie list" /><summary type="html"><![CDATA[Books and films are an indispensable part of my life. I had long wanted to keep track of the films I watch and the books that I read as they can be a window to the past, and perhaps the future. I decided to share what I read/watch with the world. I am not entirely sure what my motive is. Perhaps someone will see the book list and reach out. Maybe I will respond to them. Maybe it will help drive some insightful discussions. Maybe it’s the geek in me. Maybe I’m following Bill Gates’ footsteps. Maybe I am trying to promote the books/films that I like. Who knows?!]]></summary></entry><entry><title type="html">The Gospel of Technical Interviews</title><link href="https://kilinco.github.io/gospel-of-technical-interviews/" rel="alternate" type="text/html" title="The Gospel of Technical Interviews" /><published>2019-07-31T00:00:00+00:00</published><updated>2019-07-31T00:00:00+00:00</updated><id>https://kilinco.github.io/gospel-of-technical-interviews</id><content type="html" xml:base="https://kilinco.github.io/gospel-of-technical-interviews/"><![CDATA[<p>For the last one and a half months, I have been waiting for my OPT to arrive so that I can start working. I am really looking forward to it, but there have been considerable delays in OPT processing times. I am not used to not doing anything, and I quickly get bored. I do not have the funds to go on a vacation nor do I have a car so I can’t travel much. There aren’t that many people around either. It sucks that when you are 27, almost everyone around you seems to have a job. I have been a regular at all coffee shops that were close to my place and watched the Office from the start to the end. I am trying to avoid watching it all over again. <!--more--></p>

<p>Because of my restrictive funds, I can’t buy the parts I need for my projects. Unfortunately, my GPU isn’t that good either. Sadly, machines learn very slowly without powerful GPUs. This leaves me with a few options. I can learn a new programming language to pass time or I can work on some toy projects. I even bought a freaking domain name <a href="http://www.raining.gold">raining.gold</a>, which is “under construction” right now. Inspired by Stanley from the Office, I have decided to spend some of my time solving the crosswords specifically designed for software engineers. These crosswords can be found at <a href="https://leetcode.com/">Leetcode</a> and <a href="https://www.hackerrank.com/">Hackerrank</a>. In other words, I decided to solve technical interview questions to pass time. I will be writing about my solutions as I want to make it a little more social - talking to yourself is a bit weird when you are at a coffee shop.</p>]]></content><author><name></name></author><category term="blog" /><category term="democratizing machine learning" /><category term="democratization of machine learning" /><category term="decentralized machine learning" /><category term="peer-to-peer learning" /><summary type="html"><![CDATA[For the last one and a half months, I have been waiting for my OPT to arrive so that I can start working. I am really looking forward to it, but there have been considerable delays in OPT processing times. I am not used to not doing anything, and I quickly get bored. I do not have the funds to go on a vacation nor do I have a car so I can’t travel much. There aren’t that many people around either. It sucks that when you are 27, almost everyone around you seems to have a job. I have been a regular at all coffee shops that were close to my place and watched the Office from the start to the end. I am trying to avoid watching it all over again.]]></summary></entry><entry><title type="html">Democratizing Machine Learning - Data</title><link href="https://kilinco.github.io/democratizing-machine-learning-data/" rel="alternate" type="text/html" title="Democratizing Machine Learning - Data" /><published>2019-07-30T00:00:00+00:00</published><updated>2019-07-30T00:00:00+00:00</updated><id>https://kilinco.github.io/democratizing-machine-learning-data</id><content type="html" xml:base="https://kilinco.github.io/democratizing-machine-learning-data/"><![CDATA[<p>Industrial revolution was driven by the standardization of parts, tools and interfaces. In the context of machine learning, democratization is only possible through the standardization of machine intelligence. As I established in <a href="https://kilinco.github.io/democratizing-machine-learning-tools-and-frameworks/">my previous post</a>, empowering people to build their own models is as equally important as providing them ready-to-use tools. <!--more-->Tools and frameworks make machine learning more widespread. The open source frameworks lower the barrier for the software developers to adopt it; they can create models and play around with ideas. However, they do not completely address the problems of the “common people”. Big tech companies still hold the upper hand over data. Therefore, even with the right tools “common people” would not be able to produce intelligent systems. In the absence of data, machines can not learn. The model would just be as dormant as your brain after multiple tequila shots at 2 am on a Saturday night. In order to make models more intelligent, vast amounts of data are pooled into data centers from the devices of the “common people.” Most people are quite unaware of this data collection. Access to data is limited, and gathered at the hands of the few.</p>

<p>Data is produced by an event; either by an action or inaction. Devices like mobile phones produce data through user interactions over a period of time. For example, a hidden application may collect the news headlines that you are more likely to click on (it probably does). This information can be used to provide you a better “service” and recommend the news that you are more likely to be interested in. It is this “intelligence” and control over what you see that make these companies very powerful. Despite the growing public concern on data privacy, companies will continue to find innovative methods to gather intelligence. This is literally how companies like Google and Facebook make money. For them, it is an existential matter. Personally, I do not want to go back to a time where Google does not exist. I love free web search! To be honest, I am not sure if I could survive without it. It would have definitely been harder to write code. I also would rather have an independent company to provide me that service instead of the government. I mean have you read 1984?!</p>

<p>On the one hand, I am glad that the governments around the world are cracking down on bad data collection practices. On the other hand, I believe good data collection practices should be encouraged and government agencies should strive to make their datasets publicly available. Fortunately, the number of <a href="https://www.whitehouse.gov/ai/">AI initiatives</a> are growing. Public initiatives such as <a href="https://theodi.org/article/what-is-a-data-trust/">data trusts</a> provide a platform for small and non-profit companies to be a part of the game. Given that most researchers end up working at the big tech companies, improving publicly available datasets is as equally important as funding public research in artificial intelligence. Long story short, improving publicly available data trusts can relieve the situation a bit, and all we need is competition (and love).</p>

<p>Accessing privacy-invasive data is another issue. AI is expected to be very useful in healthcare, especially. There are already a growing number of companies that are building wonderful applications for this reason. However, healthcare data is incredibly privacy invasive and access to data is very restrictive. We must find a way to realize the potential of AI, as it can be the “cure” to many of our problems. Instead of restricting access to privacy-sensitive data, we must strive to make them more publicly available without breaching privacy. So.. How can we train our models without sharing private information? How can we ensure anonymity?</p>

<p>The answer is to share intelligence rather than data. Machine learning methods like “federated learning” cultivate the shared intelligence to build powerful models in a “centralized manner”. (Unsurprisingly, research is supported by Google. Thanks, Google!) Do you like the idea? Good, then note this textbook definition down -</p>
<blockquote>
  <p>“Federated learning is a distributed machine learning approach that enables training on decentralized data.“</p>
</blockquote>

<p>Another approach to this problem is “decentralized learning”, which is a direct descendant of anarcho-syndicalism. Fully-decentralized learning enables learning on decentralized data without a central entity that coordinates learning. In other words, it makes peer-to-peer learning possible. Therefore, improvements to this approach will provide the underlying framework to open-source intelligence.</p>]]></content><author><name></name></author><category term="blog" /><category term="democratizing machine learning" /><category term="democratization of machine learning" /><category term="decentralized machine learning" /><category term="peer-to-peer learning" /><summary type="html"><![CDATA[Industrial revolution was driven by the standardization of parts, tools and interfaces. In the context of machine learning, democratization is only possible through the standardization of machine intelligence. As I established in my previous post, empowering people to build their own models is as equally important as providing them ready-to-use tools.]]></summary></entry><entry><title type="html">Democratizing Machine Learning - Tools and Frameworks</title><link href="https://kilinco.github.io/democratizing-machine-learning-tools-and-frameworks/" rel="alternate" type="text/html" title="Democratizing Machine Learning - Tools and Frameworks" /><published>2019-07-29T00:00:00+00:00</published><updated>2019-07-29T00:00:00+00:00</updated><id>https://kilinco.github.io/democratizing-machine-learning-tools-and-frameworks</id><content type="html" xml:base="https://kilinco.github.io/democratizing-machine-learning-tools-and-frameworks/"><![CDATA[<p>It should be clear that this blog post is about democratizing machine intelligence. Ok, this might be a little late compared to all the blog posts that came before it. One thing I can assure you that this is not a blog post that preaches cryptocurrency or blockchain technology.<!--more--> This is also probably not the most scientific article. This is simply my take on the topic - which will probably change in time. I am planning to break it up into several posts, because the topic can be explored from many different perspectives.</p>

<p>Let’s start with the etymology of democracy. Did you know that it comes from Greek? Etymologically the word “democracy” comes from “demos” and “kratos”, “demos” as in “common people” and “kratos” as in “power”. So there is a little <a href="https://www.youtube.com/watch?v=RtvlBS4PMF0">“power to the people”</a> thing going on in its meaning. What, then, is meant by “democratization of machine learning”  and how can we democratize machine learning?</p>

<p>Applying the etymology of democracy means that democratizing machine learning is making machine learning more accessible to common people. It’s not just about allowing people to interact with it, but also empowering them to build their own models. Therefore, machine learning frameworks and tools should be simple enough such that people can easily interact with them. Democratization is not just about releasing applications that use AI, but also about giving people the ability to develop their own applications.</p>

<p>Just 40 years ago computers were inaccessible to the majority of the “common people”. The proliferation of personal computers was truly a democratic revolution that later brought computers to our pockets. We do not look back enough to understand how far we have come in making technology available to non-technical people, and the importance of this type of convenience. Technology evolves through our interaction with it. You should not need a PhD to access it. The lower the barrier, the better and more people can adopt the technology. Of course, there should be security measures in place, but these measures should improve the accessibility of the tools. For now, you may still have to predict where machine intelligence would fail. Non-experts may fail to understand the weaknesses of the analysis, but this can be prevented with better model calibration and the expression of uncertainties. Therefore, the aim should be to provide reliable tools and technologies to people so that they can better interact with them.</p>

<p>Open source frameworks such as Keras, PyTorch, and Tensorflow simplify the development and training of deep learning models. In essence, these frameworks are developed collectively and in a decentralized manner. They can be pulled in any direction and adjusted for different needs. However, they still require an in depth understanding of deep learning to be useful (at least for complex tasks). It would be futile to expect non-technical people to utilize these frameworks. When it comes to tools like <a href="https://cloud.google.com/automl/">Google’s Cloud AutoML</a>, the conversation is a bit different. It requires minimal machine learning expertise. A lot of people are already interacting with AI in their daily lives and these are the type of tools that will enable “common people” to produce what they consume every day. Not all companies can hire a machine learning engineer to build a model from scratch or a data scientist to analyze their data. These tools delegate the mathematically rigorous part of machine learning to the experts. It hands the power of machine intelligence to the common people and let them innovate. In the age of information, it is the only way to stay strong against bigger fish.</p>

<p><a href="https://www.quora.com/Why-is-it-important-to-democratize-machine-learning">Here is a great answer from the author of Keras on why we should make the frameworks and tools more accessible</a>. I would like to elaborate on the second part of his answer. In essence, his argument is that AI will automate a lot of jobs, as a result it will further increase the centralization of wealth and power. In other words, AI can potentially seize the means of production (at least in some industries) and we must democratize artificial intelligence in order to prevent inequality. Pretty simple, right?! I agree with this answer; the proliferation of open-source frameworks and tools is an important step for democratization, but it does not finalize the process.</p>

<p>Powerful models require mathematical rigor, adequate data and abundant computational resources. Throughout this post, I elaborated on the first requirement. It is the responsibility of the machine learning community to develop machine learning tools that are accessible, reliable and available in order to truly democratize machine learning.</p>]]></content><author><name></name></author><category term="blog" /><category term="democratizing machine learning" /><category term="democratization of machine learning" /><category term="decentralized machine learning" /><category term="peer-to-peer learning" /><summary type="html"><![CDATA[It should be clear that this blog post is about democratizing machine intelligence. Ok, this might be a little late compared to all the blog posts that came before it. One thing I can assure you that this is not a blog post that preaches cryptocurrency or blockchain technology.]]></summary></entry></feed>