gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool

#include <daFunk.hpp>

Inheritance diagram for daFunk::FunkBase:
Collaboration diagram for daFunk::FunkBase:

Public Member Functions

 FunkBase ()
 
virtual ~FunkBase ()
 
template<typename... Args>
Funk set (std::string arg, Funk g, Args... args)
 
template<typename... Args>
Funk set (std::string arg, double x, Args... args)
 
template<typename... Args>
Funk set (std::string arg, std::string arg1, Args... args)
 
template<typename... Args>
Funk set ()
 
template<typename... Args>
shared_ptr< FunkBoundbind (Args... args)
 
const std::vector< std::string > & getArgs ()
 
std::size_t getNArgs ()
 
bool hasArg (std::string)
 
bool hasArgs ()
 
Funk help ()
 
template<typename... Args>
bool assert_args (Args... args)
 
virtual double value (const std::vector< double > &, size_t bindID)=0
 
virtual void resolve (std::map< std::string, size_t > datamap, size_t &datalen, size_t bindID, std::map< std::string, size_t > &argmap)
 
Singularities getSingl ()
 
Funk set_singularity (std::string arg, double pos, double width)
 
Funk print (std::string arg)
 
template<typename... Args>
shared_ptr< FunkIntegrate_gsl1dgsl_integration (Args... args)
 
PlainPtrs1 plain (std::string)
 
PlainPtrs2 plain (std::string, std::string)
 
PlainPtrs3 plain (std::string, std::string, std::string)
 
PlainPtrs4 plain (std::string, std::string, std::string, std::string)
 
template<typename T >
PlainPtr1 plain (std::string)
 
template<typename T >
PlainPtr2 plain (std::string, std::string)
 
template<typename T >
PlainPtr3 plain (std::string, std::string, std::string)
 
template<typename T >
PlainPtr4 plain (std::string, std::string, std::string, std::string)
 
template<>
Funk set ()
 

Protected Attributes

std::vector< Funkfunctions
 
ArgsType arguments
 
std::vector< std::vector< size_t > > indices
 
size_t datalen
 
Singularities singularities
 

Private Member Functions

Funk set_singularity (std::string arg, Funk pos, Funk width)
 
Funk set_singularity (std::string arg, double pos, Funk width)
 
Funk set_singularity (std::string arg, Funk pos, double width)
 

Detailed Description

Definition at line 298 of file daFunk.hpp.

Constructor & Destructor Documentation

◆ FunkBase()

daFunk::FunkBase::FunkBase ( )
inline

Definition at line 301 of file daFunk.hpp.

301 {};

◆ ~FunkBase()

virtual daFunk::FunkBase::~FunkBase ( )
inlinevirtual

Definition at line 302 of file daFunk.hpp.

References find_all_gambit_bits::args, and g.

302 {};

Member Function Documentation

◆ assert_args()

template<typename... Args>
bool daFunk::FunkBase::assert_args ( Args...  args)
inline

Definition at line 989 of file daFunk.hpp.

References find_all_gambit_bits::args.

990  {
991  std::vector<std::vector<std::string>> list = vec<std::vector<std::string>>(args...);
992  std::set<std::string> myargs(arguments.begin(), arguments.end());
993  for ( auto it = list.begin(); it != list.end(); ++it )
994  {
995  std::set<std::string> theirargs(it->begin(), it->end());
996  if ( myargs == theirargs )
997  return true;
998  }
999  return false;
1000 
1001  }
ArgsType arguments
Definition: daFunk.hpp:369

◆ bind()

template<typename... Args>
shared_ptr< FunkBound > daFunk::FunkBase::bind ( Args...  args)
inline

Definition at line 1026 of file daFunk.hpp.

References daFunk::args_match(), daFunk::args_string(), daFunk::FunkBound::bindID_manager(), LOCAL_INFO, and Gambit::utils_error().

Referenced by daFunk::FunkBound::vect().

