WrappedTF1.h bug


ROOT From heads/master@v6-35-01-548-ga560ca093a


In file included from /Users/chenxu/software/ROOT/install/include/Math/WrappedTF1.h:19:
/Users/chenxu/software/ROOT/install/include/TF1.h:764:73: error: no matching function for call to 'GetTheRightOp'
  764 |          using Fnc_t = typename ROOT::Internal::GetFunctorType<decltype(ROOT::Internal::GetTheRightOp(&Func::operator()))>::type;
      |                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/chenxu/software/ROOT/install/include/TF1.h:401:41: note: in instantiation of member function 'ROOT::Internal::TF1Builder<(lambda at /Users/chenxu/software/chenxufunc/git/cxStats.cc:67:7)>::Build' requested here
  401 |       ROOT::Internal::TF1Builder<Func>::Build(this, f);
      |                                         ^
/Users/chenxu/software/chenxufunc/git/cxStats.cc:65:7: note: in instantiation of function template specialization 'TF1::TF1<(lambda at /Users/chenxu/software/chenxufunc/git/cxStats.cc:67:7)>' requested here
   65 |   TF1 f1(
      |       ^
/Users/chenxu/software/ROOT/install/include/TF1.h:225:12: note: candidate template ignored: deduced conflicting types for parameter 'T' ('double' vs. 'const double')
  225 |       auto GetTheRightOp(T(F::*opPtr)(T *, double *) const) -> decltype(opPtr)
      |            ^
/Users/chenxu/software/ROOT/install/include/TF1.h:207:12: note: candidate template ignored: could not match 'T (const T *, const double *)' against 'double (const double *, double *) const'
  207 |       auto GetTheRightOp(T(F::*opPtr)(const T *, const double *)) -> decltype(opPtr)
      |            ^
/Users/chenxu/software/ROOT/install/include/TF1.h:213:12: note: candidate template ignored: could not match 'const double *' against 'double *'
  213 |       auto GetTheRightOp(T(F::*opPtr)(const T *, const double *) const) -> decltype(opPtr)
      |            ^
/Users/chenxu/software/ROOT/install/include/TF1.h:219:12: note: candidate template ignored: could not match 'T (T *, double *)' against 'double (const double *, double *) const'
  219 |       auto GetTheRightOp(T(F::*opPtr)(T *, double *)) -> decltype(opPtr)
      |            ^
/Users/chenxu/software/ROOT/install/include/TF1.h:764:73: error: no matching function for call to 'GetTheRightOp'
  764 |          using Fnc_t = typename ROOT::Internal::GetFunctorType<decltype(ROOT::Internal::GetTheRightOp(&Func::operator()))>::type;
      |                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/chenxu/software/ROOT/install/include/TF1.h:401:41: note: in instantiation of member function 'ROOT::Internal::TF1Builder<(lambda at /Users/chenxu/software/chenxufunc/git/cxStats.cc:82:7)>::Build' requested here
  401 |       ROOT::Internal::TF1Builder<Func>::Build(this, f);
      |                                         ^
/Users/chenxu/software/chenxufunc/git/cxStats.cc:80:7: note: in instantiation of function template specialization 'TF1::TF1<(lambda at /Users/chenxu/software/chenxufunc/git/cxStats.cc:82:7)>' requested here
   80 |   TF1 f1(
      |       ^
/Users/chenxu/software/ROOT/install/include/TF1.h:213:12: note: candidate template ignored: cannot deduce a type for 'T' that would make 'const T' equal 'double'
  213 |       auto GetTheRightOp(T(F::*opPtr)(const T *, const double *) const) -> decltype(opPtr)
      |            ^
/Users/chenxu/software/ROOT/install/include/TF1.h:207:12: note: candidate template ignored: could not match 'T (const T *, const double *)' against 'double (double *, const double *) const'
  207 |       auto GetTheRightOp(T(F::*opPtr)(const T *, const double *)) -> decltype(opPtr)
      |            ^
/Users/chenxu/software/ROOT/install/include/TF1.h:219:12: note: candidate template ignored: could not match 'T (T *, double *)' against 'double (double *, const double *) const'
  219 |       auto GetTheRightOp(T(F::*opPtr)(T *, double *)) -> decltype(opPtr)
      |            ^
/Users/chenxu/software/ROOT/install/include/TF1.h:225:12: note: candidate template ignored: could not match 'double *' against 'const double *'
  225 |       auto GetTheRightOp(T(F::*opPtr)(T *, double *) const) -> decltype(opPtr)

Hi,

Thanks for reporting. Could you please share the recipe to reproduce the issue?

Cheers,
Danilo

using macos.

// cspell:disable
#include <Math/BrentRootFinder.h>
#include <Math/WrappedTF1.h>
#include <TF1.h>
#include <TMath.h>
#include <TROOT.h>
#include <TSystem.h>
#include <fstream>
#include <iostream>


using namespace TMath;
using namespace std;


double FindRoot(double a, double non, double noff) {
  double wmin = a;
  double b = a;
  double n = a;
  TF1 f1(
      "f1",
      [a, wmin, b](const double* x, double*) {
        double w = x[0];
        return (1 - w) * (1 + a) - pow(wmin / w, b);
      },
      wmin / a, non / n, 0);
  ROOT::Math::WrappedTF1 wf1(f1);
  ROOT::Math::BrentRootFinder brf;
  brf.SetFunction(wf1, non / n, 1);
  brf.Solve();
  return brf.Root();
}
g++ cxStats.cc -c `root-config --libs --cflags`

meets the errors.

sorry I mistakes.

The TF1 function paramaters should not marked as const.
remove const solved the problem.

1 Like

Hey no problem: thanks for posting and sharing the solution with everybody!

Cheers,
D

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.