title: How to get the center coordinate of a 1 dimension array in 2d matrix
body: <p>Here is the scenario:</p>
  
  <pre><code>// getMatrix() returns int[]. It is 1-d
  // I wish it was 2d.
  int[] mat = MyMatrix.getMatrix();
  
  // get height and width of the matrix;
  int h = MyMatrix.height;
  int w = MyMatrix.width;
  
  // calculate the center index of the matrix
  int c = ... // need help here
  
  // manipulate the center element of the matrix.
  SomeClass.foo(mat[c]);
  </code></pre>
  
  <p>Example: Suppose I have a 5 x 5 matrix:</p>
  
  <pre><code>* * * * * // index 0 to 4
  * * * * * // index 5 to 9
  * * * * * // index 10 to 14.
  * * * * * // index 15 to 19
  * * * * * // index 20 to 24
  </code></pre>
  
  <p>If <code>getMatrix()</code> were to return <code>int[][]</code>, the center coordinate of this matrix would be <code>(2,2)</code> 0-index based. But since <code>getMatrix()</code> returns <code>int[]</code>, the center coordinate index <code>c</code> is <code>12</code>.</p>
  
  <p>However, if the height or width of the matrix is even, the center index can one of its 2 or 4 centers as shown in a 6 x 6 matrix:</p>
  
  <pre><code>* * * * * *
  * * * * * *
  * * @ @ * *
  * * @ @ * *
  * * * * * *
  * * * * * *
  </code></pre>
  
  <p>--> The center is any of the <code>@</code> above.</p>
  
  <p>How would I calculate for the center index <code>c</code> of an <strong>m x n matrix</strong>?</p>