[Rcpp-commits] r4480 - pkg/RcppArmadillo/inst/include

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 13 18:35:06 CEST 2013


Author: romain
Date: 2013-09-13 18:35:05 +0200 (Fri, 13 Sep 2013)
New Revision: 4480

Modified:
   pkg/RcppArmadillo/inst/include/RcppArmadilloAs.h
   pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h
Log:
reference passinhg for Row and Col

Modified: pkg/RcppArmadillo/inst/include/RcppArmadilloAs.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadilloAs.h	2013-09-13 15:57:55 UTC (rev 4479)
+++ pkg/RcppArmadillo/inst/include/RcppArmadilloAs.h	2013-09-13 16:35:05 UTC (rev 4480)
@@ -132,6 +132,32 @@
     			arma::Mat<T> mat ;
     } ;
     
+    template <typename T, typename VEC, typename REF>
+    class ArmaVec_InputParameter {
+    		public:
+    			ArmaVec_InputParameter( SEXP x_ ) : v(x_), vec( v.begin(), v.size(), false ){}
+    			
+    			inline operator REF(){
+    				return vec ; 	
+    			}
+    			
+    		private:
+    			Rcpp::Vector< Rcpp::traits::r_sexptype_traits<T>::rtype > v ;
+    			VEC vec ;
+    } ;
+    
+    #define MAKE_INPUT_PARAMETER(TYPE,REF)                                         \
+	template <typename T>                                                          \
+	class InputParameter<REF> : public ArmaVec_InputParameter<T, TYPE, REF >{      \
+	public:                                                                        \
+			InputParameter( SEXP x) : ArmaVec_InputParameter<T, TYPE, REF >(x){}   \
+	} ;                                                                                                                  
+    
+	MAKE_INPUT_PARAMETER(arma::Col<T>, const arma::Col<T>& )
+	MAKE_INPUT_PARAMETER(arma::Col<T>, arma::Col<T>& )
+	MAKE_INPUT_PARAMETER(arma::Row<T>, const arma::Row<T>& )
+	MAKE_INPUT_PARAMETER(arma::Row<T>, arma::Row<T>& )
+	#undef MAKE_INPUT_PARAMETER
 }
 
 #endif

Modified: pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h	2013-09-13 15:57:55 UTC (rev 4479)
+++ pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h	2013-09-13 16:35:05 UTC (rev 4480)
@@ -96,12 +96,15 @@
 
     } // namespace traits 
 
-    template <typename T>
-    class InputParameter< const arma::Mat<T>& > ;
+    template <typename T> class InputParameter< const arma::Mat<T>& > ;
+    template <typename T> class InputParameter< arma::Mat<T>& > ;
     
-    template <typename T>
-    class InputParameter< arma::Mat<T>& > ;
+    template <typename T> class InputParameter< const arma::Col<T>& > ;
+    template <typename T> class InputParameter< arma::Col<T>& > ;
     
+    template <typename T> class InputParameter< const arma::Row<T>& > ;
+    template <typename T> class InputParameter< arma::Row<T>& > ;
+    
 }
 
 #endif



More information about the Rcpp-commits mailing list