1027  {
1028  size_t bindID;
1029  FunkBound::bindID_manager(bindID,true);
1030  std::map<std::string, size_t> datamap;
1031  size_t i;
1032  auto bound_arguments = vec<std::string>(argss...);
1033  datalen = bound_arguments.size();
1034  i = 0;
1035  for ( auto it = bound_arguments.begin(); it != bound_arguments.end(); ++it, ++i )
1036  {
1037  datamap[*it] = i;
1038  }
1039  std::map<std::string,size_t> argmap;
1040  if ( not args_match(arguments, bound_arguments) )
1041  {
1042  std::string msg = "FunkBase::bind() tries to resolve wrong arguments.\n";
1043  msg+= " --- Arguments that are supposed to be bound: " + args_string(bound_arguments) + "\n";
1044  msg+= " --- Actual arguments of object: " + args_string(arguments);
1045 #ifdef GAMBIT_DIR
1046  Gambit::utils_error().raise(LOCAL_INFO, msg);
1047 #else
1048  throw std::invalid_argument(msg);
1049 #endif
1050  }
1051  this->resolve(datamap, datalen, bindID, argmap);
1052  return shared_ptr<FunkBound>(new FunkBound(shared_from_this(), datalen, bindID));
1053  }
EXPORT_SYMBOLS error & utils_error()
Utility errors.
virtual void resolve(std::map< std::string, size_t > datamap, size_t &datalen, size_t bindID, std::map< std::string, size_t > &argmap)
Definition: daFunk.hpp:940
ArgsType arguments
Definition: daFunk.hpp:369
std::string args_string(ArgsType args)
Definition: daFunk.hpp:216
bool args_match(ArgsType args1, ArgsType args2)
Definition: daFunk.hpp:204
#define LOCAL_INFO
Definition: local_info.hpp:34
static void bindID_manager(size_t &bindID, bool bind)
Definition: daFunk.hpp:417
size_t datalen
Definition: daFunk.hpp:371
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getArgs()

const std::vector<std::string>& daFunk::FunkBase::getArgs ( )
inline

Definition at line 314 of file daFunk.hpp.

314 { return this->arguments; };
ArgsType arguments
Definition: daFunk.hpp:369

◆ getNArgs()

std::size_t daFunk::FunkBase::getNArgs ( )
inline

Definition at line 315 of file daFunk.hpp.

References find_all_gambit_bits::args, and find_all_gambit_bits::help.

315 {return this->arguments.size();};
ArgsType arguments
Definition: daFunk.hpp:369

◆ getSingl()

Singularities daFunk::FunkBase::getSingl ( )
inline

Definition at line 334 of file daFunk.hpp.

References find_all_gambit_bits::args, and Gambit::ColliderBit::print().

334 { return singularities; }
Singularities singularities
Definition: daFunk.hpp:372
Here is the call graph for this function:

◆ gsl_integration()

template<typename... Args>
shared_ptr< FunkIntegrate_gsl1d > daFunk::FunkBase::gsl_integration ( Args...  args)
inline

Definition at line 1065 of file daFunk.hpp.

References find_all_gambit_bits::args, and daFunk::getIntegrate_gsl1d().

1066  {
1067  return getIntegrate_gsl1d(shared_from_this(), args...);
1068  }
shared_ptr< FunkIntegrate_gsl1d > getIntegrate_gsl1d(Funk fptr, std::string arg, T1 x1, T2 x2)
Definition: daFunk.hpp:1708
Here is the call graph for this function:

◆ hasArg()

bool daFunk::FunkBase::hasArg ( std::string  arg)
inline

Definition at line 1055 of file daFunk.hpp.

1056  {
1057  return ( std::find(arguments.begin(), arguments.end(), arg) != arguments.end() );
1058  }
ArgsType arguments
Definition: daFunk.hpp:369

◆ hasArgs()

bool daFunk::FunkBase::hasArgs ( )
inline

Definition at line 1060 of file daFunk.hpp.

1061  {
1062  return ( this->arguments.size() != 0 );
1063  }
ArgsType arguments
Definition: daFunk.hpp:369

◆ help()

Funk daFunk::FunkBase::help ( )
inline

Definition at line 1070 of file daFunk.hpp.

