[Rcpp-commits] r1398 - in pkg/RcppArmadillo: . inst inst/include inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 2 13:49:30 CEST 2010


Author: romain
Date: 2010-06-02 13:49:29 +0200 (Wed, 02 Jun 2010)
New Revision: 1398

Modified:
   pkg/RcppArmadillo/NEWS
   pkg/RcppArmadillo/inst/ChangeLog
   pkg/RcppArmadillo/inst/include/RcppArmadillo.h
   pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h
   pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R
Log:
support for mtGlue

Modified: pkg/RcppArmadillo/NEWS
===================================================================
--- pkg/RcppArmadillo/NEWS	2010-06-02 11:30:52 UTC (rev 1397)
+++ pkg/RcppArmadillo/NEWS	2010-06-02 11:49:29 UTC (rev 1398)
@@ -9,8 +9,14 @@
 		as a complex and an arma::mat, which have been introduced in
 		armadillo 0.9.10
 		
+	o	wrap support for mtGlue, i.e. operations involving matrices of mixed 
+		types such as an arma::mat and an arma::imat, which have been introduced
+		in armadillo 0.9.10
+		
 	o	Included an inline plugin to support the plugin system introduced
-		in inline 0.3.5
+		in inline 0.3.5. The unit tests have moved from the src directory 
+		to the unit test directory (similar to Rcpp) using cxxfunction with the
+		RcppArmadillo plugin. 
 		
 0.2.1   2010-05-19
 

Modified: pkg/RcppArmadillo/inst/ChangeLog
===================================================================
--- pkg/RcppArmadillo/inst/ChangeLog	2010-06-02 11:30:52 UTC (rev 1397)
+++ pkg/RcppArmadillo/inst/ChangeLog	2010-06-02 11:49:29 UTC (rev 1398)
@@ -1,3 +1,10 @@
+2010-06-02   Romain Francois <romain at r-enthusiasts.com>
+
+	* inst/include/* : upgrade to armadillo 0.9.10
+	
+	* inst/include/* : support for new mtOp and mtGlue, introduced in 
+	armadillo 0.9.10
+	
 2010-05-27   Romain Francois <romain at r-enthusiasts.com>
 
 	* R/flags.R: added RcppArmadillo:::CxxFlags()

Modified: pkg/RcppArmadillo/inst/include/RcppArmadillo.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadillo.h	2010-06-02 11:30:52 UTC (rev 1397)
+++ pkg/RcppArmadillo/inst/include/RcppArmadillo.h	2010-06-02 11:49:29 UTC (rev 1398)
@@ -154,9 +154,25 @@
     		return ::Rcpp::wrap( arma::Mat<out_eT>(X) ) ;
     	}
     	
+    	template<typename out_eT, typename T1, typename T2, typename glue_type>
+    	SEXP wrap_mtglue( const arma::mtGlue<out_eT,T1,T2,glue_type>& X, ::Rcpp::traits::false_type ){
+    		// int n_rows = X.P1.n_rows ;
+    		// int n_cols = X.P1.n_cols ;
+    		// typedef typename ::Rcpp::Vector< ::Rcpp::traits::r_sexptype_traits< typename T1::elem_type>::rtype > VECTOR ;
+    		// VECTOR res(::Rcpp::Dimension( n_rows , n_cols )) ;
+    		// ::arma::Mat<typename T1::elem_type> result( res.begin(), n_rows, n_cols, false ) ;
+    		// result = X ;
+    		// return res ;
+    		return ::Rcpp::wrap( arma::Mat<out_eT>(X) ) ; 
+    	}
     	
+    	template<typename out_eT, typename T1, typename T2, typename glue_type>
+    	SEXP wrap_mtglue( const arma::mtGlue<out_eT,T1,T2,glue_type>& X , ::Rcpp::traits::true_type ){
+    		return ::Rcpp::wrap( arma::Mat<out_eT>(X) ) ; 
+    	}
     	
     	
+    	
     } // namespace RcppArmadillo
     
     template <typename T1, typename T2, typename glue_type>
@@ -184,6 +200,11 @@
     	return RcppArmadillo::wrap_mtop( X, typename traits::r_sexptype_needscast<out_eT>::type() ) ;
     }
 
+    template<typename out_eT, typename T1, typename T2, typename glue_type>
+    SEXP wrap( const arma::mtGlue<out_eT,T1,T2,glue_type>& X ){
+    	return RcppArmadillo::wrap_mtglue( X, typename traits::r_sexptype_needscast<out_eT>::type() ) ;
+    }
+
     /* support for Rcpp::as */
 
     namespace traits {

Modified: pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h	2010-06-02 11:30:52 UTC (rev 1397)
+++ pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h	2010-06-02 11:49:29 UTC (rev 1398)
@@ -61,6 +61,9 @@
     template<typename out_eT, typename T1, typename op_type>
     SEXP wrap( const arma::mtOp<out_eT,T1,op_type>& X ) ;
 
+    template<typename out_eT, typename T1, typename T2, typename glue_type>
+    SEXP wrap( const arma::mtGlue<out_eT,T1,T2,glue_type>& X );
+    
     namespace traits {
 
 	/* support for as */

Modified: pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R
===================================================================
--- pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R	2010-06-02 11:30:52 UTC (rev 1397)
+++ pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R	2010-06-02 11:49:29 UTC (rev 1398)
@@ -222,3 +222,20 @@
 	
 }
 
+test.mtGlue <- function(){
+
+	fx <- cxxfunction( signature() , '
+
+	arma::imat m2 = arma::eye<arma::imat> ( 3, 3 ) ;
+	arma::mat m1  = arma::eye<arma::mat> ( 3, 3 ) ;
+
+    return wrap( m1 + m2 ) ;
+    
+	', plugin = "RcppArmadillo" )
+	checkEquals( fx(), 
+		2.0 * diag(3) , 
+		msg = "support for mtOp" )
+	
+}
+
+



More information about the Rcpp-commits mailing list