title: Convert Rcpp Armadillo matrix to double*
body: <p>In RcppArmadillo, I need to know how I can convert <code>arma::mat</code> to c-style array <code>double *</code> for use in other functions. </p>
  
  <p>When I run the following functions, the computer crashes:</p>
  
  <p>R part:</p>
  
  <pre><code>      nn3 &lt;- function(x){
           results=.Call("KNNCV", PACKAGE = "KODAMA", x)
           results
        }
  </code></pre>
  
  <p>C++ part:</p>
  
  <pre><code>     double  KNNCV(arma::mat x) {
          double *cvpred = x.memptr();
          return cvpred[1];
       }
  </code></pre>
  
  <p>and at the end, I try:</p>
  
  <pre><code>     nn3(as.matrix(iris[,-5]))
  </code></pre>
  
  <p>Can you help me to find the errors, please?</p>