16 #ifndef QMCPLUSPLUS_ONEDIMGRID_BASE 17 #define QMCPLUSPLUS_ONEDIMGRID_BASE 28 #include "einspline/bspline_base.h" 34 template<
class T,
class CT = Vector<T>>
55 virtual std::unique_ptr<OneDimGridBase<T, CT>>
makeClone()
const = 0;
65 int khi = this->
size();
86 inline const T*
data()
const {
return &(
X[0]); }
87 inline T*
data() {
return &(
X[0]); }
92 inline T
r(
int i)
const {
return X[i]; }
94 inline T
dr(
int i)
const {
return X[i + 1] -
X[i]; }
102 template<
typename T1>
116 virtual int locate(T
r)
const = 0;
123 virtual void set(T ri, T rf,
int n) = 0;
133 template<
class T,
class CT = Vector<T>>
144 std::unique_ptr<OneDimGridBase<T, CT>>
makeClone()
const override 146 return std::make_unique<LinearGrid<T, CT>>(*this);
149 inline int locate(T
r)
const override {
return static_cast<int>((
static_cast<double>(
r) -
X[0]) *
DeltaInv); }
151 inline void set(T ri, T rf,
int n)
override 159 double Delta_DP = (
static_cast<double>(rf) - static_cast<double>(ri)) / static_cast<double>(
n - 1);
162 for (
int i = 0; i <
n; i++)
163 X[i] = ri + Delta_DP * i;
186 template<
class T,
class CT = Vector<T>>
198 std::unique_ptr<OneDimGridBase<T, CT>>
makeClone()
const override {
return std::make_unique<LogGrid<T, CT>>(*this); }
202 inline void set(T ri, T rf,
int n)
override 213 double ratio = rf / ri;
215 double dlog_ratio = log_ratio /
static_cast<double>(
n - 1);
218 for (
int i = 1; i <
n; i++)
232 template<
class T,
class CT = Vector<T>>
244 std::unique_ptr<OneDimGridBase<T, CT>>
makeClone()
const override 246 return std::make_unique<LogGridZero<T, CT>>(*this);
256 inline void set(T ri, T rf,
int n)
override 265 for (
int i = 0; i <
n; i++)
276 template<
class T,
class CT = Vector<T>>
292 assign(nv.begin(), nv.end());
295 std::unique_ptr<OneDimGridBase<T, CT>>
makeClone()
const override 297 return std::make_unique<NumericalGrid<T, CT>>(*this);
306 copy(g_first, g_last,
X.begin());
325 while (khi - klo > 1)
327 k = (khi + klo) >> 1;
336 inline void set(T ri, T rf,
int n)
override 347 std::ostream& operator<<(std::ostream& out, const OneDimGridBase<T>& rhs)
349 for (
int i = 0; i < rhs.size(); i++)
350 out << i <<
" " << rhs.r(i) <<
" " << rhs.dr(i) << std::endl;
T operator()(int i) const
return a value
T rmin() const
return the first grid point
One-Dimensional linear-grid.
std::unique_ptr< OneDimGridBase< T, CT > > makeClone() const override
helper functions for EinsplineSetBuilder
int locate(T r) const override
evaluate the index of r
T & operator[](int i)
assign a value
std::unique_ptr< OneDimGridBase< T, CT > > makeClone() const override
One-Dimensional logarithmic-grid starting at the origin (Used in Siesta).
Array_t X
array to store the radial grid data
int locate(T r) const override
evaluate the index of r
std::unique_ptr< OneDimGridBase< T, CT > > makeClone() const override
T dh() const
return the differential spacing of the grid
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
An abstract base class to implement a One-Dimensional grid.
int locate(T r) const override
evaluate the index of r
void assign(IT g_first, IT g_last)
virtual ~OneDimGridBase()=default
NumericalGrid(const VA &nv)
std::unique_ptr< OneDimGridBase< T, CT > > makeClone() const override
int locate(T r) const override
evaluate the index of r
One-Dimensional logarithmic-grid.
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
value_type Delta
differential spacing of the grid
One-Dimensional numerical grid with arbitrary grid spacings.
Define data types for any GridType.
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
int size() const
returns the size of the grid
Declaraton of Vector<T,Alloc> Manage memory through Alloc directly and allow referencing an existing ...
T operator[](int i) const
return a value
virtual int locate(T r) const =0
evaluate the index of r
T rmax() const
return the last grid point
virtual std::unique_ptr< OneDimGridBase< T, CT > > makeClone() const =0
T & operator()(int i)
assign a value
int getIndexAndDistanceFromGridPoint(T r, T1 &dist) const