Model.hpp
110 copy.m_evalfn = memoizeLastUsingRef<Result>(copy.m_evalfn); // Here, `m_evalfn` is memoized in case it is called multiple times with the same arguments and parameters.
111 copy.m_calcfn = memoizeLast(copy.m_calcfn); // Here, `m_calcfn` is memoized in case it is called multiple times with the same arguments and parameters.
169 auto calcfn = [value](const Args&... args) -> real { return value; }; // the constant model is a simple function that always return the given constant value
216 auto chain(const Model<Result(Args...)>& model, const Models&... models) -> Model<Result(Args...)>
The class used to store and retrieve data for assemblying chemical systems.
Definition: Data.hpp:30
auto add(Data data) -> void
Add a Data object to this Data object, which becomes a list if not already.
Model(const Fun &f)
Construct a Model function object with either a model evaluator or a model calculator function.
Definition: Model.hpp:102
Ref< Result > ResultRef
The reference type of result type.
Definition: Model.hpp:49
auto initialized() const -> bool
Return true if this Model function object has been initialized.
Definition: Model.hpp:136
auto operator()(const Args &... args) const -> Result
Evaluate the model with given arguments and return the result of the evaluation.
Definition: Model.hpp:123
Model()
Construct a default Model function object.
Definition: Model.hpp:52
auto evaluatorFn() const -> const ModelEvaluator< ResultRef, Args... > &
Return the model evaluator function of this Model function object.
Definition: Model.hpp:148
Model(const ModelEvaluator< ResultRef, Args... > &evalfn, const Data ¶ms={})
Construct a Model function object with given model evaluator function and its parameters.
Definition: Model.hpp:58
auto withMemoization() const -> Model
Return a new Model function object with memoization for the model calculator.
Definition: Model.hpp:107
auto params() const -> const Data &
Return the model parameters of this Model function object.
Definition: Model.hpp:160
auto calculatorFn() const -> const ModelCalculator< Result, Args... > &
Return the model calculator function of this Model function object.
Definition: Model.hpp:154
static auto Constant(String const &name, real const &value) -> Model
Return a constant Model function object.
Definition: Model.hpp:167
auto operator()(ResultRef res, const Args &... args) const -> void
Evaluate the model with given arguments and return the result of the evaluation.
Definition: Model.hpp:130
auto apply(ResultRef res, const Args &... args) const -> void
Evaluate the model with given arguments.
Definition: Model.hpp:116
Model(const ModelCalculator< Result, Args... > &calcfn, const Data ¶ms={})
Construct a Model function object with given direct model calculator and its parameters.
Definition: Model.hpp:79
Definition: Model.hpp:30
#define errorifnot(condition,...)
Define a macro to raise a runtime exception if an expected condition is not true.
Definition: Exception.hpp:149
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
Fn< Result(Args... args)> ModelCalculator
The functional signature of functions that calculates properties.
Definition: Model.hpp:38
auto memoizeLast(Fn< Ret(Args...)> f) -> Fn< Ret(Args...)>
Return a memoized version of given function f that caches only the arguments used in the last call.
Definition: Memoization.hpp:167
auto chain(const Vec< ActivityModelGenerator > &models) -> ActivityModelGenerator
Return an activity model resulting from chaining other activity models.
autodiff::real real
The number type used throughout the library.
Definition: Real.hpp:26
auto vectorize(const Container &c, const Function &f)
Return a vector by applying function f on every item in container c.
Definition: Algorithms.hpp:135
std::function< F > Fn
Convenient alias for std::function<R(Args...)>.
Definition: Types.hpp:110
Fn< void(ResultRef res, Args... args)> ModelEvaluator
The functional signature of functions that evaluates properties.
Definition: Model.hpp:34