[Rcpp-commits] r2537 - in pkg/Rcpp: . inst/include/Rcpp/vector

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 26 15:36:22 CET 2010


Author: romain
Date: 2010-11-26 15:36:22 +0100 (Fri, 26 Nov 2010)
New Revision: 2537

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h
Log:
same for MatrixRow

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2010-11-26 14:30:50 UTC (rev 2536)
+++ pkg/Rcpp/ChangeLog	2010-11-26 14:36:22 UTC (rev 2537)
@@ -9,6 +9,8 @@
     * inst/include/Rcpp/vector/MatrixColumn.h: added MatrixColumn::operator=( MatrixColumn& )
     otherwise it gets synthetized by the compiler
     
+    * inst/include/Rcpp/vector/MatrixRow.h: same for MatrixRow
+    
 2010-11-25  Romain Francois <romain at r-enthusiasts.com>
 
     * inst/include/Rcpp/module/Module_generated_function.h: new .function with

Modified: pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h	2010-11-26 14:30:50 UTC (rev 2536)
+++ pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h	2010-11-26 14:36:22 UTC (rev 2537)
@@ -112,34 +112,21 @@
 	MatrixRow& operator=( const Rcpp::VectorBase<RT,NA,T>& rhs ){
 	    int n = size() ;
 	    const T& ref = rhs.get_ref() ;
-	    
-	    int __trip_count = n >> 2 ;
-        int i = 0 ;
-        for ( ; __trip_count > 0 ; --__trip_count) { 
-        	start[get_parent_index(i)] = ref[i] ; i++ ;            
-        	start[get_parent_index(i)] = ref[i] ; i++ ;            
-        	start[get_parent_index(i)] = ref[i] ; i++ ;            
-        	start[get_parent_index(i)] = ref[i] ; i++ ;            
-        }                                            
-        switch (n - i){                          
-          case 3:                                    
-              start[get_parent_index(i)] = ref[i] ; i++ ;             
-          case 2:                                    
-              start[get_parent_index(i)] = ref[i] ; i++ ;             
-          case 1:                                    
-              start[get_parent_index(i)] = ref[i] ; i++ ;             
-          case 0:                                    
-          default:                                   
-              {}                         
-        }
-        return *this ;
+	    RCPP_LOOP_UNROLL(start,ref)
+	    return *this ;
 	}
+	
+	MatrixRow& operator=( const MatrixRow& rhs ){
+	    int n = size() ;
+	    RCPP_LOOP_UNROLL(start,rhs)
+	    return *this ;
+	}
 
-	reference operator[]( int i ){
+	inline reference operator[]( int i ){
 		return start[ get_parent_index(i) ] ;
 	}
 	
-	reference operator[]( int i ) const {
+	inline reference operator[]( int i ) const {
 		return start[ get_parent_index(i) ] ;
 	}
 	



More information about the Rcpp-commits mailing list