SERiF v0.0.1a
Stellar Evolution and Rotation in Four Dimensions
Loading...
Searching...
No Matches
serif::dimensions::PartialDerivative< OutputQuantity, InputQuantity > Class Template Referencefinal

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>

Public Member Functions

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.
 

Private Attributes

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.
 

Friends

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.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ PartialDerivative()

template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
serif::dimensions::PartialDerivative< OutputQuantity, InputQuantity >::PartialDerivative ( const double value)
inlineexplicitconstexprnoexcept

Member Function Documentation

◆ value()

template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
double serif::dimensions::PartialDerivative< OutputQuantity, InputQuantity >::value ( ) const
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

Friends And Related Symbol Documentation

◆ operator* [1/2]

template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
template<utils::misc::concepts::IsNumeric Scalar>
PartialDerivative< OutputQuantity, InputQuantity > operator* ( const PartialDerivative< OutputQuantity, InputQuantity > & lhs,
const Scalar & rhs )
friend

Overload of the * operator for a left partial and a right scalar and output types.

Template Parameters
ScalarAny value satisfying the IsNumeric concept (integral types and float types)
Parameters
lhsPartial with some input and some output type
rhsSome 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>
PartialDerivative< OutputQuantity, InputQuantity > operator* ( const Scalar & lhs,
const PartialDerivative< OutputQuantity, InputQuantity > & rhs )
friend

Overload of the * operator for a right partial and a left scalar and output types.

Template Parameters
ScalarAny value satisfying the IsNumeric concept (integral types and float types)
Parameters
lhsSome numeric quantity
rhsPartial 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>
PartialDerivative< OutputQuantity, InputQuantity > operator+ ( const PartialDerivative< OutputQuantity, InputQuantity > & lhs,
const PartialDerivative< OutputQuantity, InputQuantity > & rhs )
friend

Overload the + operator between two partials which share the exact same input and output types.

Parameters
lhsOne partial
rhsOther 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>
PartialDerivative< OutputQuantity, InputQuantity > operator- ( const PartialDerivative< OutputQuantity, InputQuantity > & lhs,
const PartialDerivative< OutputQuantity, InputQuantity > & rhs )
friend

Overload the - operator between two partials which share the exact same input and output types.

Parameters
lhsOne partial
rhsOther 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>
PartialDerivative< OutputQuantity, InputQuantity > operator/ ( const PartialDerivative< OutputQuantity, InputQuantity > & lhs,
const Scalar & rhs )
friend

Overload of the / operator for a left partial and a right scalar and output types.

Template Parameters
ScalarAny value satisfying the IsNumeric concept (integral types and float types)
Parameters
lhsPartial with some input and some output type
rhsSome 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>
std::partial_ordering operator<=> ( const PartialDerivative< OutputQuantity, InputQuantity > & lhs,
const PartialDerivative< OutputQuantity, InputQuantity > & rhs )
friend

Partial ordering comparing two partials with exactly the same input and output types.

Parameters
lhsSome Partial
rhsOther 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
ScalarAny value satisfying the IsNumeric concept (integral types and float types)
Parameters
lhsSome numeric quantity
rhsSome 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
ScalarAny value satisfying the IsNumeric concept (integral types and float types)
Parameters
lhsSome numeric quantity
rhsSome partial with an input and output type
Returns
partial ordering comparing rhs.m_value to lhs

Member Data Documentation

◆ m_value

template<ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
double serif::dimensions::PartialDerivative< OutputQuantity, InputQuantity >::m_value
private

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: