title: Matrix division & permutation to achieve Baker map
body: <p>I'm trying to implement the Baker map. 
  Is there a function that would allow one to divide a 8 x 8 matrix by providing, for example, a sequence of divisors 2, 4, 2 and rearranging pixels in the order as shown in the matrices below?</p>
  
  <pre><code>X = reshape(1:64,8,8);
  </code></pre>
  
  <p>After applying divisors 2,4,2 to the matrix X one should get a matrix like A shown below.</p>
  
  <pre><code>A=[31 23 15 7 32 24 16 8;
    63 55 47 39 64 56 48 40;
    11 3 12 4 13 5 14 6;
    27 19 28 20 29 21 30 22;
    43 35 44 36 45 37 46 38;
    59 51 60 52 61 53 62 54;
    25 17 9 1 26 18 10 2;
    57 49 41 33 58 50 42 34]
  </code></pre>
  
  <p>The link to the document which I am working on is:
  <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.39.5132&amp;rep=rep1&amp;type=pdf" rel="nofollow noreferrer">http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.39.5132&amp;rep=rep1&amp;type=pdf</a></p>
  
  <p>This is what I want to achieve:</p>
  
  <p><img src="https://i.stack.imgur.com/i3l8P.jpg" alt="enter image description here"></p>