# ‘Functor1D’ is not a member of ‘ROOT::Math’

**URL:** <https://root-forum.cern.ch/t/functor1d-is-not-a-member-of-root-math/43111>\
**Category:** Newbie\
**Created:** [January 15, 2021, 8:04am UTC](https://root-forum.cern.ch/t/functor1d-is-not-a-member-of-root-math/43111 "2021-01-15T08:04:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie2](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/b4bc9f/32.png) [@newbie2](https://root-forum.cern.ch/u/newbie2)\
**Post date:** [January 15, 2021, 8:04am UTC](https://root-forum.cern.ch/t/functor1d-is-not-a-member-of-root-math/43111/1 "2021-01-15T08:04:54Z")

</div>

ROOT Version: 6.22/02  
Platform: Ubuntu 20.04.1 LTS  
Compiler: g++

What am I doing wrong actually? Is it something related to namespace or what? I have  
just taken the code from the available user guide for ROOT and using a function and then  
compiling it with `g++ -o File test.cc `root-config --cflags --libs``. Here is the code :

```auto
#define EPS 1e-5
#include <iostream>
#include <cmath>
#include "Math/Integrator.h"
using namespace std;

const double R = 6.38;
const double a = 0.535;
const double w = 0.;

double Fermi(double* r){
  double rho = (1. + w*pow(r[0]/R, 2))/(1. + exp((r[0] - R)/a));
  return rho;
}

int test(){
  ROOT::Math::IntegratorOneDimOptions::SetDefaultAbsTolerance(EPS);
  ROOT::Math::IntegratorOneDimOptions::SetDefaultRelTolerance(EPS);

  ROOT::Math::Functor1D F(&Fermi);
  ROOT::Math::Integrator I(ROOT::Math::IntegrationOneDim::kADAPTIVESINGULAR);
  I.SetFunction(F);
  double t = I.Integral(0., 3*R);
  cout << t << endl;

  return 0;
}

```

Here is the error :

```auto
test.cc: In function ‘int test()’:
test.cc:20:15: error: ‘Functor1D’ is not a member of ‘ROOT::Math’
   20 | ROOT::Math::Functor1D F(&Fermi);
      | ^ ~~~~~~~~

```

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [January 15, 2021, 11:33am UTC](https://root-forum.cern.ch/t/functor1d-is-not-a-member-of-root-math/43111/2 "2021-01-15T11:33:33Z")

</div>

You’d need to `#include "Math/Functor.h"` in order to make `ROOT::Math::Functor1D` available to the compiler. Note that in this case you also need a main function, something like

```auto
int main() {
  test();
}

```

You can run the macro unmodified interpreted with ROOT like

```auto
root test.cc

```

Note that you cannot use a function that takes a _pointer_ to a double for `Functor1D`. The `Fermi` function can take just a `double r` though.

---

<div class="post-metadata">

**Author:** ![newbie2](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/b4bc9f/32.png) [@newbie2](https://root-forum.cern.ch/u/newbie2)\
**Post date:** [January 15, 2021, 2:16pm UTC](https://root-forum.cern.ch/t/functor1d-is-not-a-member-of-root-math/43111/3 "2021-01-15T14:16:23Z")

</div>

Yeah I had forgotten to replace the `test()` with `main()` 😅. But inclusion of `Functor.h` makes the code work. Thanks for the help!
