[Rcpp-commits] r2590 - in pkg/RcppGSL/inst: examples/RcppGSLExample/src include

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 29 13:56:34 CET 2010


Author: edd
Date: 2010-11-29 13:56:34 +0100 (Mon, 29 Nov 2010)
New Revision: 2590

Modified:
   pkg/RcppGSL/inst/examples/RcppGSLExample/src/colNorm.cpp
   pkg/RcppGSL/inst/include/RcppGSLForward.h
Log:
taking matrix_ and vector_ private in the view classes and adding getVector/getMatrix getters
adapting usage example accordingly


Modified: pkg/RcppGSL/inst/examples/RcppGSLExample/src/colNorm.cpp
===================================================================
--- pkg/RcppGSL/inst/examples/RcppGSLExample/src/colNorm.cpp	2010-11-29 11:36:04 UTC (rev 2589)
+++ pkg/RcppGSL/inst/examples/RcppGSLExample/src/colNorm.cpp	2010-11-29 12:56:34 UTC (rev 2590)
@@ -36,7 +36,7 @@
 
 		for (int j = 0; j < k; j++) {
 			RcppGSL::vector_view<double> colview = gsl_matrix_column (M, j);
-			n[j] = gsl_blas_dnrm2(colview.vector_ );
+			n[j] = gsl_blas_dnrm2(colview.getVector());
 		}
 		M.free() ;
 		return n;							// return vector  

Modified: pkg/RcppGSL/inst/include/RcppGSLForward.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSLForward.h	2010-11-29 11:36:04 UTC (rev 2589)
+++ pkg/RcppGSL/inst/include/RcppGSLForward.h	2010-11-29 12:56:34 UTC (rev 2590)
@@ -138,9 +138,10 @@
 	inline iterator begin(){ return vector_.begin() ; }
 	inline iterator end(){ return vector_.end() ; }
 	inline size_t size(){ return vector_.size(); }
-	
+	inline VEC & getVector() { return vector_; }
 	view_type view ;
-	VEC vector_ ;
+private:
+	VEC vector_;
 } ;
 
 template <typename T> class matrix_view {
@@ -159,8 +160,9 @@
 	inline size_t nrow(){ return matrix_.nrow() ; }              
 	inline size_t ncol(){ return matrix_.ncol() ; }              
 	inline size_t size(){ return matrix_.size() ; }
-	
+	inline MAT & getMatrix() { return matrix_; }
 	view_type view ;
+private:
 	MAT matrix_ ;
 } ;
 



More information about the Rcpp-commits mailing list