[Rcpp-devel] Regression in conversion from NumericVector to ComplexVector?

Dirk Eddelbuettel edd at debian.org
Wed Dec 22 17:42:18 CET 2010


On 22 December 2010 at 09:18, Christian Gunning wrote:
| > test1 = cxxfunction(signature(vec='complex'), '
| >             ComplexVector x(vec) ;
| >                 int nn = x.size();
| >                 for( int i=0; i<nn; i++) {
| >                     x[i].r = x[i].r*2 ;
| >                     x[i].i = x[i].i*2 ;
| >                 }
| >                 return x ;
| > ', plugin='Rcpp')
| >
| > aa1 =  (0:9)*(1+1i)
| > aa2 =  (0:9)*(1+1i)
| > all.equal(aa1,aa2)  ## true
| > bb = test1(aa1)
| > all.equal(aa1,aa2)  ## false
| >
| 
| Good deal. Is the above behaivor a bug?

Not really.  I think you meant to make a deep copy and didn't.  So you
altered aa1 which you sent in, and get the difference between aa1 and aa2.

Or maybe I am missing something.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list