title: Linear index upper triangular matrix
body: <p>If I have the upper triangular portion of a matrix, offset above the diagonal, stored as a linear array, how can the <code>(i,j)</code> indices of a matrix element be extracted from the linear index of the array?</p>
  
  <p>For example, the linear array <code>[a0, a1, a2, a3, a4, a5, a6, a7, a8, a9</code> is storage for the matrix</p>
  
  <pre><code>0  a0  a1  a2  a3
  0   0  a4  a5  a6
  0   0   0  a7  a8
  0   0   0   0  a9
  0   0   0   0   0
  </code></pre>
  
  <p>And we want to know the (i,j) index in the array corresponding to an offset in the linear matrix, without recursion.</p>
  
  <p>A suitable result, <code>k2ij(int k, int n) -&gt; (int, int)</code> would satisfy, for example</p>
  
  <pre><code>k2ij(k=0, n=5) = (0, 1)
  k2ij(k=1, n=5) = (0, 2)
  k2ij(k=2, n=5) = (0, 3)
  k2ij(k=3, n=5) = (0, 4)
  k2ij(k=4, n=5) = (1, 2)
  k2ij(k=5, n=5) = (1, 3)
   [etc]
  </code></pre>