1 #ifndef BASICCLEXPARAMPACK_HH
2 #define BASICCLEXPARAMPACK_HH
23 : ClexParamPack_impl::
BaseKey(_name, _standalone),
m_index(_ind) {}
50 template <
typename Scalar>
53 template <
typename Scalar>
57 return size(*
static_cast<Key const *
>(_key.
ptr()));
63 return dim(*
static_cast<Key const *
>(_key.
ptr()));
75 return read(*
static_cast<Key const *
>(_key.
ptr()));
83 return read(*
static_cast<Key const *
>(_key.
ptr()), _ind);
92 return read(*
static_cast<Key const *
>(_key.
ptr()), _i, _j);
100 std::string
const &_mode)
override {
102 from_string<EvalMode>(_mode));
110 Eigen::Ref<const Eigen::MatrixXd>
const &_val)
override {
111 write(*
static_cast<Key const *
>(_key.
ptr()), _val);
114 void write(
Key const &_key, Eigen::Ref<const Eigen::MatrixXd>
const &_val) {
119 write(*
static_cast<Key const *
>(_key.
ptr()), _i, _val);
127 double _val)
override {
128 write(*
static_cast<Key const *
>(_key.
ptr()), _i, _j, _val);
137 auto it =
keys().find(_keyname);
138 if (it !=
keys().end())
139 throw std::runtime_error(
140 "Naming collision in BasicClexParamPack::allocate(), ClexParamPack "
141 "already managing parameter allocation corresponding to name " +
144 Key protokey(_keyname,
true,
m_data.size());
146 m_data.push_back(Eigen::MatrixXd::Zero(_rows, _cols));
150 m_keys[_keyname] = protokey;
175 Eigen::Ref<const Eigen::MatrixXd>
const &_val) {
179 template <
typename Scalar2>
185 template <
typename Scalar2>
197 std::vector<std::string> >
203 sout << to_string<BasicClexParamPack::EvalMode>(val);
210 val = from_string<BasicClexParamPack::EvalMode>(
s);
216 const std::multimap<BasicClexParamPack::EvalMode, std::vector<std::string> >
219 {
"Default",
"DEFAULT",
"default"}},
222 {
"Dynamic",
"Dynam",
"DYNAMIC",
"DYNAM",
"dynamic",
"dynam"}}};
std::set< std::string > & s
ClexParamPack::size_type size_type
ClexParamPack_impl::BaseKey * _clone() const override
Clone the ClexParamKey.
BasicClexParamKey(std::string const &_name="", bool _standalone=false, size_type _ind=-1)
Abstract base class for reading/writing clexulator parameters Parameters are assume be naturally repr...
double const & read(Key const &_key, size_type _ind) const
void write(ClexParamKey const &_key, size_type _i, double _val) override
Write element to 1D parameter array for parameter specified by.
EvalMode eval_mode(Key const &_key) const
Eigen::MatrixXd::CoeffReturnType DoubleReference
std::vector< EvalMode > m_eval
void set_eval_mode(Key const &_key, EvalMode _mode)
double const & read(ClexParamKey const &_key, size_type _ind) const override
Returns const reference to element of 1D parameter array for parameter specified by.
static const EvalMode DYNAM
double const & read(ClexParamKey const &_key, size_type _i, size_type _j) const override
Returns const reference to element of 2D parameter array for parameter specified by.
Eigen::MatrixXd const & read(Key const &_key) const
void write(Key const &_key, size_type _i, double _val)
Eigen::MatrixXd const & read(ClexParamKey const &_key) const override
Returns const reference to parameter array for parameter specified by.
void write(Key const &_key, size_type _i, size_type _j, double _val)
double const & read(Key const &_key, size_type _i, size_type _j) const
size_type dim(Key const &_key) const
static const EvalMode READ
Key allocate(std::string const &_keyname, Index _rows, Index _cols, bool _independent)
size_type dim(ClexParamKey const &_key) const override
'm' dimension of parameter array returns number of rows in parameter array
std::vector< Eigen::MatrixXd > m_data
static const EvalMode DEFAULT
size_type size(Key const &_key) const
std::string eval_mode(ClexParamKey const &_key) const override
Check evaluation mode for ClexParamPack parameter Choices are at least.
void write(ClexParamKey const &_key, size_type _i, size_type _j, double _val) override
Write element to 2D parameter array for parameter specified by.
void write(Key const &_key, Eigen::Ref< const Eigen::MatrixXd > const &_val)
void set_eval_mode(ClexParamKey const &_key, std::string const &_mode) override
Sets evaluation mode for ClexParamPack parameter Choices are at least.
void write(ClexParamKey const &_key, Eigen::Ref< const Eigen::MatrixXd > const &_val) override
Write parameter array for parameter specified by.
size_type size(ClexParamKey const &_key) const override
'N' dimension of parameter array (either '1', or size of unit cell neighborhood) returns number of co...
Key for indexing clexulator parameters Contains pointer to implementation of the Key.
ClexParamPack_impl::BaseKey const * ptr() const
Returns pointer to Key implementation.
BaseKey is base class from which all ClexParamKey implementation classes inherit. Hides implementatio...
BaseKey(std::string const &_name, bool _standalone, std::vector< Index > const &_offset={}, std::vector< Index > const &_stride={})
Must be constructed with at least a name.
Abstract base class for reading/writing clexulator parameters Parameters are assumed to be stored as,...
std::map< std::string, ClexParamKey > const & keys() const
Obtain registry of all keys for data blocks managed by this ClexParamPack.
std::map< std::string, ClexParamKey > m_keys
std::string to_string(ENUM val)
Return string representation of enum class.
std::ostream & operator<<(std::ostream &_stream, const FormattedPrintable &_formatted)
std::istream & operator>>(std::istream &_in, std::vector< T > &vec)
INDEX_TYPE Index
For long integer indexing:
static void set(BasicClexParamPack &_pack, BasicClexParamKey const &_key, size_type i, Scalar2 const &_val)
static double const & get(BasicClexParamPack const &_pack, BasicClexParamKey const &_key, size_type i, size_type j)
static void set(BasicClexParamPack &_pack, BasicClexParamKey const &_key, Eigen::Ref< const Eigen::MatrixXd > const &_val)
BasicClexParamPack::size_type size_type
static void set(BasicClexParamPack &_pack, BasicClexParamKey const &_key, size_type i, size_type j, Scalar2 const &_val)
static double const & get(BasicClexParamPack const &_pack, BasicClexParamKey const &_key, size_type i)
static const std::string name
static const std::multimap< BasicClexParamPack::EvalMode, std::vector< std::string > > strval