[Rcpp-commits] r717 - in pkg/RcppArmadillo: inst src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 17 11:33:09 CET 2010


Author: romain
Date: 2010-02-17 11:33:09 +0100 (Wed, 17 Feb 2010)
New Revision: 717

Modified:
   pkg/RcppArmadillo/inst/ChangeLog
   pkg/RcppArmadillo/src/RcppArmadillo.h
Log:
added experimental support for wrap(Cube<T>), can't test them because I only have armadillo 0.6.12

Modified: pkg/RcppArmadillo/inst/ChangeLog
===================================================================
--- pkg/RcppArmadillo/inst/ChangeLog	2010-02-17 10:14:47 UTC (rev 716)
+++ pkg/RcppArmadillo/inst/ChangeLog	2010-02-17 10:33:09 UTC (rev 717)
@@ -3,6 +3,8 @@
 	* added support for as<Mat<T>> as<Row<T>> and as<Col<T>> 
 	with T in : int, double, float, unsigned int
 	
+	* added untested support for wrap( Cube<T> )
+	
 2010-02-16  Romain Francois <romain at r-enthusiasts.com>
 
 	* initial version, covering wrap(Mat), wrap(Col), wrap(Row)

Modified: pkg/RcppArmadillo/src/RcppArmadillo.h
===================================================================
--- pkg/RcppArmadillo/src/RcppArmadillo.h	2010-02-17 10:14:47 UTC (rev 716)
+++ pkg/RcppArmadillo/src/RcppArmadillo.h	2010-02-17 10:33:09 UTC (rev 717)
@@ -14,7 +14,9 @@
 	template <typename T> SEXP wrap ( const arma::Mat<T>& ) ;
 	template <typename T> SEXP wrap ( const arma::Row<T>& ) ;
 	template <typename T> SEXP wrap ( const arma::Col<T>& ) ;
-	       
+#ifdef HAS_CUBE
+	template <typename T> SEXP wrap ( const arma::Cube<T>& ) ;
+#endif
 	RCPPARMA_FORWARD(int)
 	RCPPARMA_FORWARD(double)
 	RCPPARMA_FORWARD(float)
@@ -39,9 +41,7 @@
 	SimpleVector< traits::r_sexptype_traits<T>::rtype > vec( 
 		Dimension( mat.n_rows, mat.n_cols ) );
 	int n = mat.n_elem ;
-	for( int i=0; i<n; i++){
-		vec[i] = mat[i] ;
-	}
+	RCPPARMA_COPY(mat,vec,n)
 	return vec ; 
 } ;
 
@@ -49,9 +49,7 @@
 	int n = column.n_rows ;
 	SimpleVector< traits::r_sexptype_traits<T>::rtype > vec( 
 		Dimension( n, 1 ) );
-	for( int i=0; i<n; i++){
-		vec[i] = column[i] ;
-	}
+	RCPPARMA_COPY(column,vec,n)
 	return vec ;
 }
 
@@ -59,12 +57,20 @@
 	int n = row.n_cols ;
 	SimpleVector< traits::r_sexptype_traits<T>::rtype > vec( 
 		Dimension( 1, n ) );
-	for( int i=0; i<n; i++){
-		vec[i] = row[i] ;
-	}
+	RCPPARMA_COPY(row,vec,n)
 	return vec ;
 }
 
+#ifdef HAS_CUBE
+template <typename T> SEXP wrap( const arma::Cube<T>& cube ){
+	int n = cube.n_elem;
+	SimpleVector< traits::r_sexptype_traits<T>::rtype > vec( 
+		Dimension( cube.n_rows, cube.n_cols, cube.n_slices ) );
+	RCPPARMA_COPY(cube,vec,n)
+	return vec ;
+}
+#endif
+
 } // namespace Rcpp
 
 



More information about the Rcpp-commits mailing list