<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Absolutely right! <br>
    How stupid of me.<br>
    Cheers, <br>
    <br>
    <br>
    On 08/04/11 13:18, <a class="moz-txt-link-abbreviated" href="mailto:romain@r-enthusiasts.com">romain@r-enthusiasts.com</a> wrote:
    <blockquote
      cite="mid:CAF2284D-1387-42B7-8962-8496D674A821@r-enthusiasts.com"
      type="cite">
      <div>Hmmm. I think you just need "i&lt;n" instead of "i&lt;=n" in
        your for construct.</div>
      <div><br>
      </div>
      <div>Romain<br>
        <br>
        <div><br>
        </div>
      </div>
      <div><br>
        Le 8 avr. 2011 à 10:12 AM, Cedric Ginestet &lt;<a
          moz-do-not-send="true"
          href="mailto:c.ginestet05@googlemail.com">c.ginestet05@googlemail.com</a>&gt;
        a écrit :<br>
        <br>
      </div>
      <blockquote type="cite">
        <div> Hi guys, <br>
          <br>
          I have encountered a reproducible error in using Rcpp, which I
          have reported below. Basically, while allocation of elements
          in a vector to a particular value works well for vectors of
          small sizes, this returns an error when the size of that
          vector is increased. Either it returns a giblc error or it
          hangs and never resumes. I have reproduced this error on two
          different Linux distributions (Ubuntu 10.10 and 10.04 with g++
          4.4.1 and R 2.12.1). <br>
          <br>
          ####################################################<br>
          library(Rcpp)<br>
          library(inline)<br>
          <br>
          src &lt;- '<br>
            Rcpp::IntegerMatrix xA(A);<br>
            int n=xA.nrow();<br>
            NumericVector dist(n);<br>
            for(int i=0;i&lt;=n;i++){dist[i]=1.0;}<br>
            return dist;'<br>
          cxxfun &lt;-
cxxfunction(sig=signature(A="matrix"),body=src,plugin="Rcpp",verbose=TRUE)<br>
          <br>
          ## Tests.<br>
          n &lt;- 20; A &lt;- matrix(0,n,n); dist &lt;- cxxfun(A); <br>
          n &lt;- 200; A &lt;- matrix(0,n,n); dist &lt;- cxxfun(A); <br>
          n &lt;- 2000; A &lt;- matrix(0,n,n); dist &lt;- cxxfun(A); <br>
          *** glibc detected *** /usr/lib/R/bin/exec/R: double free or
          corruption (!prev): 0x08cfc278 ***<br>
          <br>
          ####################################################<br>
          <br>
          Is there something that I doing wrong there? <br>
          Thank you very much for your help, <br>
          Ced<br>
          <br>
          <br>
          <div class="moz-signature">-- <br>
            <div class="moz-signature"><font face="Times" size="3">
                Cedric Ginestet <br>
                Centre for Neuroimaging Sciences (L3.04) <br>
                NIHR Biomedical Research Centre <br>
                Institute of Psychiatry, Box P089 <br>
                Kings College London <br>
                De Crespigny Park<br>
                London <br>
                SE5 8AF <br>
              </font> </div>
          </div>
        </div>
      </blockquote>
      <blockquote type="cite">
        <div><span>_______________________________________________</span><br>
          <span>Rcpp-devel mailing list</span><br>
          <span><a moz-do-not-send="true"
              href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a></span><br>
          <span><a moz-do-not-send="true"
href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></span><br>
        </div>
      </blockquote>
    </blockquote>
  </body>
</html>