Class to represent a compile time derivative relation between two quantities. Note that this class does not, in fact cannot, compute any derivatives itself. Rather, this is a way for the compiler to understand higher level mathematical relations. Unless you are really in the weeds of the development team you will likely not need to interact with this directly. Further note that this class does include (unlike the more basic dimension system) some basic dimensional analysis. Specifically, there are some overloaded operators that allow for certain specializations of PartialDerivative to operate on one and other conditioned on what their input and output types are. This does not do any thing like convert area to length^2. However, it will do more basic things like ensure that you can only add two partials which agree on their dimensions exactly. Or that while you can multiple a partial by any scalar, you cannot multiply arbitrary partials.
More...
#include <partial.hpp>
|
| constexpr | PartialDerivative (const double value) noexcept |
| |
| constexpr double | value () const noexcept |
| | Get the underlying value as a compile time constant if possible. This allows the compiler, where the constructor may be determined at compile time, to fully optimize PartialDerivative operations as if they were doubles.
|
| |
|
| double | m_value |
| | Numeric value associated with the partial. If this is known at compile time then the compiler can optimize operations with partial.value() to be equivalent to compile time double operations.
|
| |
|
| constexpr PartialDerivative< OutputQuantity, InputQuantity > | operator+ (const PartialDerivative< OutputQuantity, InputQuantity > &lhs, const PartialDerivative< OutputQuantity, InputQuantity > &rhs) noexcept |
| | Overload the + operator between two partials which share the exact same input and output types.
|
| |
| constexpr PartialDerivative< OutputQuantity, InputQuantity > | operator- (const PartialDerivative< OutputQuantity, InputQuantity > &lhs, const PartialDerivative< OutputQuantity, InputQuantity > &rhs) noexcept |
| | Overload the - operator between two partials which share the exact same input and output types.
|
| |
| template<utils::misc::concepts::IsNumeric Scalar> |
| constexpr PartialDerivative< OutputQuantity, InputQuantity > | operator* (const PartialDerivative< OutputQuantity, InputQuantity > &lhs, const Scalar &rhs) noexcept |
| | Overload of the * operator for a left partial and a right scalar and output types.
|
| |
| template<utils::misc::concepts::IsNumeric Scalar> |
| constexpr PartialDerivative< OutputQuantity, InputQuantity > | operator* (const Scalar &lhs, const PartialDerivative< OutputQuantity, InputQuantity > &rhs) noexcept |
| | Overload of the * operator for a right partial and a left scalar and output types.
|
| |
| template<utils::misc::concepts::IsNumeric Scalar> |
| constexpr PartialDerivative< OutputQuantity, InputQuantity > | operator/ (const PartialDerivative< OutputQuantity, InputQuantity > &lhs, const Scalar &rhs) noexcept |
| | Overload of the / operator for a left partial and a right scalar and output types.
|
| |
| template<utils::misc::concepts::IsNumeric Scalar> |
| constexpr std::partial_ordering | operator<=> (const PartialDerivative< OutputQuantity, InputQuantity > &lhs, Scalar rhs) noexcept |
| | Partial ordering overload to compare a left partial and a right scalar.
|
| |
| template<utils::misc::concepts::IsNumeric Scalar> |
| constexpr std::partial_ordering | operator<=> (Scalar lhs, const PartialDerivative< OutputQuantity, InputQuantity > &rhs) noexcept |
| | Partial ordering overload to compare a right partial and a left scalar.
|
| |
| constexpr std::partial_ordering | operator<=> (const PartialDerivative< OutputQuantity, InputQuantity > &lhs, const PartialDerivative< OutputQuantity, InputQuantity > &rhs) noexcept |
| | Partial ordering comparing two partials with exactly the same input and output types.
|
| |
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
class serif::dimensions::PartialDerivative< OutputQuantity, InputQuantity >
Class to represent a compile time derivative relation between two quantities. Note that this class does not, in fact cannot, compute any derivatives itself. Rather, this is a way for the compiler to understand higher level mathematical relations. Unless you are really in the weeds of the development team you will likely not need to interact with this directly. Further note that this class does include (unlike the more basic dimension system) some basic dimensional analysis. Specifically, there are some overloaded operators that allow for certain specializations of PartialDerivative to operate on one and other conditioned on what their input and output types are. This does not do any thing like convert area to length^2. However, it will do more basic things like ensure that you can only add two partials which agree on their dimensions exactly. Or that while you can multiple a partial by any scalar, you cannot multiply arbitrary partials.
- Template Parameters
-
| OutputQuantity | |
| InputQuantity | |
◆ PartialDerivative()
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
|
|
inlineexplicitconstexprnoexcept |
◆ value()
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
|
|
inlinenodiscardconstexprnoexcept |
Get the underlying value as a compile time constant if possible. This allows the compiler, where the constructor may be determined at compile time, to fully optimize PartialDerivative operations as if they were doubles.
- Note
- calling value gets the underlying numeric value directly thereby bypassing the limitations on what a valid operation are (e.g. what the operator overloads enforce).
- Returns
- m_value: This is whatever was passed at constructor time since there is no way to modify this value after construction without some truly horrific C++ tricks
◆ operator* [1/2]
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
template<utils::misc::concepts::IsNumeric Scalar>
Overload of the * operator for a left partial and a right scalar and output types.
- Template Parameters
-
| Scalar | Any value satisfying the IsNumeric concept (integral types and float types) |
- Parameters
-
| lhs | Partial with some input and some output type |
| rhs | Some numeric quantity |
- Returns
- A new partial with the same input and output types where m_value = lhs.m_value * rhs
◆ operator* [2/2]
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
template<utils::misc::concepts::IsNumeric Scalar>
Overload of the * operator for a right partial and a left scalar and output types.
- Template Parameters
-
| Scalar | Any value satisfying the IsNumeric concept (integral types and float types) |
- Parameters
-
| lhs | Some numeric quantity |
| rhs | Partial with some input and some output type |
- Returns
- A new partial with the same input and output types where m_value = lhs * rhs.m_value
◆ operator+
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
Overload the + operator between two partials which share the exact same input and output types.
- Parameters
-
| lhs | One partial |
| rhs | Other Partial |
- Returns
- A new partial with the same input and output types where m_value = lhs.m_value + rhs.m_value
◆ operator-
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
Overload the - operator between two partials which share the exact same input and output types.
- Parameters
-
| lhs | One partial |
| rhs | Other Partial |
- Returns
- A new partial with the same input and output types where m_value = lhs.m_value - rhs.m_value
◆ operator/
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
template<utils::misc::concepts::IsNumeric Scalar>
Overload of the / operator for a left partial and a right scalar and output types.
- Template Parameters
-
| Scalar | Any value satisfying the IsNumeric concept (integral types and float types) |
- Parameters
-
| lhs | Partial with some input and some output type |
| rhs | Some numeric quantity |
- Returns
- A new partial with the same input and output types where m_value = lhs.m_value / rhs
◆ operator<=> [1/3]
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
Partial ordering comparing two partials with exactly the same input and output types.
- Parameters
-
| lhs | Some Partial |
| rhs | Other Partial |
- Returns
- Partial ordering comparing lhs.m_value to rhs.m_value
◆ operator<=> [2/3]
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
template<utils::misc::concepts::IsNumeric Scalar>
| std::partial_ordering operator<=> |
( |
const PartialDerivative< OutputQuantity, InputQuantity > & | lhs, |
|
|
Scalar | rhs ) |
|
friend |
Partial ordering overload to compare a left partial and a right scalar.
- Template Parameters
-
| Scalar | Any value satisfying the IsNumeric concept (integral types and float types) |
- Parameters
-
| lhs | Some numeric quantity |
| rhs | Some partial with an input and output type |
- Returns
- partial ordering comparing rhs.m_value to lhs
◆ operator<=> [3/3]
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
template<utils::misc::concepts::IsNumeric Scalar>
| std::partial_ordering operator<=> |
( |
Scalar | lhs, |
|
|
const PartialDerivative< OutputQuantity, InputQuantity > & | rhs ) |
|
friend |
Partial ordering overload to compare a right partial and a left scalar.
- Template Parameters
-
| Scalar | Any value satisfying the IsNumeric concept (integral types and float types) |
- Parameters
-
| lhs | Some numeric quantity |
| rhs | Some partial with an input and output type |
- Returns
- partial ordering comparing rhs.m_value to lhs
◆ m_value
template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
Numeric value associated with the partial. If this is known at compile time then the compiler can optimize operations with partial.value() to be equivalent to compile time double operations.
The documentation for this class was generated from the following file: