[Rcpp-commits] r2811 - in pkg/Rcpp: . inst/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 22 13:29:57 CET 2010
Author: edd
Date: 2010-12-22 13:29:57 +0100 (Wed, 22 Dec 2010)
New Revision: 2811
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/unitTests/runit.Vector.R
Log:
applied patch by Christian for more tests on complex-valued vectors
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2010-12-22 11:35:25 UTC (rev 2810)
+++ pkg/Rcpp/ChangeLog 2010-12-22 12:29:57 UTC (rev 2811)
@@ -1,6 +1,11 @@
+2010-12-22 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/unitTests/runit.Vector.R: Applied patch by Christian Gunning
+ to add more tests for complex-typed vectors
+
2010-12-20 Dirk Eddelbuettel <edd at debian.org>
- * R/inline.R (Rcpp.plugin.maker): Reverse order in PKG_LIBS
+ * R/inline.R (Rcpp.plugin.maker): Reverse order in PKG_LIBS
2010-12-19 Dirk Eddelbuettel <edd at debian.org>
Modified: pkg/Rcpp/inst/unitTests/runit.Vector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Vector.R 2010-12-22 11:35:25 UTC (rev 2810)
+++ pkg/Rcpp/inst/unitTests/runit.Vector.R 2010-12-22 12:29:57 UTC (rev 2811)
@@ -95,21 +95,41 @@
return x ;
'
),
- "complex_INTSXP" = list(
+ "complex_CPLXSXP" = list(
signature(vec = "complex" ),
'
ComplexVector x(vec) ;
- for( int i=0; i<x.size(); i++) {
+ 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 ;
'
),
+ "complex_INTSXP" = list(
+ signature(vec = "integer" ),
+ '
+ ComplexVector x(vec);
+ int nn = x.size();
+ IntegerVector tmp(nn, 2.0);
+ ComplexVector tmp1(tmp);
+ x = x * tmp1;
+ return x ;
+ '
+ ),
+ "complex_REALSXP" = list(
+ signature(vec = "numeric" ),
+ '
+ ComplexVector x(vec);
+ int nn = x.size();
+ NumericVector tmp(nn, 3.0);
+ ComplexVector tmp1(tmp);
+ x = x * tmp1;
+ return x ;
+ '
+ ),
-
-
-
"integer_ctor"=list(
signature(),
'IntegerVector x(10) ;
@@ -727,11 +747,22 @@
funx <- .rcpp.Vector$complex_
checkEquals( funx(), 0:9*(1+1i), msg = "ComplexVector" )
}
-
+test.ComplexVector.CPLXSXP <- function(){
+ funx <- .rcpp.Vector$complex_CPLXSXP
+ vv = (0:9)*(1+1i) ## not working - funx changes its argument
+ #checkEquals( funx(vv), 2*vv, msg = "ComplexVector( CPLXSXP) " )
+ checkEquals( funx((0:9)*(1+1i)), 2*(0:9)*(1+1i), msg = "ComplexVector( CPLXSXP) " )
+}
test.ComplexVector.INTSXP <- function(){
funx <- .rcpp.Vector$complex_INTSXP
- checkEquals( funx(0:9*(1+1i)), 2*0:9*(1+1i), msg = "ComplexVector( CPLXSXP) " )
+ vv <- 0L:9L
+ checkEquals( funx(vv), (2+0i)*vv, msg = "ComplexVector( INTSXP) " )
}
+test.ComplexVector.REALSXP <- function(){
+ funx <- .rcpp.Vector$complex_REALSXP
+ vv <- as.numeric(0:9)
+ checkEquals( funx(vv), (3+0i)*vv, msg = "ComplexVector( REALSXP) " )
+}
if( Rcpp:::capabilities()[["initializer lists"]] ){
test.ComplexVector.initializer.list <- function(){
funx <- .rcpp.Vector$complex_initializer_list
More information about the Rcpp-commits
mailing list