title: Eigen 3 - Slicing a MatrixXd to reverse the columns order
body: <p>I need to reverse the order of the columns of a MatrixXd using RcppEigen.</p>
  
  <p>In <code>R</code> I would simply do</p>
  
  <pre><code>&gt; M = matrix(1:9, ncol = 3)
  &gt; M
       [,1] [,2] [,3]
  [1,]    1    4    7
  [2,]    2    5    8
  [3,]    3    6    9
  &gt; M = M[, 3:1]
  &gt; M
       [,1] [,2] [,3]
  [1,]    7    4    1
  [2,]    8    5    2
  [3,]    9    6    3
  </code></pre>
  
  <p>In <code>C++</code> using Eigen I can do it with a loop</p>
  
  <pre><code>Eigen::MatrixXd m1(3, 3);
  Eigen::MatrixXd m2(3, 3);
  m1 &lt;&lt; 1, 4, 7,
        2, 5, 8,
        3, 6, 9;
  
  for (int i = 0; i &lt; 3; i++){
      m2.col(i) =  m1.col(2 - i);
  }
  
  return m2;
  </code></pre>
  
  <p>Is there a better way of doing it? I looked also the <code>Eigen::Array</code> documentation but didn't find anything useful.</p>
  
  <p>Thanks, Marco</p>