QMCPACK
OrbitalSetTraits.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
10 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 /** @file BasisSetBase.h
17  * @brief Declaration of a base class of BasisSet
18  */
19 #ifndef QMCPLUSPLUS_ORBITALSETTRAITS_H
20 #define QMCPLUSPLUS_ORBITALSETTRAITS_H
21 
22 #include "Configuration.h"
25 #include "OhmmsPETE/OhmmsMatrix.h"
26 
27 namespace qmcplusplus
28 {
29 /** dummy class for templated classes
30  */
31 struct DummyGrid
32 {
33  inline void locate(double r) {}
34  DummyGrid* makeClone() const { return new DummyGrid; }
35 };
36 
38 
39 enum
40 {
41  q_n = 0,
42  q_l,
43  q_m,
45 };
46 
47 /** trait class to handel a set of Orbitals
48  */
49 template<typename T>
50 struct OrbitalSetTraits //: public OrbitalTraits<T>
51 {
52  enum
53  {
55  };
57  using ValueType = T;
58  using IndexType = int;
74 };
75 
76 /** evaluate log(psi) as log(|psi|) and phase
77  * @param psi real/complex value
78  * @return complex<T>(log(|psi|), arg(psi))
79  *
80  * The return value is always complex regardless of the type of psi.
81  * The sign of of a real psi value is represented in the complex part of the return value.
82  * The phase of std::log(complex) is in range [-pi, pi] defined in C++
83  */
84 template<typename T>
85 inline std::complex<T> convertValueToLog(const std::complex<T>& logpsi)
86 {
87  return std::log(logpsi);
88 }
89 
90 template<typename T>
91 inline std::complex<T> convertValueToLog(const T logpsi)
92 {
93  return std::log(std::complex<T>(logpsi));
94 }
95 
96 /** evaluate psi based on log(psi)
97  * @param logpsi complex value
98  * @return exp(log(psi))
99  *
100  * LogToValue<ValueType>::convert(complex) is the reverse operation of convertValueToLog(ValueType)
101  */
102 template<typename T>
104 {
105  template<typename T1>
106  inline static T convert(const std::complex<T1>& logpsi)
107  {
108  return std::real(std::exp(logpsi));
109  }
110 };
111 
112 template<typename T>
113 struct LogToValue<std::complex<T>>
114 {
115  template<typename T1, typename = std::enable_if_t<!std::is_same<T, T1>::value>>
116  inline static std::complex<T> convert(const std::complex<T1>& logpsi)
117  {
118  std::complex<T> tmp(std::real(logpsi), std::imag(logpsi));
119  return std::exp(tmp);
120  }
121 
122  inline static std::complex<T> convert(const std::complex<T>& logpsi) { return std::exp(logpsi); }
123 };
124 
125 } // namespace qmcplusplus
126 
127 #endif
static std::complex< T > convert(const std::complex< T1 > &logpsi)
static T convert(const std::complex< T1 > &logpsi)
QMCTraits::RealType real
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
dummy class for templated classes
Soa Container for D-dim vectors.
evaluate psi based on log(psi)
SoA adaptor class for Vector<TinyVector<T,D> >
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
#define OHMMS_DIM
Definition: config.h:64
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
Tensor<T,D> class for D by D tensor.
Definition: OhmmsTinyMeta.h:32
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
static std::complex< T > convert(const std::complex< T > &logpsi)
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
typename RealAlias_impl< T >::value_type RealAlias
If you have a function templated on a value that can be real or complex and you need to get the base ...
trait class to handel a set of Orbitals
DummyGrid * makeClone() const