sigma  1.0.0
Loading...
Searching...
No Matches
exponents.ipp
1#pragma once
3#include <cmath>
4
5namespace sigma {
6
7template<typename T, typename U>
8Uncertain<T> pow(const Uncertain<T>& a, const U& exp) {
9 T mean = std::pow(a.mean(), exp);
10 T dcda = exp * std::pow(a.mean(), exp - 1);
11 return detail_::unary_result(a, mean, dcda);
12}
13
14template<typename T>
16 Uncertain<T> c(a);
17 T mean = std::pow(a.mean(), exp.mean());
18 T dcda = exp.mean() * std::pow(a.mean(), exp.mean() - 1);
19 T dcdb = std::log(a.mean()) * std::pow(a.mean(), exp.mean());
20 detail_::inplace_binary(c, exp, mean, dcda, dcdb);
21 return c;
22}
23
24template<typename T>
26 T mean = std::sqrt(a.mean());
27 T dcda = 1.0 / (2.0 * std::sqrt(a.mean()));
28 return detail_::unary_result(a, mean, dcda);
29}
30
31template<typename T>
33 T mean = std::cbrt(a.mean());
34 T dcda = 1.0 / (3.0 * std::cbrt(std::pow(a.mean(), 2.0)));
35 return detail_::unary_result(a, mean, dcda);
36}
37
38template<typename T>
40 T mean = std::exp(a.mean());
41 T dcda = std::exp(a.mean());
42 return detail_::unary_result(a, mean, dcda);
43}
44
45template<typename T>
47 T mean = std::exp2(a.mean());
48 T dcda = mean * std::log(2.0);
49 return detail_::unary_result(a, mean, dcda);
50}
51
52template<typename T>
54 T mean = std::expm1(a.mean());
55 T dcda = std::exp(a.mean());
56 return detail_::unary_result(a, mean, dcda);
57}
58
59template<typename T>
61 T mean = std::log(a.mean());
62 T dcda = 1.0 / a.mean();
63 return detail_::unary_result(a, mean, dcda);
64}
65
66template<typename T>
68 T mean = std::log10(a.mean());
69 T dcda = 1.0 / (a.mean() * std::log(10.0));
70 return detail_::unary_result(a, mean, dcda);
71}
72
73template<typename T>
75 T mean = std::log2(a.mean());
76 T dcda = 1.0 / (a.mean() * std::log(2.0));
77 return detail_::unary_result(a, mean, dcda);
78}
79
80template<typename T>
82 T mean = std::log1p(a.mean());
83 T dcda = 1.0 / (a.mean() + 1.0);
84 return detail_::unary_result(a, mean, dcda);
85}
86
87template<typename T>
89 Uncertain<T> c(a);
90 T mean = std::hypot(a.mean(), b.mean());
91 T dcda = a.mean() / std::hypot(a.mean(), b.mean());
92 T dcdb = b.mean() / std::hypot(a.mean(), b.mean());
93 detail_::inplace_binary(c, b, mean, dcda, dcdb);
94 return c;
95}
96
97template<typename T, typename U>
98Uncertain<T> hypot(const Uncertain<T>& a, const U& b) {
99 T mean = std::hypot(a.mean(), b);
100 T dcda = a.mean() / std::hypot(a.mean(), b);
101 return detail_::unary_result(a, mean, dcda);
102}
103
104template<typename T, typename U>
105Uncertain<T> hypot(const U& a, const Uncertain<T>& b) {
106 return hypot(b, a);
107}
108
109} // namespace sigma
Models an unceratin variable.
Definition uncertain.hpp:34
value_t mean() const
Get the mean value of the variable.
Definition uncertain.hpp:71
void inplace_binary(Uncertain< T > &c, const Uncertain< T > &b, T mean, T dcda, T dcdb)
Generalized Inplace Binary Changes.
Definition operation_common.hpp:61
Uncertain< T > unary_result(const Uncertain< T > &a, T mean, T dcda)
Generalized Unary Changes.
Definition operation_common.hpp:43
The primary namespace for the sigma library.
Definition affine.hpp:12
Affine< T > exp(const Affine< T > &a)
Calculate the exponential of an affine form.
Definition exponents.ipp:30
Affine< T > pow(const Affine< T > &a, const U &exp)
Calculate the power of an affine form.
Definition exponents.ipp:71
Uncertain< T > hypot(const Uncertain< T > &a, const Uncertain< T > &b)
Calculate the square root of the sum of squared arguments.
Definition exponents.ipp:88
Affine< T > log(const Affine< T > &a)
Calculate the natural logarithm of an affine form.
Definition exponents.ipp:50
Uncertain< T > expm1(const Uncertain< T > &a)
Calculate the Euler's number raised to the power of an uncertain variable, then subtract 1.
Definition exponents.ipp:53
Uncertain< T > log1p(const Uncertain< T > &a)
Calculate the natural logarithm of one plus a variable.
Definition exponents.ipp:81
Uncertain< T > log2(const Uncertain< T > &a)
Calculate the base 2 logarithm of a variable.
Definition exponents.ipp:74
Affine< T > sqrt(const Affine< T > &a)
Calculate the square root of an affine form.
Definition exponents.ipp:8
Uncertain< T > exp2(const Uncertain< T > &a)
Calculate 2 raised to the power of an uncertain variable.
Definition exponents.ipp:46
Uncertain< T > log10(const Uncertain< T > &a)
Calculate the base 10 logarithm of a variable.
Definition exponents.ipp:67
Uncertain< T > cbrt(const Uncertain< T > &a)
Calculate the cube root of an uncertain variable.
Definition exponents.ipp:32
Common implementation details for operations.