title: Compare vector to double in rcpp armadillo
body: <p>Consider this Rcpp Armadillo function:</p>
  <pre><code>// [[Rcpp::depends(RcppArmadillo)]]
  #include &lt;RcppArmadillo.h&gt;
  using namespace arma;
  
  // [[Rcpp::export]]
  vec testfun(const vec &amp;x,
              const double &amp;y,
              const double &amp;z)
  {
      vec out = ((y &lt; x) - z) % (x - y);
      return out;
  }
  </code></pre>
  <p>Now running the following R Script I get inconsistent results:</p>
  <pre><code>Rcpp::sourceCpp(&quot;functions/test.cpp&quot;)
  
  x &lt;- 1:3
  y &lt;- 2
  z &lt;- 0.5
  
  out_r &lt;- ((y &lt; x) - z) * (x - y)
  out_cpp &lt;- testfun(x, y, z)
  
  print(out_r)
  print(out_cpp)
  [1] 0.5 0.0 0.5
       [,1]
  [1,]    0
  [2,]    0
  [3,]    1
  </code></pre>
  <p>So somehow the comparison fails. I would be glad for any advice on how to solve this. Coming from R, I think a loop is too complicated for this task. Maybe I'm wrong.</p>