LHAPDF  6.5.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Interpolator.h
1 // -*- C++ -*-
2 //
3 // This file is part of LHAPDF
4 // Copyright (C) 2012-2022 The LHAPDF collaboration (see AUTHORS for details)
5 //
6 #pragma once
7 #ifndef LHAPDF_Interpolator_H
8 #define LHAPDF_Interpolator_H
9 
10 #include "LHAPDF/Utils.h"
11 #include "LHAPDF/KnotArray.h"
12 
13 namespace LHAPDF {
14 
15 
16  // Forward declaration
17  class GridPDF;
18 
19 
21  class Interpolator {
22  public:
23 
25  virtual ~Interpolator() { }
26 
27 
30 
32  void bind(const GridPDF* pdf) { _pdf = pdf; }
33 
35  void unbind() { _pdf = 0; }
36 
38  bool hasPDF() { return _pdf != 0; }
39 
41  const GridPDF& pdf() const { return *_pdf; }
42 
44 
45 
48 
50  double interpolateXQ(int id, double x, double q) const {
51  return interpolateXQ2(id, x, q*q);
52  }
53 
55  double interpolateXQ2(int id, double x, double q2) const;
56 
57  void interpolateXQ2(double x, double q2, std::vector<double>& ret) const;
58 
60 
62 
63  void setType(std::string t){
64  _type = t;
65  }
66 
67  std::string getType(){
68  return _type;
69  }
70 
71 
72 
73  protected:
74 
81  virtual double _interpolateXQ2(const KnotArray& grid, double x, size_t ix, double q2, size_t iq2, int id) const = 0;
82 
83  virtual void _interpolateXQ2(const KnotArray& grid, double x, size_t ix, double q2, size_t iq2, std::vector<double>& ret) const = 0;
84 
85 
86  private:
87  const GridPDF* _pdf;
88  std::string _type;
89  };
90 
91 
92 }
93 
94 #endif
bool hasPDF()
Identify whether this Interpolator has an associated PDF.
Definition: Interpolator.h:38
virtual ~Interpolator()
Destructor to allow inheritance.
Definition: Interpolator.h:25
double interpolateXQ(int id, double x, double q) const
Interpolate a single-point in (x,Q)
Definition: Interpolator.h:50
void bind(const GridPDF *pdf)
Bind to a GridPDF.
Definition: Interpolator.h:32
virtual double _interpolateXQ2(const KnotArray &grid, double x, size_t ix, double q2, size_t iq2, int id) const =0
Interpolate a single-point in (x,Q2), given x/Q2 values and subgrid indices.
A PDF defined via an interpolation grid.
Definition: GridPDF.h:19
void unbind()
Unbind from GridPDF.
Definition: Interpolator.h:35
The general interface for interpolating between grid points.
Definition: Interpolator.h:21
void setType(std::string t)
Definition: Interpolator.h:63
const GridPDF & pdf() const
Get the associated GridPDF.
Definition: Interpolator.h:41
double interpolateXQ2(int id, double x, double q2) const
Interpolate a single-point in (x,Q2)