[Rcpp-commits] r505 - in pkg: inst src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jan 28 14:51:13 CET 2010
Author: romain
Date: 2010-01-28 14:51:13 +0100 (Thu, 28 Jan 2010)
New Revision: 505
Modified:
pkg/inst/ChangeLog
pkg/src/Dimension.cpp
pkg/src/RcppCommon.h
Log:
using accumulate and multiplies
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2010-01-28 13:37:37 UTC (rev 504)
+++ pkg/inst/ChangeLog 2010-01-28 13:51:13 UTC (rev 505)
@@ -3,11 +3,11 @@
* src/Rcpp/SimpleVector.h: simple vectors gain a range
based assign method and a range based assign constructor
* inst/unitTests/runit.IntegerVector.R: new unit test
+ test.IntegerVector.range.constructors
-
* src/Rcpp/Dimension.h: new class Rcpp::Dimension to support
creation of vectors with dimensions
-
+
* src/Rcpp/*Vector.h: using Rcpp::Dimension
* src/Rcpp/SimpleVector.h: data is initialized with 0 when
Modified: pkg/src/Dimension.cpp
===================================================================
--- pkg/src/Dimension.cpp 2010-01-28 13:37:37 UTC (rev 504)
+++ pkg/src/Dimension.cpp 2010-01-28 13:51:13 UTC (rev 505)
@@ -55,14 +55,7 @@
}
int Dimension::prod() const {
- int prod = 1 ;
- std::vector<int>::const_iterator begin = dims.begin() ;
- std::vector<int>::const_iterator end = dims.end() ;
- while( begin != end ){
- prod *= (*begin) ;
- ++begin ;
- }
- return prod ;
+ return std::accumulate( dims.begin(), dims.end(), 1, std::multiplies<int>() ) ;
}
int& Dimension::operator[](int i) throw(std::range_error){
Modified: pkg/src/RcppCommon.h
===================================================================
--- pkg/src/RcppCommon.h 2010-01-28 13:37:37 UTC (rev 504)
+++ pkg/src/RcppCommon.h 2010-01-28 13:51:13 UTC (rev 505)
@@ -44,6 +44,8 @@
#include <map>
#include <stdexcept>
#include <vector>
+#include <functional>
+#include <numeric>
#ifdef HAS_INIT_LISTS
#include <initializer_list>
More information about the Rcpp-commits
mailing list