title: Inverse (Column) Row-Major Order Transformation
body: <p>Can anyone provide/refer to the inverse of the 'indices -> offset'* transformation for Multi-Dimensional Row-Major Order. Also, (pseudo)code would be appreciated. </p>
  
  <ul>
  <li><a href="http://en.wikipedia.org/wiki/Row-major_order" rel="nofollow">http://en.wikipedia.org/wiki/Row-major_order</a></li>
  </ul>
  
  <p>To give an example, an simplification of the particular problem which prompted my question:
  I have a 3 dimensional data hierarchy, expressed in the space spanned by (a,b,c) where a, b, and c are integers larger or equal zero and less then N_a, N_b, and N_c. I want to express the data an one dimensional array. The "offset," In Row-Major Order, is then given as follows:</p>
  
  <pre><code> int offset(a, b, c){
        return a*N_b*N_c + b*N_c + c;
  }
  </code></pre>
  
  <p>What is then the reverse transformation, i.e.:</p>
  
  <pre><code>int a(int offset);
  int b(int offset);
  int c(int offset);
  </code></pre>
  
  <p>Furthermore, how to i generalise this to N'th dimension indexation? The problem which prompted this question is of 5'th dimension.</p>
  
  <p>In case it matters, I am writing in c/c++.</p>