QMCPACK
ComplexExpFitClass< M > Class Template Reference
+ Collaboration diagram for ComplexExpFitClass< M >:

Public Member Functions

void Fit (std::vector< double > &r, std::vector< std::complex< double >> &u)
 
void FitCusp (std::vector< double > &r, std::vector< std::complex< double >> &u, double cusp)
 
void eval (double r, std::complex< double > &u)
 
void eval (double r, std::complex< double > &u, std::complex< double > &du, std::complex< double > &d2u)
 

Private Attributes

TinyVector< std::complex< double >, M > Coefs
 
TinyVector< std::complex< double >, M > dCoefs
 
TinyVector< std::complex< double >, M > d2Coefs
 
double realSign
 
double imagSign
 

Detailed Description

template<int M>
class qmcplusplus::ComplexExpFitClass< M >

Definition at line 28 of file ExpFitClass.h.

Member Function Documentation

◆ eval() [1/2]

void eval ( double  r,
std::complex< double > &  u 
)
inline

Definition at line 255 of file ExpFitClass.h.

References qmcplusplus::exp().

256 {
257  double r2j = 1.0;
258  std::complex<double> P = std::complex<double>();
259  for (int j = 0; j < M; j++)
260  {
261  P += Coefs[j] * r2j;
262  r2j *= r;
263  }
264  u = std::complex<double>(realSign * std::exp(P.real()), imagSign * std::exp(P.imag()));
265 }
TinyVector< std::complex< double >, M > Coefs
Definition: ExpFitClass.h:196
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)

◆ eval() [2/2]

void eval ( double  r,
std::complex< double > &  u,
std::complex< double > &  du,
std::complex< double > &  d2u 
)
inline

Definition at line 268 of file ExpFitClass.h.

References qmcplusplus::exp().

269 {
270  double r2j = 1.0;
271  std::complex<double> P, dP, d2P;
272  P = dP = d2P = std::complex<double>();
273  for (int j = 0; j < M; j++)
274  {
275  P += Coefs[j] * r2j;
276  dP += dCoefs[j] * r2j;
277  d2P += d2Coefs[j] * r2j;
278  r2j *= r;
279  }
280  u = std::complex<double>(realSign * std::exp(P.real()), imagSign * std::exp(P.imag()));
281  du = std::complex<double>(dP.real() * u.real(), dP.imag() * u.imag());
282  d2u = std::complex<double>((d2P.real() + dP.real() * dP.real()) * u.real(),
283  (d2P.imag() + dP.imag() * dP.imag()) * u.imag());
284  //u.real() = realSign * std::exp (P.real());
285  //du.real() = dP.real() * u.real();
286  //d2u.real() = (d2P.real() + dP.real()*dP.real())*u.real();
287  //u.imag() = imagSign * std::exp (P.imag());
288  //du.imag() = dP.imag() * u.imag();
289  //d2u.imag() = (d2P.imag() + dP.imag()*dP.imag())*u.imag();
290 }
TinyVector< std::complex< double >, M > d2Coefs
Definition: ExpFitClass.h:196
TinyVector< std::complex< double >, M > Coefs
Definition: ExpFitClass.h:196
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
TinyVector< std::complex< double >, M > dCoefs
Definition: ExpFitClass.h:196

◆ Fit()

void Fit ( std::vector< double > &  r,
std::vector< std::complex< double >> &  u 
)
inline

Definition at line 231 of file ExpFitClass.h.

References ExpFitClass< M >::Coefs, ExpFitClass< M >::d2Coefs, ExpFitClass< M >::dCoefs, ExpFitClass< M >::Fit(), qmcplusplus::imag(), qmcplusplus::Units::force::N, qmcplusplus::real(), and ExpFitClass< M >::sign.

232 {
233  int N = u.size();
234  ExpFitClass<M> realFit, imagFit;
235  std::vector<double> realVals(N), imagVals(N);
236  for (int i = 0; i < N; i++)
237  {
238  realVals[i] = real(u[i]);
239  imagVals[i] = imag(u[i]);
240  }
241  realFit.Fit(r, realVals);
242  imagFit.Fit(r, imagVals);
243  realSign = realFit.sign;
244  imagSign = imagFit.sign;
245  for (int i = 0; i < M; i++)
246  {
247  Coefs[i] = std::complex<double>(realFit.Coefs[i], imagFit.Coefs[i]);
248  dCoefs[i] = std::complex<double>(realFit.dCoefs[i], imagFit.dCoefs[i]);
249  d2Coefs[i] = std::complex<double>(realFit.d2Coefs[i], imagFit.d2Coefs[i]);
250  }
251 }
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
TinyVector< std::complex< double >, M > d2Coefs
Definition: ExpFitClass.h:196
TinyVector< std::complex< double >, M > Coefs
Definition: ExpFitClass.h:196
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
TinyVector< std::complex< double >, M > dCoefs
Definition: ExpFitClass.h:196

◆ FitCusp()

void FitCusp ( std::vector< double > &  r,
std::vector< std::complex< double >> &  u,
double  cusp 
)
inline

Definition at line 208 of file ExpFitClass.h.

References ExpFitClass< M >::Coefs, ExpFitClass< M >::d2Coefs, ExpFitClass< M >::dCoefs, ExpFitClass< M >::FitCusp(), qmcplusplus::imag(), qmcplusplus::Units::force::N, qmcplusplus::real(), and ExpFitClass< M >::sign.

209 {
210  int N = u.size();
211  ExpFitClass<M> realFit, imagFit;
212  std::vector<double> realVals(N), imagVals(N);
213  for (int i = 0; i < N; i++)
214  {
215  realVals[i] = real(u[i]);
216  imagVals[i] = imag(u[i]);
217  }
218  realFit.FitCusp(r, realVals, cusp);
219  imagFit.FitCusp(r, imagVals, cusp);
220  realSign = realFit.sign;
221  imagSign = imagFit.sign;
222  for (int i = 0; i < M; i++)
223  {
224  Coefs[i] = std::complex<double>(realFit.Coefs[i], imagFit.Coefs[i]);
225  dCoefs[i] = std::complex<double>(realFit.dCoefs[i], imagFit.dCoefs[i]);
226  d2Coefs[i] = std::complex<double>(realFit.d2Coefs[i], imagFit.d2Coefs[i]);
227  }
228 }
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
TinyVector< std::complex< double >, M > d2Coefs
Definition: ExpFitClass.h:196
TinyVector< std::complex< double >, M > Coefs
Definition: ExpFitClass.h:196
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
TinyVector< std::complex< double >, M > dCoefs
Definition: ExpFitClass.h:196

Member Data Documentation

◆ Coefs

TinyVector<std::complex<double>, M> Coefs
private

Definition at line 196 of file ExpFitClass.h.

◆ d2Coefs

TinyVector<std::complex<double>, M> d2Coefs
private

Definition at line 196 of file ExpFitClass.h.

◆ dCoefs

TinyVector<std::complex<double>, M> dCoefs
private

Definition at line 196 of file ExpFitClass.h.

◆ imagSign

double imagSign
private

Definition at line 197 of file ExpFitClass.h.

◆ realSign

double realSign
private

Definition at line 197 of file ExpFitClass.h.


The documentation for this class was generated from the following file: