aboutsummaryrefslogtreecommitdiffstats
path: root/src/projet.cpp
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2016-04-21 17:37:40 -0400
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2016-04-21 17:37:40 -0400
commite3694fb5e5b6b2b307dd31399b242e01977ed19f (patch)
tree96c9831c14ce89c03e2b2191daeb7397a5db8c6e /src/projet.cpp
parent8c9f217887de0802d6b8dfa1f872ec3cf8797d45 (diff)
downloadprojet_C++-e3694fb5e5b6b2b307dd31399b242e01977ed19f.tar.gz
use lambda functionslambda_fun
Diffstat (limited to 'src/projet.cpp')
-rw-r--r--src/projet.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/projet.cpp b/src/projet.cpp
index d2cae1a..efab703 100644
--- a/src/projet.cpp
+++ b/src/projet.cpp
@@ -63,15 +63,10 @@ vector< vector<double> > exemple1_rqmc(){
std::vector<double> normalize (std::vector<double> mu) {
- int d = mu.size();
- double norm_mu = 0;
- std::vector<double> u(d);
- for(int i=0; i<d; i++) {
- norm_mu += mu[i]*mu[i];
- }
- for(int i=0; i<d; i++) {
- u[i] = mu[i]/sqrt(norm_mu);
- }
+ double norm_mu = accumulate(mu.begin(), mu.end(), 0.,
+ [](double x, double y){ return x + y*y;});
+ vector<double> u(mu);
+ transform(u.begin(), u.end(), u.begin(), [norm_mu](double x){ return x/sqrt(norm_mu); });
return u;
}
@@ -176,7 +171,6 @@ int main()
make_table2(data1, data2, data3, data4, "table2.tex");
vector< vector<double> > data5 = exemple2_stratified(16, false);
vector< vector<double> > data6 = exemple2_rqmc(16, false);
- cout<<"test"<<endl;
vector< vector<double> > data7 = exemple2_stratified(64, false);
vector< vector<double> > data8 = exemple2_rqmc(64,false);
make_table2(data5, data6, data7, data8, "table3.tex");