qtty-cpp 0.4.5
Header-only C++ wrapper for qtty
Loading...
Searching...
No Matches
math.hpp File Reference

Dimension-aware math helpers mirroring the Rust Quantity API. More...

#include <cmath>
#include <type_traits>
#include "units/angular.hpp"
#include "units/dimensionless.hpp"
Include dependency graph for math.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  qtty
 

Functions

template<typename U >
Ratio qtty::ratio_to (const Quantity< U > &a, const Quantity< U > &b)
 Same-unit division returning a typed dimensionless Ratio.
 
template<typename U , std::enable_if_t< is_dimensionless_v< U >, int > = 0>
Ratio qtty::exp (const Quantity< U > &q)
 
template<typename U , std::enable_if_t< is_dimensionless_v< U >, int > = 0>
Ratio qtty::ln (const Quantity< U > &q)
 
template<typename U , std::enable_if_t< is_dimensionless_v< U >, int > = 0>
Ratio qtty::powi (const Quantity< U > &q, int n)
 
template<typename U , std::enable_if_t< is_dimensionless_v< U >, int > = 0>
Ratio qtty::powf (const Quantity< U > &q, const Ratio &exponent)
 
template<typename U , std::enable_if_t< is_dimensionless_v< U >, int > = 0>
Radian qtty::asin_angle (const Quantity< U > &q)
 
template<typename U , std::enable_if_t< is_dimensionless_v< U >, int > = 0>
Radian qtty::acos_angle (const Quantity< U > &q)
 
template<typename U , std::enable_if_t< is_dimensionless_v< U >, int > = 0>
Radian qtty::atan_angle (const Quantity< U > &q)
 

Detailed Description

Dimension-aware math helpers mirroring the Rust Quantity API.

These mirror the Rust methods that change the dimension of the result and therefore cannot live as plain members of Quantity (which is unit-tag agnostic). They are provided as free functions:

Rust C++ q.ratio_to(other) qtty::ratio_to(q, other) q.exp() qtty::exp(q) q.ln() qtty::ln(q) q.powi(n) qtty::powi(q, n) q.powf(exp) qtty::powf(q, exp) q.sin() qtty::sin(q) q.cos() qtty::cos(q) q.tan() qtty::tan(q) q.asin_angle() qtty::asin_angle(q) q.acos_angle() qtty::acos_angle(q) q.atan_angle() qtty::atan_angle(q)

The transcendental helpers are constrained to dimensionless inputs, matching the Rust trait bounds (U: Unit<Dim = Dimensionless>).

Definition in file math.hpp.