1071  {
1072  std::cout << "Arguments:";
1073  for ( auto it = arguments.begin(); it != arguments.end(); it++ )
1074  {
1075  std::cout << " \"" << *it << "\"";
1076  }
1077  if ( arguments.size() == 0 )
1078  std::cout << " none";
1079  std::cout << std::endl;
1080  for ( auto it = singularities.begin() ; it != singularities.end(); ++it )
1081  {
1082  std::cout << "Singularities in " << it->first << ": " << it->second.size() << std::endl;
1083  }
1084  return shared_from_this();
1085  }
ArgsType arguments
Definition: daFunk.hpp:369
Singularities singularities
Definition: daFunk.hpp:372

◆ plain() [1/8]

PlainPtrs1 daFunk::FunkBase::plain ( std::string  arg1)
inline

Definition at line 1087 of file daFunk.hpp.

References daFunk::FunkPlain::plain1p().

1088  {
1089  void* ptr = new FunkPlain(shared_from_this(), arg1);
1090  return PlainPtrs1(&FunkPlain::plain1p, ptr);
1091  }
std::pair< double(*)(double, void *), void * > PlainPtrs1
Definition: daFunk.hpp:129
static double plain1p(double x1, void *ptr)
Definition: daFunk.hpp:521
Here is the call graph for this function:

◆ plain() [2/8]

PlainPtrs2 daFunk::FunkBase::plain ( std::string  arg1,
std::string  arg2 
)
inline

Definition at line 1092 of file daFunk.hpp.

References daFunk::FunkPlain::plain2p().

1093  {
1094  void* ptr = new FunkPlain(shared_from_this(), arg1, arg2);
1095  return PlainPtrs2(&FunkPlain::plain2p, ptr);
1096  }
static double plain2p(double x1, double x2, void *ptr)
Definition: daFunk.hpp:526
std::pair< double(*)(double, double, void *), void * > PlainPtrs2
Definition: daFunk.hpp:130
Here is the call graph for this function:

◆ plain() [3/8]

PlainPtrs3 daFunk::FunkBase::plain ( std::string  arg1,
std::string  arg2,
std::string  arg3 
)
inline

Definition at line 1097 of file daFunk.hpp.

References daFunk::FunkPlain::plain3p().

1098  {
1099  void* ptr = new FunkPlain(shared_from_this(), arg1, arg2, arg3);
1100  return PlainPtrs3(&FunkPlain::plain3p, ptr);
1101  }
static double plain3p(double x1, double x2, double x3, void *ptr)
Definition: daFunk.hpp:531
std::pair< double(*)(double, double, double, void *), void * > PlainPtrs3
Definition: daFunk.hpp:131
Here is the call graph for this function:

◆ plain() [4/8]

PlainPtrs4 daFunk::FunkBase::plain ( std::string  arg1,
std::string  arg2,
std::string  arg3,
std::string  arg4 
)
inline

Definition at line 1102 of file daFunk.hpp.

References daFunk::FunkPlain::plain4p().

1103  {
1104  void* ptr = new FunkPlain(shared_from_this(), arg1, arg2, arg3, arg4);
1105  return PlainPtrs4(&FunkPlain::plain4p, ptr);
1106  }
std::pair< double(*)(double, double, double, double, void *), void * > PlainPtrs4
Definition: daFunk.hpp:132
static double plain4p(double x1, double x2, double x3, double x4, void *ptr)
Definition: daFunk.hpp:536
Here is the call graph for this function:

◆ plain() [5/8]

template<typename T >
PlainPtr1 daFunk::FunkBase::plain ( std::string  arg1)
inline

Definition at line 1109 of file daFunk.hpp.

1110  {
1111  T::set(new FunkPlain(shared_from_this(), arg1));
1112  return &FunkPlain::plain1<T>;
1113  }

◆ plain() [6/8]

template<typename T >
PlainPtr2 daFunk::FunkBase::plain ( std::string  arg1,
std::string  arg2 
)
inline

Definition at line 1115 of file daFunk.hpp.

1116  {
1117  T::set(new FunkPlain(shared_from_this(), arg1, arg2));
1118  return &FunkPlain::plain2<T>;
1119  }

◆ plain() [7/8]

