From 28fe184f2fea5031f352cf73fc30b99b5cde8f6f Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 13 Apr 2016 11:34:19 -0400 Subject: replace unary_function by function --- src/option.hpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/option.hpp') diff --git a/src/option.hpp b/src/option.hpp index 4d9ee13..c969071 100644 --- a/src/option.hpp +++ b/src/option.hpp @@ -1,12 +1,12 @@ -#include "rqmc.hpp" +#include double pos (double x); -struct asian_option : public std::unary_function, double> +struct asian_option : public std::function)> { asian_option(double r, double T, double S0, double V, int d, double K) : r(r), T(T), S0(S0), V(V), d(d), K(K) {}; - + double operator()(std::vector X) const { std::vector S(d); S[0]= S0*exp((r-V*V/2)*(T/d)+V*sqrt(T/d)*X[0]); @@ -15,8 +15,8 @@ struct asian_option : public std::unary_function, double> } double temp = std::accumulate(S.begin(), S.end(), 0.)/d; return exp(-r*T)*pos(temp-K); - }; - + }; + private: double r; double T; @@ -25,5 +25,3 @@ struct asian_option : public std::unary_function, double> int d; double K; }; - - -- cgit v1.2.3-70-g09d2