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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 20 11:30:16 CEST 2013


Author: romain
Date: 2013-08-20 11:30:16 +0200 (Tue, 20 Aug 2013)
New Revision: 4435

Modified:
   pkg/RcppArmadillo/ChangeLog
   pkg/RcppArmadillo/inst/NEWS.Rd
   pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h
   pkg/RcppArmadillo/inst/include/RcppArmadilloWrap.h
Log:
implementation of wrap<subview>

Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog	2013-08-17 22:31:23 UTC (rev 4434)
+++ pkg/RcppArmadillo/ChangeLog	2013-08-20 09:30:16 UTC (rev 4435)
@@ -1,3 +1,7 @@
+2013-08-20 Romain Francois <romain at r-enthusiasts.com>
+
+        * include/RcppArmadilloWrap.h: Handle wrap<subview>
+        
 2013-08-17  Dirk Eddelbuettel  <edd at debian.org>
 
 	* vignettes/RcppArmadillo-intro.Rnw: Converted from LaTeX minted

Modified: pkg/RcppArmadillo/inst/NEWS.Rd
===================================================================
--- pkg/RcppArmadillo/inst/NEWS.Rd	2013-08-17 22:31:23 UTC (rev 4434)
+++ pkg/RcppArmadillo/inst/NEWS.Rd	2013-08-20 09:30:16 UTC (rev 4435)
@@ -2,6 +2,12 @@
 \title{News for Package 'RcppArmadillo'}
 \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
 
+\section{Changes in RcppArmadillo version (future)}{
+    \itemize{
+        \item Initial Implementation of wrap<subview>    
+    }
+}
+    
 \section{Changes in RcppArmadillo version 0.3.910.0.1 (2013-08-17)}{
   \itemize{
     \item Converted main vignette from \code{LaTeX} style \code{minted}

Modified: pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h	2013-08-17 22:31:23 UTC (rev 4434)
+++ pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h	2013-08-20 09:30:16 UTC (rev 4435)
@@ -44,6 +44,7 @@
     template <typename T> SEXP wrap ( const arma::Col<T>& ) ;
     template <typename T> SEXP wrap ( const arma::field<T>& ) ;
     template <typename T> SEXP wrap ( const arma::Cube<T>& ) ;
+    template <typename T> SEXP wrap ( const arma::subview<T>& ) ;
     
     template <typename T1, typename T2, typename glue_type> 
     SEXP wrap(const arma::Glue<T1, T2, glue_type>& X ) ;

Modified: pkg/RcppArmadillo/inst/include/RcppArmadilloWrap.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadilloWrap.h	2013-08-17 22:31:23 UTC (rev 4434)
+++ pkg/RcppArmadillo/inst/include/RcppArmadilloWrap.h	2013-08-20 09:30:16 UTC (rev 4435)
@@ -43,6 +43,16 @@
 	    return ::Rcpp::wrap(object.memptr() , object.memptr() + object.n_elem);
 	}
 
+		template <typename T>
+		SEXP arma_subview_wrap( const arma::subview<T>& data, int nrows, int ncols ){
+			const int RTYPE = Rcpp::traits::r_sexptype_traits<T>::rtype ;
+			Rcpp::Matrix<RTYPE> mat( nrows, ncols ) ;
+			for( int j=0, k=0; j<ncols; j++)
+				for( int i=0; i<nrows; i++, k++) 
+					mat[k] = data(i,j) ;
+			return mat ;
+		}
+	
     } /* namespace RcppArmadillo */
 	
     /* wrap */
@@ -63,6 +73,12 @@
 	return RcppArmadillo::arma_wrap(data, Dimension(  data.n_rows, data.n_cols, data.n_slices ) ) ;
     }
     
+    template <typename T> SEXP wrap( const arma::subview<T>& data ){
+    		return RcppArmadillo::arma_subview_wrap<T>( data, data.n_rows, data.n_cols ) ;
+    }
+    
+    
+    
     namespace RcppArmadillo {
 	
 	/* Importer class for field<T> */



More information about the Rcpp-commits mailing list