template<class T>
Dual class
Dual number.
Template parameters | |
---|---|
T | Underlying data type |
Contents
Public types
- using Type = T
- Underlying data type.
Constructors, destructors, conversion operators
- Dual() constexpr noexcept
- Default constructor.
- Dual(ZeroInitT) constexpr noexcept
- Construct zero-initialized dual number.
- Dual(NoInitT) explicit noexcept
- Construct without initializing the contents.
- Dual(const T& real, const T& dual = T()) constexpr noexcept
- Construct dual number from real and dual part.
-
template<class U>Dual(const Dual<U>& other) explicit constexpr noexcept
- Construct dual number from another of different type.
- Dual(const Dual<T>&) noexcept defaulted constexpr
- Copy constructor.
Public functions
- auto operator==(const Dual<T>& other) const -> bool
- Equality comparison.
- auto operator!=(const Dual<T>& other) const -> bool
- Non-equality comparison.
- auto real() -> T&
- Real part.
- auto real() const -> T constexpr
- auto dual() -> T&
- Dual part.
- auto dual() const -> T constexpr
- auto operator+=(const Dual<T>& other) -> Dual<T>&
- Add and assign dual number.
- auto operator+(const Dual<T>& other) const -> Dual<T>
- Add dual number.
- auto operator-() const -> Dual<T>
- Negated dual number.
- auto operator-=(const Dual<T>& other) -> Dual<T>&
- Subtract and assign dual number.
- auto operator-(const Dual<T>& other) const -> Dual<T>
- Subtract dual number.
-
template<class U>auto operator*(const Dual<U>& other) > -> auto
- Multiply by dual number.
-
template<class U, class V = typename std::auto operator*(const U& other) const -> Dual<decltype(std::
enable_if<!Implementation::IsDual<U>::value, void>::type> declval<T>)*std:: declval<U>))> - Multiply by real number.
-
template<class U>auto operator/(const Dual<U>& other) > -> auto
- Divide by dual number.
-
template<class U, class V = typename std::auto operator/(const U& other) const -> V
enable_if<!Implementation::IsDual<U>::value, Dual<decltype(std:: declval<T>()/std:: declval<U>())>>::type> - Divide by real number.
- auto conjugated() const -> Dual<T>
- Conjugated dual number.
Function documentation
template<class T>
Magnum:: Math:: Dual<T>:: Dual() constexpr noexcept
Default constructor.
Both parts are default-constructed.
template<class T>
Magnum:: Math:: Dual<T>:: Dual(const T& real,
const T& dual = T()) constexpr noexcept
Construct dual number from real and dual part.
template<class T>
template<class U>
Magnum:: Math:: Dual<T>:: Dual(const Dual<U>& other) explicit constexpr noexcept
Construct dual number from another of different type.
Performs only default casting on the values, no rounding or anything else. Example usage:
Dual<Float> floatingPoint(1.3f, 2.7f); Dual<Byte> integral(floatingPoint); // integral == {1, 2}
template<class T>
T Magnum:: Math:: Dual<T>:: real() const constexpr
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T>
T Magnum:: Math:: Dual<T>:: dual() const constexpr
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T>
Dual<T>& Magnum:: Math:: Dual<T>:: operator+=(const Dual<T>& other)
Add and assign dual number.
The computation is done in-place.
template<class T>
Dual<T>& Magnum:: Math:: Dual<T>:: operator-=(const Dual<T>& other)
Subtract and assign dual number.
The computation is done in-place.
template<class T>
template<class U, class V = typename std:: enable_if<!Implementation::IsDual<U>::value, void>::type>
Dual<decltype(std:: declval<T>)*std:: declval<U>))> Magnum:: Math:: Dual<T>:: operator*(const U& other) const
Multiply by real number.
Equivalent to the above assuming that .
template<class T>
template<class U, class V = typename std:: enable_if<!Implementation::IsDual<U>::value, Dual<decltype(std:: declval<T>()/std:: declval<U>())>>::type>
V Magnum:: Math:: Dual<T>:: operator/(const U& other) const
Divide by real number.
Equivalent to the above assuming that .
template<class T>
Dual<T> Magnum:: Math:: Dual<T>:: conjugated() const
Conjugated dual number.
template<class T>
template<class T, class U, class V = typename std:: enable_if<!Implementation::IsDual<T>::value, Dual<decltype(std:: declval<T>()*std:: declval<U>())>>::type>
V operator*(const T& a,
const Dual<U>& b)
Multiply real number by dual number.
Equivalent to Dual::
template<class T>
template<class T>
Corrade:: Utility:: Debug& operator<<(Corrade:: Utility:: Debug& debug,
const Dual<T>& value)
Debug output operator.