LHAPDF  6.3.0
LogBicubicInterpolator.h
1 // -*- C++ -*-
2 //
3 // This file is part of LHAPDF
4 // Copyright (C) 2012-2020 The LHAPDF collaboration (see AUTHORS for details)
5 //
6 #pragma once
7 #ifndef LHAPDF_LogBicubicInterpolator_H
8 #define LHAPDF_LogBicubicInterpolator_H
9 
10 #include "LHAPDF/Interpolator.h"
11 
12 namespace LHAPDF {
13 
14 
19  public:
20 
22  double _interpolateXQ2(const KnotArray1F& subgrid, double x, size_t ix, double q2, size_t iq2) const;
23 
25  struct XCache {
27  double x = -1;
28  //size_t ix;
29 
31  double logx;
32  double dlogx_1;
33  double tlogx;
34  };
35 
37  struct XCaches {
38 
40  static size_t SIZE;
42  static int UPDATE_STEP;
44  static bool UPDATE_ON_HIT;
45 
47  static void setup(size_t size, int update_step=+1, bool update_on_hit=true);
49  static void init();
50 
52  size_t ilast = 0;
53 
55  vector<XCache> caches{SIZE};
56 
58  size_t size() { return caches.size(); }
59 
61  XCache& operator[] (size_t index) { return caches[index]; }
62 
63  };
64 
65 
67  struct Q2Cache {
69  double q2 = -1;
70 
72  double logq2;
73  double dlogq_0;
74  double dlogq_1;
75  double dlogq_2;
76  double tlogq;
77  };
78 
80  struct Q2Caches {
81 
83  static size_t SIZE;
85  static int UPDATE_STEP;
87  static bool UPDATE_ON_HIT;
88 
90  static void setup(size_t size, int update_step=+1, bool update_on_hit=true);
92  static void init();
93 
95  size_t ilast = 0;
96 
98  vector<Q2Cache> caches{SIZE};
99 
101  size_t size() { return caches.size(); }
102 
104  Q2Cache& operator[] (size_t index) { return caches[index]; }
105 
106  };
107 
108 
113  static XCache& _getCacheX(const KnotArray1F& subgrid, double x, size_t ix);
114  static Q2Cache& _getCacheQ2(const KnotArray1F& subgrid, double q2, size_t iq2);
116 
117  };
118 
119 
120 }
121 
122 #endif
LHAPDF::LogBicubicInterpolator
Implementation of bicubic interpolation.
Definition: LogBicubicInterpolator.h:18
LHAPDF::LogBicubicInterpolator::Q2Cache::q2
double q2
Defining params from call (initialised to unphysical values, so first use will set the cache)
Definition: LogBicubicInterpolator.h:69
LHAPDF::KnotArray1F
Internal storage class for PDF data point grids.
Definition: KnotArray.h:20
LHAPDF::LogBicubicInterpolator::XCaches::UPDATE_ON_HIT
static bool UPDATE_ON_HIT
Cache access strategy.
Definition: LogBicubicInterpolator.h:44
LHAPDF::LogBicubicInterpolator::XCaches::init
static void init()
Initialize a cache on this thread (call with explicit locks to ensure safe initialisation for each th...
LHAPDF::LogBicubicInterpolator::Q2Caches::size
size_t size()
Get the length of the cache vector.
Definition: LogBicubicInterpolator.h:101
LHAPDF::LogBicubicInterpolator::Q2Caches::init
static void init()
Initialize a cache on this thread (call with explicit locks to ensure safe initialisation for each th...
LHAPDF::LogBicubicInterpolator::Q2Caches::setup
static void setup(size_t size, int update_step=+1, bool update_on_hit=true)
(Re)define cache size and search strategy
LHAPDF::LogBicubicInterpolator::XCaches::setup
static void setup(size_t size, int update_step=+1, bool update_on_hit=true)
(Re)define cache size and search strategy
LHAPDF::LogBicubicInterpolator::_getCacheX
static XCache & _getCacheX(const KnotArray1F &subgrid, double x, size_t ix)
Get and update the current caching structs for interpolation params.
LHAPDF::LogBicubicInterpolator::Q2Caches::SIZE
static size_t SIZE
Number of cache levels.
Definition: LogBicubicInterpolator.h:83
LHAPDF::LogBicubicInterpolator::_interpolateXQ2
double _interpolateXQ2(const KnotArray1F &subgrid, double x, size_t ix, double q2, size_t iq2) const
Implementation of (x,Q2) interpolation.
LHAPDF::LogBicubicInterpolator::XCaches::ilast
size_t ilast
Latest-call index.
Definition: LogBicubicInterpolator.h:52
LHAPDF::LogBicubicInterpolator::Q2Caches::ilast
size_t ilast
Latest-call index.
Definition: LogBicubicInterpolator.h:95
LHAPDF::LogBicubicInterpolator::Q2Caches
A multi-level Q2-variable cache for a single subgrid hash.
Definition: LogBicubicInterpolator.h:80
LHAPDF::LogBicubicInterpolator::Q2Caches::UPDATE_STEP
static int UPDATE_STEP
Cache access strategy.
Definition: LogBicubicInterpolator.h:85
LHAPDF::LogBicubicInterpolator::Q2Caches::operator[]
Q2Cache & operator[](size_t index)
Access the index'th element of the cache.
Definition: LogBicubicInterpolator.h:104
LHAPDF::LogBicubicInterpolator::XCaches::caches
vector< XCache > caches
List of N cached-value sets.
Definition: LogBicubicInterpolator.h:55
LHAPDF::LogBicubicInterpolator::XCaches::SIZE
static size_t SIZE
Number of cache levels.
Definition: LogBicubicInterpolator.h:40
LHAPDF::LogBicubicInterpolator::XCaches::UPDATE_STEP
static int UPDATE_STEP
Cache access strategy.
Definition: LogBicubicInterpolator.h:42
LHAPDF::LogBicubicInterpolator::XCache::logx
double logx
Cached params.
Definition: LogBicubicInterpolator.h:31
LHAPDF::Interpolator
The general interface for interpolating between grid points.
Definition: Interpolator.h:21
LHAPDF::LogBicubicInterpolator::XCaches::operator[]
XCache & operator[](size_t index)
Access the index'th element of the cache.
Definition: LogBicubicInterpolator.h:61
LHAPDF::LogBicubicInterpolator::Q2Cache
A single set of cached Q2-variables.
Definition: LogBicubicInterpolator.h:67
LHAPDF::LogBicubicInterpolator::XCache::x
double x
Defining params from call (initialised to unphysical values, so first use will set the cache)
Definition: LogBicubicInterpolator.h:27
LHAPDF::LogBicubicInterpolator::XCache
A single set of cached x-variables.
Definition: LogBicubicInterpolator.h:25
LHAPDF::LogBicubicInterpolator::XCaches
A multi-level x-variable cache for a single subgrid hash.
Definition: LogBicubicInterpolator.h:37
LHAPDF::LogBicubicInterpolator::XCaches::size
size_t size()
Get the length of the cache vector.
Definition: LogBicubicInterpolator.h:58
LHAPDF::LogBicubicInterpolator::Q2Caches::caches
vector< Q2Cache > caches
List of N cached-value sets.
Definition: LogBicubicInterpolator.h:98
LHAPDF
Namespace for all LHAPDF functions and classes.
Definition: AlphaS.h:14
LHAPDF::LogBicubicInterpolator::Q2Cache::logq2
double logq2
Cached params.
Definition: LogBicubicInterpolator.h:72
LHAPDF::LogBicubicInterpolator::Q2Caches::UPDATE_ON_HIT
static bool UPDATE_ON_HIT
Cache access strategy.
Definition: LogBicubicInterpolator.h:87