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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 19 07:56:51 CEST 2010


Author: romain
Date: 2010-08-19 07:56:51 +0200 (Thu, 19 Aug 2010)
New Revision: 2042

Modified:
   pkg/RcppArmadillo/inst/include/RcppArmadillo/Mat_meat.h
Log:
using pointers indexes instead of iterators

Modified: pkg/RcppArmadillo/inst/include/RcppArmadillo/Mat_meat.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadillo/Mat_meat.h	2010-08-19 05:43:25 UTC (rev 2041)
+++ pkg/RcppArmadillo/inst/include/RcppArmadillo/Mat_meat.h	2010-08-19 05:56:51 UTC (rev 2042)
@@ -40,9 +40,9 @@
   	
 	set_size( X.size(), 1 ) ;
 		
-	iterator first = begin(), last = end(); 
-	for( u32 i=0; first != last; ++i){
-		*first++ = X[i] ;
+	eT* ptr = memptr() ;
+	for( u32 i=0; i<n_elem; ++i){
+		ptr[i] = X[i] ;
 	}
 }
 
@@ -62,13 +62,13 @@
 	// std::complex<double> != Rcomplex
 	isnt_same_type<eT, typename Rcpp::traits::storage_type<RTYPE>::type >::check();
   	
-	u32 nr = X.nrow(), nc = X.ncol(), i_col, i_row ;
+	u32 nr = X.nrow(), nc = X.ncol(), i_col, i_row, k ;
 	set_size( nr, nc ) ;
 		
-	iterator first = begin() ;
-	for( i_col=0; i_col < nc; ++i_col){
-		for( i_row = 0; i_row < nr ; ++i_row ){
-			*first++ = X(i_row,i_col) ;
+	eT* ptr = memptr() ;
+	for( i_col=0, k=0 ; i_col < nc; ++i_col){
+		for( i_row = 0; i_row < nr ; ++i_row, ++k ){
+			ptr[k] = X(i_row,i_col) ;
 		}
 	}
 }



More information about the Rcpp-commits mailing list