42template <base::concepts::real_scalar Value,
typename Diff = Value>
57 template <
typename DiffArg>
88 [[nodiscard]]
auto has_diff() const noexcept ->
bool {
89 return diff_.has_value();
99 "diff function called for a variable without differential "
126 *
diff_ += *right.diff_;
128 diff_ = *right.diff_;
144 *
diff_ -= *right.diff_;
146 diff_ = -*right.diff_;
161 *
diff_ *= right.value_;
168 *
diff_ *= right.value_;
185 *
diff_ = ((*diff_) - (*right.diff_) *
value_) / right.value_;
191 *
diff_ = (*diff_) / right.value_;
214template <
typename Value,
typename Diff>
229template <
typename Value,
typename Diff>
244template <
typename Value,
typename Diff>
259template <
typename Value,
typename Diff>
274template <
typename Value,
typename Diff>
289template <
typename Value,
typename Diff>
304template <
typename Value,
typename Diff>
319template <
typename Value,
typename Diff>
334template <
typename Value,
typename Diff>
349template <
typename Value,
typename Diff>
364template <
typename Value,
typename Diff>
379template <
typename Value,
typename Diff>
400template <
typename Value,
typename Diff>
401struct NumTraits<
num_collect::auto_diff::forward::variable<Value, Diff>> {
425 RequireInitialization = 1,
443 return NumTraits<Value>::epsilon();
452 return NumTraits<Value>::dummy_precision();
461 return NumTraits<Value>::highest();
470 return NumTraits<Value>::lowest();
479 return NumTraits<Value>::digits10();
488 return NumTraits<Value>::infinity();
497 return NumTraits<Value>::quiet_NaN();
Class of variables in forward-mode automatic differentiation kubota1998.
auto operator+=(const variable &right) -> variable &
Add a variable.
auto operator/=(const variable &right) -> variable &
Divide by a variable.
std::optional< diff_type > diff_
Differential coefficients.
auto value() const noexcept -> const value_type &
Get the value.
Value value_type
Type of values.
auto operator*=(const variable &right) -> variable &
Multiply a variable.
variable(const value_type &value)
Constructor.
Diff diff_type
Type of differential coefficients.
auto operator-() const -> variable
Negate this variable.
variable(const value_type &value, DiffArg &&diff)
Constructor.
auto operator-=(const variable &right) -> variable &
Subtract a variable.
auto diff() const -> const diff_type &
Get the differential coefficients.
auto has_diff() const noexcept -> bool
Get whether this variable has differential coefficients.
Definition of exceptions.
Definition of macros for logging.
Namespace of Eigen library.
Namespace of forward-mode automatic differentiation.
auto operator/(const variable< Value, Diff > &left, const variable< Value, Diff > &right) -> variable< Value, Diff >
Divide a variable by another variable.
auto operator*(const variable< Value, Diff > &left, const variable< Value, Diff > &right) -> variable< Value, Diff >
Multiply two variables.
auto operator-(const variable< Value, Diff > &left, const variable< Value, Diff > &right) -> variable< Value, Diff >
Subtract a variable from another variable.
auto operator+(const variable< Value, Diff > &left, const variable< Value, Diff > &right) -> variable< Value, Diff >
Add two variables.
Namespace of num_collect source codes.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.
Definition of real_scalar concept.
static constexpr auto epsilon() -> Real
Get machine epsilon.
static constexpr auto dummy_precision() -> Real
Get dummy precision.
static constexpr auto infinity() -> Real
Get the infinity.
static constexpr auto lowest() -> Real
Get the lowest value.
static constexpr auto digits10() -> int
Get the number of digits.
static constexpr auto quiet_NaN() -> Real
Get the quiet NaN value.
static constexpr auto highest() -> Real
Get the highest value.