5#ifndef MADNESS_MRA_KERNELRANGE_H__INCLUDED
6#define MADNESS_MRA_KERNELRANGE_H__INCLUDED
57 auto f = [](
double x,
double ooσ) {
58 return (1 + std::erf(x * ooσ)) * 0.5;
109 unsigned int N()
const {
return data.value().N; }
123 explicit operator bool()
const {
return finite(); }
160 return std::numeric_limits<int>::max();
192 constexpr bool use_newton_solver =
false;
193 if (use_newton_solver) {
197 const auto arg = (0.5 *
N - x) * ooσ;
198 const auto fx = (1 + std::erf(
arg)) * 0.5;
199 const auto dfx = -std::exp(-
arg *
arg) * oosqrtpiσ;
200 return std::make_pair(fx, dfx);
203 const auto max_iter = 50;
211 std::tie(fx, dfx) = f01(x);
213 auto restricted_step = [](
const double step,
214 const double maxabs_step) {
215 auto sign = [](
const auto x) {
return x >= 0 ? 1. : -1.; };
216 return std::abs(step) > maxabs_step ? sign(step) * maxabs_step
219 x += restricted_step(dx, 0.2);
222 return static_cast<int>(ceil(x * 2.));
226 auto value = [&](
const double r) {
230 double fx =
value(x * 0.5);
Definition kernelrange.h:19
const Restrictor & restrictor() const
Definition kernelrange.h:246
bool finite_soft() const
Definition kernelrange.h:118
Type type() const
Definition kernelrange.h:110
static constexpr double extent_default_epsilon
Definition kernelrange.h:153
double sigma() const
Definition kernelrange.h:111
friend bool operator==(const KernelRange &r1, const KernelRange &r2)
Definition kernelrange.h:126
int iextent_x2(double epsilon=extent_default_epsilon) const
Definition kernelrange.h:157
hashT hash() const
Definition kernelrange.h:144
bool infinite() const
Definition kernelrange.h:120
bool finite() const
Definition kernelrange.h:114
KernelRange(unsigned int N)
Definition kernelrange.h:107
unsigned int N() const
Definition kernelrange.h:109
Type
types of range restrictor functions
Definition kernelrange.h:23
@ Hard
Heavyside (step) function: .
Definition kernelrange.h:25
@ SoftErf
Definition kernelrange.h:28
double value(double r) const
Definition kernelrange.h:135
KernelRange(unsigned int N, double sigma)
Definition kernelrange.h:98
std::optional< Data > data
Definition kernelrange.h:245
bool finite_hard() const
Definition kernelrange.h:116
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:2502
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
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:2451
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:168
Restrictor restrictor
Definition kernelrange.h:170
static int compute_iextent_x2(int N, const Restrictor &restrictor, double epsilon)
Definition kernelrange.h:186
int iextent_x2(double epsilon) const
Definition kernelrange.h:177
unsigned int N
Definition kernelrange.h:169
Data(unsigned int n, Restrictor r)
Definition kernelrange.h:173
int iextent_x2_default
Definition kernelrange.h:171
restrictor function
Definition kernelrange.h:32
Restrictor(Type type)
Definition kernelrange.h:34
double sigma_inverse() const
Definition kernelrange.h:50
double sigma() const
Definition kernelrange.h:46
std::optional< std::pair< double, double > > sigma_w_inverse_
Definition kernelrange.h:88
double value(double x) const
Definition kernelrange.h:56
hashT hash() const
Definition kernelrange.h:79
Type type_
Definition kernelrange.h:87
friend bool operator==(const Restrictor &r1, const Restrictor &r2)
Definition kernelrange.h:73
Restrictor(Type type, double sigma)
Definition kernelrange.h:35
Type type() const
Definition kernelrange.h:45
Defines hash functions for use in distributed containers.