template<typename T >
PlainPtr3 daFunk::FunkBase::plain ( std::string  arg1,
std::string  arg2,
std::string  arg3 
)
inline

Definition at line 1121 of file daFunk.hpp.

1122  {
1123  T::set(new FunkPlain(shared_from_this(), arg1, arg2, arg3));
1124  return &FunkPlain::plain3<T>;
1125  }

◆ plain() [8/8]

template<typename T >
PlainPtr4 daFunk::FunkBase::plain ( std::string  arg1,
std::string  arg2,
std::string  arg3,
std::string  arg4 
)
inline

Definition at line 1127 of file daFunk.hpp.

1128  {
1129  T::set(new FunkPlain(shared_from_this(), arg1, arg2, arg3, arg4));
1130  return &FunkPlain::plain4<T>;
1131  }

◆ print()

Funk daFunk::FunkBase::print ( std::string  arg)
inline

Definition at line 1467 of file daFunk.hpp.

1468  { return Funk(new Bottle(shared_from_this(), msg)); };
shared_ptr< FunkBase > Funk
Definition: daFunk.hpp:113

◆ resolve()

void daFunk::FunkBase::resolve ( std::map< std::string, size_t >  datamap,
size_t &  datalen,
size_t  bindID,
std::map< std::string, size_t > &  argmap 
)
inlinevirtual

Reimplemented in daFunk::FunkIntegrate_gsl1d, and daFunk::FunkDerived.

Definition at line 940 of file daFunk.hpp.

References daFunk::args_string(), LOCAL_INFO, and Gambit::utils_error().

941  {
942  // Resolve my dependencies
943  auto it1 = arguments.begin();
944  std::vector<size_t> tmp_indices;
945  tmp_indices.resize(arguments.size());
946  auto it2 = tmp_indices.begin();
947  for (; it1 != arguments.end() && it2 != tmp_indices.end(); ++it1, ++it2 )
948  {
949  try
950  {
951  *it2 = datamap.at(*it1);
952  }
953  catch (std::out_of_range & e)
954  {
955  std::string msg = "FunkBase::resolve() encountered internal problem when resolving " + *it1 + ".\n";
956  msg+= " --- Actual arguments of object: " + args_string(arguments);
957 #ifdef GAMBIT_DIR
958  Gambit::utils_error().raise(LOCAL_INFO, msg);
959 #else
960  throw std::invalid_argument(msg);
961 #endif
962  }
963  }
964 
965  // Set indices
966  if(indices.size() <= bindID)
967  {
968  indices.resize(bindID+1);
969  // TODO: Throw error if problems are encountered
970  //std::cout << "FATAL ERROR: bind() attempts to resolve dependencies of FunkBase" << std::endl;
971  //std::cout << "object inconsistently." << std::endl;
972  //std::cout << "Encountered while resolving: " << std::endl;
973  //for (auto it = datamap.begin(); it != datamap.end(); it++)
974  //{
975  // std::cout << " " << it->first << std::endl;
976  //}
977  //exit(1);
978  }
979  indices[bindID] = tmp_indices;
980 
981  // Resolve other dependencies
982  for (auto it = functions.begin(); it != functions.end(); ++it)
983  {
984  (*it)->resolve(datamap, datalen, bindID, argmap);
985  }
986 
987  }
EXPORT_SYMBOLS error & utils_error()
Utility errors.
ArgsType arguments
Definition: daFunk.hpp:369
std::string args_string(ArgsType args)
Definition: daFunk.hpp:216
#define LOCAL_INFO
Definition: local_info.hpp:34
std::vector< Funk > functions
Definition: daFunk.hpp:368
std::vector< std::vector< size_t > > indices
Definition: daFunk.hpp:370
size_t datalen
Definition: daFunk.hpp:371
Here is the call graph for this function:

◆ set() [1/5]

template<typename... Args>
Funk daFunk::FunkBase::set ( std::string  arg,
Funk  g,
Args...  args 
)
inline

Definition at line 1003 of file daFunk.hpp.

References find_all_gambit_bits::args.

