#include <Magnum/Math/Dual.h>
template<class T>
Dual class
Dual number.
Template parameters | |
---|---|
T | Underlying data type |
Usually denoted as the following in equations, with being the real() part and the dual() part:
Public types
- using Type = T
- Underlying data type.
Constructors, destructors, conversion operators
- Dual() constexpr noexcept
- Default constructor.
- Dual(ZeroInitT) explicit 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 a dual number from real and dual part.
-
template<class U>Dual(const Dual<U>& other) explicit constexpr noexcept
- Construct a dual number from another of different type.
Public functions
- auto data() -> T*
- Raw data.
- auto data() const -> const T*
- 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 -> const T constexpr
- auto dual() -> T&
- Dual part ( )
- auto dual() const -> const T constexpr
- auto operator+() const -> Dual<T> new in Git master
- Promotion.
- 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 a 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 a dual number from another of different type.
Performs only default casting on the values, no rounding or anything else. Example usage:
Math::Dual<Float> floatingPoint{1.3f, 2.7f}; Math::Dual<Byte> integral{floatingPoint}; // {1, 2}
template<class T>
T* Magnum:: Math:: Dual<T>:: data()
Raw data.
Contrary to what Doxygen shows, returns reference to an one-dimensional fixed-size array of two elements, i.e. T(&)[2]
.
template<class T>
const T* Magnum:: Math:: Dual<T>:: data() const
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>:: real()
Real part ( )
template<class T>
const 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()
Dual part ( )
template<class T>
const 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 new in Git master
Promotion.
Returns the value as-is.
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>
Debug& operator<<(Debug& debug,
const Dual<T>& value)
Debug output operator.