5#ifndef MADNESS_MRA_KERNELRANGE_H__INCLUDED
6#define MADNESS_MRA_KERNELRANGE_H__INCLUDED
46 N = std::numeric_limits<int>::max();
51 [[nodiscard]]
bool infinite()
const {
return N == std::numeric_limits<int>::max();}
54 explicit operator bool()
const {
return static_cast<bool>(
N); }
98 auto f = [](
double x,
double ooσ) {
99 return (1 + std::erf(x * ooσ)) * 0.5;
150 unsigned int N()
const {
return data.value().N; }
164 explicit operator bool()
const {
return finite(); }
201 return std::numeric_limits<int>::max();
233 constexpr bool use_newton_solver =
false;
234 if (use_newton_solver) {
238 const auto arg = (0.5 *
N - x) * ooσ;
239 const auto fx = (1 + std::erf(
arg)) * 0.5;
240 const auto dfx = -std::exp(-
arg *
arg) * oosqrtpiσ;
241 return std::make_pair(fx, dfx);
244 const auto max_iter = 50;
252 std::tie(fx, dfx) = f01(x);
254 auto restricted_step = [](
const double step,
255 const double maxabs_step) {
256 auto sign = [](
const auto x) {
return x >= 0 ? 1. : -1.; };
257 return std::abs(step) > maxabs_step ? sign(step) * maxabs_step
260 x += restricted_step(dx, 0.2);
263 return static_cast<int>(ceil(x * 2.));
267 auto value = [&](
const double r) {
271 double fx =
value(x * 0.5);
Definition kernelrange.h:60
const Restrictor & restrictor() const
Definition kernelrange.h:287
bool finite_soft() const
Definition kernelrange.h:159
Type type() const
Definition kernelrange.h:151
static constexpr double extent_default_epsilon
Definition kernelrange.h:194
double sigma() const
Definition kernelrange.h:152
friend bool operator==(const KernelRange &r1, const KernelRange &r2)
Definition kernelrange.h:167
int iextent_x2(double epsilon=extent_default_epsilon) const
Definition kernelrange.h:198
hashT hash() const
Definition kernelrange.h:185
bool infinite() const
Definition kernelrange.h:161
bool finite() const
Definition kernelrange.h:155
KernelRange(unsigned int N)
Definition kernelrange.h:148
unsigned int N() const
Definition kernelrange.h:150
Type
types of range restrictor functions
Definition kernelrange.h:64
@ Hard
Heavyside (step) function: .
Definition kernelrange.h:66
@ SoftErf
Definition kernelrange.h:69
double value(double r) const
Definition kernelrange.h:176
KernelRange(unsigned int N, double sigma)
Definition kernelrange.h:139
std::optional< Data > data
Definition kernelrange.h:286
bool finite_hard() const
Definition kernelrange.h:157
Denotes lattice summation over range [-N, N]; N=0 is equivalent to including the simulation cell only...
Definition kernelrange.h:17
LatticeRange()=default
constructs [0,0]
LatticeRange(int n)
constructs [-n,n]
Definition kernelrange.h:24
LatticeRange & set_range(int n)
Definition kernelrange.h:34
LatticeRange(bool lattice_sum)
Definition kernelrange.h:28
bool infinite() const
Definition kernelrange.h:51
int N
lattice sum over [-N, N]; total # of cells = 2N + 1
Definition kernelrange.h:19
int get_range() const
Definition kernelrange.h:41
LatticeRange & set_infinite()
Definition kernelrange.h:45
static double epsilon
Definition dirac-hatom.cc:20
Tensor< typename Tensor< T >::scalar_type > arg(const Tensor< T > &t)
Return a new tensor holding the argument of each element of t (complex types only)
Definition tensor.h:2518
Defines madness::MadnessException for exception handling.
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
array_of_bools< NDIM > lattice_sum()
Definition bc.h:248
static double r2(const coord_3d &x)
Definition smooth.h:45
void hash_combine(hashT &seed, const T &v)
Combine hash values.
Definition worldhash.h:260
NDIM & f
Definition mra.h:2528
std::size_t hashT
The hash value type.
Definition worldhash.h:145
madness::hashT hash_value(const std::array< T, N > &a)
Hash std::array with madness hash.
Definition array_addons.h:78
static long abs(long a)
Definition tensor.h:218
Definition test_ccpairfunction.cc:22
Definition kernelrange.h:209
Restrictor restrictor
Definition kernelrange.h:211
static int compute_iextent_x2(int N, const Restrictor &restrictor, double epsilon)
Definition kernelrange.h:227
int iextent_x2(double epsilon) const
Definition kernelrange.h:218
unsigned int N
Definition kernelrange.h:210
Data(unsigned int n, Restrictor r)
Definition kernelrange.h:214
int iextent_x2_default
Definition kernelrange.h:212
restrictor function
Definition kernelrange.h:73
Restrictor(Type type=Hard, double sigma=1.0)
Definition kernelrange.h:76
double sigma_inverse() const
Definition kernelrange.h:91
double sigma() const
Definition kernelrange.h:87
std::optional< std::pair< double, double > > sigma_w_inverse_
Definition kernelrange.h:129
double value(double x) const
Definition kernelrange.h:97
hashT hash() const
Definition kernelrange.h:120
Type type_
Definition kernelrange.h:128
friend bool operator==(const Restrictor &r1, const Restrictor &r2)
Definition kernelrange.h:114
Type type() const
Definition kernelrange.h:86
Defines hash functions for use in distributed containers.