1004  {
1005  Funk f = shared_from_this();
1006  if ( std::find(arguments.begin(), arguments.end(), arg) != arguments.end() )
1007  {
1008  f = Funk(new FunkDerived(f, arg, g));
1009  }
1010  else
1011  {
1012  std::cout << "daFunk::FunkBase WARNING: Ignoring \"" << arg << "\" = function." << std::endl;
1013  }
1014  return f->set(args...);
1015  }
ArgsType arguments
Definition: daFunk.hpp:369
shared_ptr< FunkBase > Funk
Definition: daFunk.hpp:113

◆ set() [2/5]

template<typename... Args>
Funk daFunk::FunkBase::set ( std::string  arg,
double  x,
Args...  args 
)
inline

Definition at line 1020 of file daFunk.hpp.

References find_all_gambit_bits::args, and daFunk::cnst().

1021  { return shared_from_this()->set(arg, cnst(x))->set(args...); }
Funk cnst(double x, Args... argss)
Definition: daFunk.hpp:606
Here is the call graph for this function:

◆ set() [3/5]

template<typename... Args>
Funk daFunk::FunkBase::set ( std::string  arg,
std::string  arg1,
Args...  args 
)
inline

Definition at line 1017 of file daFunk.hpp.

References find_all_gambit_bits::args, and daFunk::var().

1018  { return shared_from_this()->set(arg, var(arg1))->set(args...); }
Funk var(std::string arg)
Definition: daFunk.hpp:921
Here is the call graph for this function:

◆ set() [4/5]

template<typename... Args>
Funk daFunk::FunkBase::set ( )

◆ set() [5/5]

template<>
Funk daFunk::FunkBase::set ( )
inline

Definition at line 1023 of file daFunk.hpp.

1024  { return shared_from_this(); }

◆ set_singularity() [1/4]

Funk daFunk::FunkBase::set_singularity ( std::string  arg,
Funk  pos,
Funk  width 
)
inlineprivate

Definition at line 928 of file daFunk.hpp.

929  {
930  singularities[arg].push_back(std::pair<Funk, Funk>(pos, width));
931  return shared_from_this();
932  };
Singularities singularities
Definition: daFunk.hpp:372

◆ set_singularity() [2/4]

Funk daFunk::FunkBase::set_singularity ( std::string  arg,
double  pos,
Funk  width 
)
inlineprivate

Definition at line 933 of file daFunk.hpp.

References daFunk::cnst().

934  { return shared_from_this()->set_singularity(arg, cnst(pos), width); }
Funk cnst(double x, Args... argss)
Definition: daFunk.hpp:606
Here is the call graph for this function:

◆ set_singularity() [3/4]

Funk daFunk::FunkBase::set_singularity ( std::string  arg,
Funk  pos,
double  width 
)
inlineprivate

Definition at line 937 of file daFunk.hpp.

References daFunk::cnst().

938  { return shared_from_this()->set_singularity(arg, pos, cnst(width)); }
Funk cnst(double x, Args... argss)
Definition: daFunk.hpp:606
Here is the call graph for this function:

◆ set_singularity() [4/4]

Funk daFunk::FunkBase::set_singularity ( std::string  arg,
double  pos,
double  width 
)
inline

Definition at line 935 of file daFunk.hpp.

References daFunk::cnst().

936  { return shared_from_this()->set_singularity(arg, cnst(pos), cnst(width)); }
Funk cnst(double x, Args... argss)
Definition: daFunk.hpp:606
Here is the call graph for this function:

◆ value()

Member Data Documentation

◆ arguments

ArgsType daFunk::FunkBase::arguments
protected

Definition at line 369 of file daFunk.hpp.

◆ datalen

size_t daFunk::FunkBase::datalen
protected

Definition at line 371 of file daFunk.hpp.

◆ functions

std::vector<Funk> daFunk::FunkBase::functions
protected

Definition at line 368 of file daFunk.hpp.

Referenced by daFunk::FunkIntegrate_gsl1d::invoke().

◆ indices

std::vector<std::vector<size_t> > daFunk::FunkBase::indices
protected

Definition at line 370 of file daFunk.hpp.

◆ singularities

Singularities daFunk::FunkBase::singularities
protected

Definition at line 372 of file daFunk.hpp.


The documentation for this class was generated from the following file: