QMCPACK
FakeFunctor.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2022 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 /** @file FakeFunctor.h
14  * @brief FakeFunctor for testing purpose
15  */
16 #ifndef QMCPLUSPLUS_FAKEFUNCTOR_H
17 #define QMCPLUSPLUS_FAKEFUNCTOR_H
18 
19 #include "OptimizableFunctorBase.h"
20 #include <cmath>
21 #include "OhmmsPETE/TinyVector.h"
23 
24 namespace qmcplusplus
25 {
26 template<class T>
28 {
29  ///default constructor
30  FakeFunctor(const std::string& my_name) : OptimizableFunctorBase(my_name) {}
31 
32  void setCusp(real_type cusp) override {}
33 
34  OptimizableFunctorBase* makeClone() const override { return new FakeFunctor(*this); }
35 
36  void reset() override {}
37 
38  inline real_type evaluate(real_type r) const { return 0.0; }
39 
40 
41  inline real_type evaluate(real_type r, real_type& dudr, real_type& d2udr2) const
42  {
43  dudr = 0.0;
44  d2udr2 = 0.0;
45  return 0.0;
46  }
47 
48  inline real_type evaluate(real_type r, real_type& dudr, real_type& d2udr2, real_type& d3udr3) const
49  {
50  dudr = 0.0;
51  d2udr2 = 0.0;
52  d3udr3 = 0.0;
53  return 0.0;
54  }
55 
56 
57  inline real_type evaluateV(const int iat,
58  const int iStart,
59  const int iEnd,
60  const T* restrict _distArray,
61  T* restrict distArrayCompressed) const
62  {
63  return 0.0;
64  }
65 
66  static void mw_evaluateV(const int num_groups,
67  const FakeFunctor* const functors[],
68  const int n_src,
69  const int* grp_ids,
70  const int num_pairs,
71  const int* ref_at,
72  const T* mw_dist,
73  const int dist_stride,
74  T* mw_vals,
75  Vector<char, OffloadPinnedAllocator<char>>& transfer_buffer)
76  {}
77 
78  inline void evaluateVGL(const int iat,
79  const int iStart,
80  const int iEnd,
81  const T* distArray,
82  T* restrict valArray,
83  T* restrict gradArray,
84  T* restrict laplArray,
85  T* restrict distArrayCompressed,
86  int* restrict distIndices) const
87  {}
88 
89  static void mw_evaluateVGL(const int iat,
90  const int num_groups,
91  const FakeFunctor* const functors[],
92  const int n_src,
93  const int* grp_ids,
94  const int nw,
95  T* mw_vgl, // [nw][DIM+2]
96  const int n_padded,
97  const T* mw_dist, // [nw][DIM+1][n_padded]
98  T* mw_cur_allu, // [nw][3][n_padded]
99  Vector<char, OffloadPinnedAllocator<char>>& transfer_buffer)
100  {}
101 
102  inline real_type f(real_type r) override { return evaluate(r); }
103 
104  inline real_type df(real_type r) override { return 0.0; }
105 
106  static void mw_updateVGL(const int iat,
107  const std::vector<bool>& isAccepted,
108  const int num_groups,
109  const FakeFunctor* const functors[],
110  const int n_src,
111  const int* grp_ids,
112  const int nw,
113  T* mw_vgl, // [nw][DIM+2]
114  const int n_padded,
115  const T* mw_dist, // [nw][DIM+1][n_padded]
116  T* mw_allUat, // [nw][DIM+2][n_padded]
117  T* mw_cur_allu, // [nw][3][n_padded]
118  Vector<char, OffloadPinnedAllocator<char>>& transfer_buffer)
119  {}
120 
121  inline bool evaluateDerivatives(real_type r, std::vector<TinyVector<real_type, 3>>& derivs) override
122  {
123  derivs = derivs_;
124  return true;
125  }
126 
127 
128  /// compute derivatives with respect to variational parameters
129  inline bool evaluateDerivatives(real_type r, std::vector<real_type>& derivs) override { return true; }
130 
131  bool put(xmlNodePtr cur) override { return true; }
132 
133 
135 
136  void checkOutVariables(const opt_variables_type& active) override {}
137 
138  void resetParametersExclusive(const opt_variables_type& active) override {}
139 
140 
141  std::vector<TinyVector<real_type, 3>> derivs_;
142 };
143 
144 
145 } // namespace qmcplusplus
146 #endif
bool put(xmlNodePtr cur) override
process xmlnode and registers variables to optimize
Definition: FakeFunctor.h:131
Fixed-size array.
Definition: OhmmsTinyMeta.h:30
bool evaluateDerivatives(real_type r, std::vector< TinyVector< real_type, 3 >> &derivs) override
Definition: FakeFunctor.h:121
void checkOutVariables(const opt_variables_type &active) override
check out variational optimizable variables
Definition: FakeFunctor.h:136
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void resetParametersExclusive(const opt_variables_type &active) override
reset the parameters during optimizations.
Definition: FakeFunctor.h:138
real_type evaluate(real_type r, real_type &dudr, real_type &d2udr2) const
Definition: FakeFunctor.h:41
real_type evaluate(real_type r) const
Definition: FakeFunctor.h:38
void setCusp(real_type cusp) override
Definition: FakeFunctor.h:32
void checkInVariablesExclusive(opt_variables_type &active) override
check in variational parameters to the global list of parameters used by the optimizer.
Definition: FakeFunctor.h:134
real_type evaluateV(const int iat, const int iStart, const int iEnd, const T *restrict _distArray, T *restrict distArrayCompressed) const
Definition: FakeFunctor.h:57
Define a base class for one-dimensional functions with optimizable variables.
bool evaluateDerivatives(real_type r, std::vector< real_type > &derivs) override
compute derivatives with respect to variational parameters
Definition: FakeFunctor.h:129
class to handle a set of variables that can be modified during optimizations
Definition: VariableSet.h:49
static void mw_updateVGL(const int iat, const std::vector< bool > &isAccepted, const int num_groups, const FakeFunctor *const functors[], const int n_src, const int *grp_ids, const int nw, T *mw_vgl, const int n_padded, const T *mw_dist, T *mw_allUat, T *mw_cur_allu, Vector< char, OffloadPinnedAllocator< char >> &transfer_buffer)
Definition: FakeFunctor.h:106
FakeFunctor(const std::string &my_name)
default constructor
Definition: FakeFunctor.h:30
OHMMS_PRECISION real_type
OMPallocator is an allocator with fused device and dualspace allocator functionality.
static void mw_evaluateV(const int num_groups, const FakeFunctor *const functors[], const int n_src, const int *grp_ids, const int num_pairs, const int *ref_at, const T *mw_dist, const int dist_stride, T *mw_vals, Vector< char, OffloadPinnedAllocator< char >> &transfer_buffer)
Definition: FakeFunctor.h:66
Base class for any functor with optimizable parameters.
OptimizableFunctorBase * makeClone() const override
create a clone of this object
Definition: FakeFunctor.h:34
real_type evaluate(real_type r, real_type &dudr, real_type &d2udr2, real_type &d3udr3) const
Definition: FakeFunctor.h:48
real_type df(real_type r) override
Definition: FakeFunctor.h:104
void evaluateVGL(const int iat, const int iStart, const int iEnd, const T *distArray, T *restrict valArray, T *restrict gradArray, T *restrict laplArray, T *restrict distArrayCompressed, int *restrict distIndices) const
Definition: FakeFunctor.h:78
static void mw_evaluateVGL(const int iat, const int num_groups, const FakeFunctor *const functors[], const int n_src, const int *grp_ids, const int nw, T *mw_vgl, const int n_padded, const T *mw_dist, T *mw_cur_allu, Vector< char, OffloadPinnedAllocator< char >> &transfer_buffer)
Definition: FakeFunctor.h:89
void reset() override
reset function
Definition: FakeFunctor.h:36
real_type f(real_type r) override
Definition: FakeFunctor.h:102
std::vector< TinyVector< real_type, 3 > > derivs_
Definition: FakeFunctor.h:141