19template<
typename UncertainType>
29 using value_t =
typename uncertain_t::value_t;
32 using dep_sd_t =
typename uncertain_t::dep_sd_t;
63 std::vector<dep_sd_ptr> zero_contributions{};
64 for(
const auto& [dep, deriv] : m_x_.m_deps_) {
66 zero_contributions.emplace_back(dep);
69 m_x_.m_sd_ += std::pow(*dep.get() * deriv, 2.0);
71 for(
const auto& dep : zero_contributions) { m_x_.m_deps_.erase(dep); }
72 m_x_.m_sd_ = std::sqrt(m_x_.m_sd_);
87 for(
const auto& [dep, deriv] : m_x_.m_deps_) {
88 m_x_.m_deps_[dep] *= dxda;
107 bool call_update_std =
true) {
108 for(
const auto& [dep, deriv] : deps) {
109 auto new_deriv = dxda * deriv;
110 if(m_x_.m_deps_.count(dep) != 0) {
111 m_x_.m_deps_[dep] += new_deriv;
113 m_x_.m_deps_.emplace(std::make_pair(std::move(dep), new_deriv));
UncertainType uncertain_t
The numeric type of the variable.
Definition setter.hpp:26
typename uncertain_t::dep_sd_ptr dep_sd_ptr
A pointer to a dependency of this variable.
Definition setter.hpp:35
Setter(uncertain_t &u)
Construct a Setter for a variable.
Definition setter.hpp:46
void update_sd()
Calculate the standatd deviation of m_x_ based on the uncertainty of its dependencies.
Definition setter.hpp:61
void update_derivatives(value_t dxda, bool call_update_std=true)
Update of existing derivatives.
Definition setter.hpp:85
Setter< UncertainType > my_t
Type of the instance.
Definition setter.hpp:23
void update_mean(value_t mean)
Update the mean of the wrapped variable.
Definition setter.hpp:54
typename uncertain_t::value_t value_t
The type of the values of the variable.
Definition setter.hpp:29
void update_derivatives(const deps_map_t &deps, value_t dxda, bool call_update_std=true)
Update/addition of derivatives.
Definition setter.hpp:106
typename uncertain_t::dep_sd_t dep_sd_t
The type of a standard deviation that this instance depends on.
Definition setter.hpp:32
typename uncertain_t::deps_map_t deps_map_t
The type of the map holding the variable's dependencies.
Definition setter.hpp:38
The namespace that contains the implementation details of the library.
Definition operation_common.hpp:10
Defines the Uncertain class.