FunctionGenerator

class FunctionGenerator

Base class for compute-graph functions that are not invertible mappings.

A FunctionGenerator builds a Function from named Arguments to named Returns. Unlike Mapping it has no inverse and produces no Jacobian weight. It is used for the pieces of the integrand that only need to be evaluated in one direction: cuts, observables, histograms, matrix elements, PDF and scale evaluation, and the trainable networks. Concrete subclasses list their arguments and returns individually. Subclasses may be written in Python by deriving from this class.

References

Subclassed by madspace::BatchSampler, madspace::BufferUnweighter, madspace::ChannelWeightNetwork, madspace::CustomFunction, madspace::Cuts, madspace::DifferentialCrossSection, madspace::DiscreteHistogram, madspace::EnergyScale, madspace::GradientClipper, madspace::Integrand, madspace::IntegrandChannelPart, madspace::IntegrandCommonPart, madspace::IntegrandConcatenator, madspace::IntegrandProbability, madspace::MLP, madspace::MadnisLoss, madspace::MatrixElement, madspace::MomentumPreprocessing, madspace::MultiChannelFunction, madspace::MultiChannelIntegrand, madspace::Observable, madspace::ObservableHistograms, madspace::ObservableValues, madspace::PartonDensity, madspace::PropagatorChannelWeights, madspace::RunningCoupling, madspace::SubchannelWeights, madspace::Unweighter, madspace::VegasHistogram

Public Functions

inline FunctionGenerator(const std::string &name, const NamedVector<Type> &arg_types, const NamedVector<Type> &return_types)
Parameters:
  • name – Identifier used for the generated compute graph.

  • arg_types – Types of the values consumed by the function.

  • return_types – Types of the values produced by the function.

virtual ~FunctionGenerator() = default
NamedVector<Value> build_function(FunctionBuilder &fb, const NamedVector<Value> &args) const

Add the function to fb and return its named results.

The positional overload attaches names from arg_types().

inline NamedVector<Value> build_function(FunctionBuilder &fb, const ValueVec &args) const

Add the function to fb and return its named results.

The positional overload attaches names from arg_types().

Function function() const

Build a standalone Function.

inline const NamedVector<Type> &arg_types() const

Types of the function arguments.

inline const NamedVector<Type> &return_types() const

Types of the function returns.

inline const std::string &name() const

Compute-graph identifier passed to the constructor.