ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ModelParameters Class Reference

#include <DmrgParameters.h>

Inheritance diagram for ModelParameters:
BaseParameters

Public Member Functions

 ModelParameters ()
 
 ModelParameters (std::ifstream &param_file)
 
 ModelParameters (BaseParameters const &p)
 
bool is_set (std::string const &key) const
 
parameters::proxy operator[] (std::string const &key)
 
template<class T >
get (std::string const &key)
 
template<class T >
void set (std::string const &key, T const &value)
 
BaseParameters iteration_params (std::string const &var, std::size_t val)
 
BaseParametersoperator<< (BaseParameters const &p)
 

Protected Member Functions

void add_option (std::string const &name, std::string const &desc, parameters::value const &val=parameters::value())
 

Protected Attributes

std::map< std::string,
std::string > 
defaults
 
std::map< std::string,
std::string > 
descriptions
 

Detailed Description

Definition at line 125 of file DmrgParameters.h.

Constructor & Destructor Documentation

ModelParameters::ModelParameters ( )
inline

Definition at line 128 of file DmrgParameters.h.

128 : BaseParameters() { init_options(); }
ModelParameters::ModelParameters ( std::ifstream &  param_file)
inline

Definition at line 129 of file DmrgParameters.h.

130  : BaseParameters(param_file)
131  {
132  init_options();
133  }
ModelParameters::ModelParameters ( BaseParameters const &  p)
inline

Definition at line 134 of file DmrgParameters.h.

135  : BaseParameters(p)
136  {
137  init_options();
138  }

Member Function Documentation

void BaseParameters::add_option ( std::string const &  name,
std::string const &  desc,
parameters::value const &  val = parameters::value() 
)
inlineprotectedinherited

Definition at line 148 of file BaseParameters.h.

151  {
152  if (!val.empty())
153  defaults[name] = val.get();
154  descriptions[name] = desc;
155  }
std::map< std::string, std::string > descriptions
std::map< std::string, std::string > defaults
template<class T >
T BaseParameters::get ( std::string const &  key)
inlineinherited

Definition at line 107 of file BaseParameters.h.

108  {
109  parameters::proxy const& p = (*this)[key];
110  return p.as<T>();
111  }
bool BaseParameters::is_set ( std::string const &  key) const
inlineinherited

Definition at line 90 of file BaseParameters.h.

91  {
92  return defined(key);
93  }
BaseParameters BaseParameters::iteration_params ( std::string const &  var,
std::size_t  val 
)
inlineinherited

Definition at line 118 of file BaseParameters.h.

119  {
120  BaseParameters p;
121 
122  boost::regex expression("^(.*)\\[" + var + "\\]$");
123  boost::smatch what;
124  for (alps::Parameters::const_iterator it=this->begin();it != this->end();++it) {
125  std::string key = it->key();
126  if (boost::regex_match(key, what, expression)) {
127  std::vector<value_type> v = (*this)[key];
128  if (val < v.size())
129  p.set(what.str(1), v[val]);
130  else
131  p.set(what.str(1), *(v.rbegin()));
132  }
133  }
134  p.set(var, val);
135  return p;
136  }
void set(std::string const &key, T const &value)
BaseParameters& BaseParameters::operator<< ( BaseParameters const &  p)
inlineinherited

Definition at line 138 of file BaseParameters.h.

139  {
140  for (alps::Parameters::const_iterator it=p.begin(); it!=p.end(); ++it)
141  alps::Parameters::operator[](it->key()) = it->value();
142  defaults.insert(p.defaults.begin(), p.defaults.end());
143 
144  return *this;
145  }
std::map< std::string, std::string > defaults
parameters::proxy BaseParameters::operator[] ( std::string const &  key)
inlineinherited

Definition at line 95 of file BaseParameters.h.

96  {
97  if (!defined(key)) {
98  std::map<std::string, std::string>::const_iterator match = defaults.find(key);
99  if (match != defaults.end())
100  alps::Parameters::operator[](key) = match->second;
101  else
102  boost::throw_exception(std::runtime_error("parameter " + key + " not defined"));
103  }
104  return parameters::proxy(alps::Parameters::operator[](key));
105  }
std::map< std::string, std::string > defaults
template<class T >
void BaseParameters::set ( std::string const &  key,
T const &  value 
)
inlineinherited

Definition at line 113 of file BaseParameters.h.

114  {
115  alps::Parameters::operator[](key) = boost::lexical_cast<std::string>(value);
116  }

Member Data Documentation

std::map<std::string, std::string> BaseParameters::defaults
protectedinherited

Definition at line 157 of file BaseParameters.h.

std::map<std::string, std::string> BaseParameters::descriptions
protectedinherited

Definition at line 158 of file BaseParameters.h.


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