aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2016-02-01 15:15:13 -0500
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2016-02-01 15:15:13 -0500
commit37e7d24066bd59c51263b1e045dab1ada4ea4769 (patch)
tree66465bf87c24ef7186cc435fb905d3c3a3add8f1
parentca2758864ee33fc7aebbbf65a87bc9074afc4a3b (diff)
downloadprojet_C++-37e7d24066bd59c51263b1e045dab1ada4ea4769.tar.gz
C++11 me voilĂ !
-rw-r--r--Makefile2
-rw-r--r--stratified_sampling.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 2ffcd8f..c412ee3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
CXX=g++
CC=gcc
RM = rm
-CXXFLAGS=-O3
+CXXFLAGS=-std=c++11 -O3
GSL_FLAGS:=$(shell pkg-config --libs gsl)
stratified_sampling: rtnorm.o stratified_sampling.o
diff --git a/stratified_sampling.cpp b/stratified_sampling.cpp
index 22bdbf5..f6c3ff1 100644
--- a/stratified_sampling.cpp
+++ b/stratified_sampling.cpp
@@ -26,9 +26,9 @@ double quantile_truncate_normal (int i, int n, double mu,
std::pair<double, double> mean_var( std::vector<double> r){
std::pair<double, double> p;
- for(int i=0; i<r.size(); i++){
- p.first += r[i];
- p.second += r[i]*r[i];
+ for(auto &x: r){
+ p.first += x;
+ p.second += x*x;
}
p.first /= r.size();
p.second /= r.size();