[Rcpp-commits] r796 - in pkg/Rcpp: inst inst/unitTests src/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Mar 1 09:31:12 CET 2010
Author: romain
Date: 2010-03-01 09:31:12 +0100 (Mon, 01 Mar 2010)
New Revision: 796
Modified:
pkg/Rcpp/inst/ChangeLog
pkg/Rcpp/inst/unitTests/runit.SimpleMatrix.R
pkg/Rcpp/src/Rcpp/Vector.h
Log:
more Matrix<> typedefs
Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog 2010-03-01 08:19:33 UTC (rev 795)
+++ pkg/Rcpp/inst/ChangeLog 2010-03-01 08:31:12 UTC (rev 796)
@@ -1,5 +1,8 @@
2010-03-01 Romain Francois <romain at r-enthusiasts.com>
+ * src/Rcpp/Vector.h: more typedef : CharacterMatrix, StringMatrix,
+ GenericMatrix, ExpressionMatrix, ListMatrix
+
* src/ExpressionVector.cpp : replaced by templates in Vector.h
* src/Rcpp/Vector.h: use templates to cover ExpressionVector additional
methods : eval() and eval(const Environment& )
Modified: pkg/Rcpp/inst/unitTests/runit.SimpleMatrix.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.SimpleMatrix.R 2010-03-01 08:19:33 UTC (rev 795)
+++ pkg/Rcpp/inst/unitTests/runit.SimpleMatrix.R 2010-03-01 08:31:12 UTC (rev 796)
@@ -34,3 +34,32 @@
}
+test.CharacterMatrix <- function(){
+ funx <- cfunction(signature(x = "matrix" ), '
+ CharacterMatrix m(x) ;
+ std::string trace ;
+ for( size_t i=0 ; i<4; i++){
+ trace += m(i,i) ;
+ }
+ return wrap( trace ) ;
+ ', Rcpp = TRUE, includes = "using namespace Rcpp;" )
+ x <- matrix( letters[1:16], ncol = 4 )
+ checkEquals( funx(x), paste( diag(x), collapse = "" ) )
+}
+
+test.GenericMatrix <- function( ){
+ funx <- cfunction(signature(x = "matrix" ), '
+ GenericMatrix m(x) ;
+ List output( m.ncol() ) ;
+ for( size_t i=0 ; i<4; i++){
+ output[i] = m(i,i) ;
+ }
+ return output ;
+ ', Rcpp = TRUE, includes = "using namespace Rcpp;" )
+ g <- function(y){
+ sapply( y, function(x) seq(from=x, to = 16) )
+ }
+ x <- matrix( g(1:16), ncol = 4 )
+ checkEquals( funx(x), g(diag(matrix(1:16,ncol=4))), msg = "GenericMatrix" )
+}
+
Modified: pkg/Rcpp/src/Rcpp/Vector.h
===================================================================
--- pkg/Rcpp/src/Rcpp/Vector.h 2010-03-01 08:19:33 UTC (rev 795)
+++ pkg/Rcpp/src/Rcpp/Vector.h 2010-03-01 08:31:12 UTC (rev 796)
@@ -1125,6 +1125,7 @@
typedef Vector<LGLSXP> LogicalVector ;
typedef Vector<REALSXP> NumericVector ;
typedef Vector<RAWSXP> RawVector ;
+
typedef Vector<STRSXP> CharacterVector ;
typedef Vector<STRSXP> StringVector ;
typedef Vector<VECSXP> GenericVector ;
@@ -1137,6 +1138,12 @@
typedef Matrix<REALSXP> NumericMatrix ;
typedef Matrix<RAWSXP> RawMatrix ;
+typedef Matrix<STRSXP> CharacterMatrix ;
+typedef Matrix<STRSXP> StringMatrix ;
+typedef Matrix<VECSXP> GenericMatrix ;
+typedef Matrix<VECSXP> ListMatrix ;
+typedef Matrix<EXPRSXP> ExpressionMatrix ;
+
namespace internal{
template<int RTYPE> class string_proxy {
More information about the Rcpp-commits
mailing list