QMCPACK
OptimizableFunctorBase.cpp
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: Luke Shulenburger, lshulen@sandia.gov, Sandia National Laboratories
8 //
9 // File created by: Luke Shulenburger, lshulen@sandia.gov, Sandia National Laboratories
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include "OptimizableFunctorBase.h"
14 
15 namespace qmcplusplus
16 {
17 void print(OptimizableFunctorBase& func, std::ostream& os, double extent)
18 {
20  int n = 1000;
21  real_type d = extent == -1.0 ? func.cutoff_radius / n : extent / n;
22  real_type r = 0;
23  real_type u, du;
24  for (int i = 0; i < n; ++i)
25  {
26  u = func.f(r);
27  du = func.df(r);
28  os << std::setw(22) << r << std::setw(22) << u << std::setw(22) << du << std::endl;
29  r += d;
30  }
31 }
32 
33 std::string extractCoefficientsID(xmlNodePtr cur)
34 {
35  xmlNodePtr xmlCoefs = cur->xmlChildrenNode;
36  while (xmlCoefs != NULL)
37  {
38  std::string cname((const char*)xmlCoefs->name);
39  if (cname == "coefficients")
40  return getXMLAttributeValue(xmlCoefs, "id");
41  xmlCoefs = xmlCoefs->next;
42  }
43  return "";
44 }
45 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void print(OptimizableFunctorBase &func, std::ostream &os, double extent)
evaluates a functor (value and derivative) and dumps the quantities to output
virtual real_type f(real_type r)=0
evaluate the value at r
Define a base class for one-dimensional functions with optimizable variables.
XMLNodeString convert xmlNode contents into a std::string XMLAttrString convert one xmlNode attribute...
OHMMS_PRECISION real_type
std::string getXMLAttributeValue(const xmlNodePtr cur, const std::string_view name)
get the value string for attribute name if name is unfound in cur you get an empty string back this i...
Base class for any functor with optimizable parameters.
virtual real_type df(real_type r)=0
evaluate the first derivative
std::string extractCoefficientsID(xmlNodePtr cur)
return the id of the first coefficients. If not found, return an emtpy string
optimize::VariableSet::real_type real_type
typedef for real values