CLASSpp Manual
Cosmology reference and developer manual
Loading...
Searching...
No Matches
bessel_table_cache.h
1
#ifndef BESSEL_TABLE_CACHE_H
2
#define BESSEL_TABLE_CACHE_H
3
4
#include <memory>
5
#include <mutex>
6
#include <vector>
7
8
#include "hyperspherical.h"
9
26
class
BesselTableCache
{
27
public
:
30
std::shared_ptr<const HyperInterpStruct>
Get
(
const
std::vector<int>& l,
31
double
xmin,
32
double
xmax,
33
double
sampling,
34
int
l_WKB,
35
double
phiminabs) {
36
std::scoped_lock guard(mutex_);
37
const
bool
reusable = table_ && l == l_ && xmin == xmin_ && sampling == sampling_ &&
38
l_WKB == l_WKB_ && phiminabs == phiminabs_ && table_->x.back() >= xmax;
39
if
(!reusable) {
40
/* With some headroom, so that the next cosmology, which may need a little more x, can
41
reuse it too. The headroom adds nodes, it does not move them. */
42
table_ = std::make_shared<const HyperInterpStruct>(
43
HyperInterpStruct::OnFixedSpacing(0,
44
1.,
45
static_cast<
int
>
(l.size()),
46
l.data(),
47
xmin,
48
kHeadroom * xmax,
49
sampling,
50
l_WKB,
51
phiminabs));
52
l_ = l;
53
xmin_ = xmin;
54
sampling_ = sampling;
55
l_WKB_ = l_WKB;
56
phiminabs_ = phiminabs;
57
}
58
return
table_;
59
}
60
61
private
:
62
static
constexpr
double
kHeadroom = 1.05;
63
64
std::mutex mutex_;
65
std::shared_ptr<const HyperInterpStruct> table_;
66
std::vector<int> l_;
67
double
xmin_ = 0.;
68
double
sampling_ = 0.;
69
int
l_WKB_ = 0;
70
double
phiminabs_ = 0.;
71
};
72
73
#endif
// BESSEL_TABLE_CACHE_H
BesselTableCache
Definition
bessel_table_cache.h:26
BesselTableCache::Get
std::shared_ptr< const HyperInterpStruct > Get(const std::vector< int > &l, double xmin, double xmax, double sampling, int l_WKB, double phiminabs)
Definition
bessel_table_cache.h:30
include
bessel_table_cache.h
Generated by
1.9.8