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

Christian Gunning xian at unm.edu
Fri Dec 17 21:47:15 CET 2010


On Fri, Dec 17, 2010 at 9:11 AM, Dirk Eddelbuettel <edd at debian.org> wrote:
> Aie. Thanks for catching that.

Sure.

> | test1 = cxxfunction(, '
> |     ComplexVector tmpc(10);
> |     NumericVector tmpd(10, 2.0);
> |     tmpc = tmpc + tmpd;
> |     return(tmpc);
> |  ', plugin='Rcpp')

> | test2 = cxxfunction(, '
> |     NumericVector tmpd(10, 2.0);
> |     ComplexVector tmpc = tmpd;
> |     return(tmpc);
> |  ', plugin='Rcpp')
> |
> | test3 = cxxfunction(, '
> |     ComplexVector tmpc(10, 0.0);
> |     return(tmpc);
> |  ', plugin='Rcpp')
> |

> Yes, but that should happen behind the scenes.

Just to clarify:

* test2 and test3 are "behind the scenes" equivalent, correct?  If so,
I'll add a unit test for test3, or both otherwise.

* test1 does not work by design, and it's the responsibility of user
to convert to appropriate RTYPE, correct?  By analogy, assigning
IntegerVector into NumericVector currently works, but NumericVector +
IntegerVector does not:

test3 = cxxfunction(, '
    NumericVector tmpd(10, 5.0), tmpd1(10, 6.0);
    IntegerVector tmpi(10, 2.0), tmpi1(10, 3.0);  //note that float in
2nd position is required
    tmpd = tmpi; // works
    tmpd1 = tmpd1 * tmpi1;  // doesnt compile
    return(tmpd);
 ', plugin='Rcpp')

>You could also express your code in terms of Armadillo matrices.

I'm happy to leave well enough alone here :)

-xian

-- 
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!


More information about the Rcpp-devel mailing list