To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

integrate_bind.cpp 446 Bytes
Newer Older
Donjan Rodic's avatar
Donjan Rodic committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "simpson.hpp"
#include <iostream>
#include <cmath>
#include <functional>

// a function with two variables
double expax(double a, double x)
{
  return std::exp(a*x);
}

int main()
{
  using namespace std::placeholders;
  
  double a=3.4;
  // bind one argument
  // _1, _2, .... are used for unbound arguments of the resulting function
  auto f = std::bind(expax,3.4,_1);
  std::cout << simpson(f,0.,1.,100) << std::endl;
  return 0;
}