|
wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
|
#include <algorithm>#include <cmath>#include <ostream>#include <tuple>#include <type_traits>#include <utility>#include "wuzp/core/Integer.hpp"#include "wuzp/core/MatrixSize.hpp"#include "wuzp/core/Quantity.hpp"#include "wuzp/core/Rational.hpp"#include "wuzp/core/TypeMatrix.hpp"#include "wuzp/core/Units.hpp"#include "wuzp/core/ValuesWrapper.hpp"#include "wuzp/core/concepts.hpp"#include "wuzp/core/helpers.hpp"#include "wuzp/core/internal/powers.hpp"#include "wuzp/core/traits.hpp"Go to the source code of this file.
Namespaces | |
| namespace | wuzp |
Functions | |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::sum (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::operator+ (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::difference (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::operator- (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::negation (const Quantities< ValuesT_, UnitsT_ > &rhs) |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::operator- (const Quantities< ValuesT_, UnitsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValueRhsT_> | |
| auto | wuzp::product (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const ValueRhsT_ rhs) |
| template<typename ValueLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::product (const ValueLhsT_ lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename MatrixSizeRhsT_, typename ValueRhsT_, typename ImplementationRhsT_> | |
| auto | wuzp::product (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const ValuesWrapper< MatrixSizeRhsT_, ValueRhsT_, ImplementationRhsT_ > &rhs) |
| template<typename MatrixSizeLhsT_, typename ValueLhsT_, typename ImplementationLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::product (const ValuesWrapper< MatrixSizeLhsT_, ValueLhsT_, ImplementationLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::product (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| The elementwise product of quantities of the same size, or with a quantity. | |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValueRhsT_> | |
| auto | wuzp::operator* (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const ValueRhsT_ rhs) |
| template<typename ValueLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::operator* (const ValueLhsT_ lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename MatrixSizeRhsT_, typename ValueRhsT_, typename ImplementationRhsT_> | |
| auto | wuzp::operator* (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const ValuesWrapper< MatrixSizeRhsT_, ValueRhsT_, ImplementationRhsT_ > &rhs) |
| template<typename MatrixSizeLhsT_, typename ValueLhsT_, typename ImplementationLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::operator* (const ValuesWrapper< MatrixSizeLhsT_, ValueLhsT_, ImplementationLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::operator* (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::innerProduct (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::outerProduct (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValueRhsT_> | |
| auto | wuzp::division (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const ValueRhsT_ rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename MatrixSizeRhsT_, typename ValueRhsT_, typename ImplementationRhsT_> | |
| auto | wuzp::division (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const ValuesWrapper< MatrixSizeRhsT_, ValueRhsT_, ImplementationRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValueRhsT_, typename UnitRhsT_> | |
| auto | wuzp::division (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantity< ValueRhsT_, UnitRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| auto | wuzp::division (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| The elementwise quotient of quantities of the same size. | |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValueRhsT_> | |
| auto | wuzp::operator/ (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const ValueRhsT_ rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename MatrixSizeRhsT_, typename ValueRhsT_, typename ImplementationRhsT_> | |
| auto | wuzp::operator/ (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const ValuesWrapper< MatrixSizeRhsT_, ValueRhsT_, ImplementationRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValueRhsT_, typename UnitRhsT_> | |
| auto | wuzp::operator/ (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantity< ValueRhsT_, UnitRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| bool | wuzp::operator== (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesLhsT_, typename UnitsLhsT_, typename ValuesRhsT_, typename UnitsRhsT_> | |
| bool | wuzp::operator!= (const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs) |
| template<typename ValuesT_, typename UnitsT_> | |
| std::ostream & | wuzp::operator<< (std::ostream &lhs, const Quantities< ValuesT_, UnitsT_ > &rhs) |
| template<typename ExponentT_, typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::pow (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| The quantities raised to a rational power P/Q, elementwise, e.g. pow<Rational<1, 2>>(area) is a length, and pow<2>() of a length and a time is an area and a squared time. | |
| template<int ExponentV_, typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::pow (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| template<int ExponentDividendV_, int ExponentDivisorV_, typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::pow (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::sqrt (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| The square root, elementwise: pow<1, 2>(), computed with std::sqrt (https://en.cppreference.com/w/cpp/numeric/math/sqrt), e.g. the square root of an area is a length. | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::cbrt (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| The cube root, elementwise: pow<1, 3>(), computed with std::cbrt (https://en.cppreference.com/w/cpp/numeric/math/cbrt), e.g. the cube root of a volume is a length. | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::abs (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| The absolute value, elementwise, of the same unit, like std::abs (https://en.cppreference.com/w/cpp/numeric/math/fabs), and the values themselves for unsigned values, for which std::abs is ambiguous. | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::sin (const Quantities< ValuesT_, UnitsT_ > &angles) |
| The sine of angles in radians, elementwise, like std::sin (https://en.cppreference.com/w/cpp/numeric/math/sin): dimensionless quantities. | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::cos (const Quantities< ValuesT_, UnitsT_ > &angles) |
| The cosine of angles in radians, elementwise, like std::cos (https://en.cppreference.com/w/cpp/numeric/math/cos), see sin(). | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::tan (const Quantities< ValuesT_, UnitsT_ > &angles) |
| The tangent of angles in radians, elementwise, like std::tan (https://en.cppreference.com/w/cpp/numeric/math/tan), see sin(). | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::asin (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| The arc sine of dimensionless quantities, elementwise, like std::asin (https://en.cppreference.com/w/cpp/numeric/math/asin): the angles in [-pi/2, pi/2] in radians, which are dimensionless (see "Angles are dimensionless" in DESIGN.md). | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::acos (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| The arc cosine of dimensionless quantities, elementwise, like std::acos (https://en.cppreference.com/w/cpp/numeric/math/acos): the angles in [0, pi] in radians, see asin(). | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::atan (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| The arc tangent of dimensionless quantities, elementwise, like std::atan (https://en.cppreference.com/w/cpp/numeric/math/atan): the angles in [-pi/2, pi/2] in radians, see asin(). | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::exp (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| The exponential function e^x of dimensionless quantities, elementwise, like std::exp (https://en.cppreference.com/w/cpp/numeric/math/exp): not the matrix exponential of a matrix. | |
| template<typename ValuesT_, typename UnitsT_> | |
| auto | wuzp::log (const Quantities< ValuesT_, UnitsT_ > &quantities) |
| The natural logarithm of dimensionless quantities, elementwise, like std::log (https://en.cppreference.com/w/cpp/numeric/math/log): NaN for negative values, and -infinity for zero. | |
| template<typename ValuesYT_, typename UnitYT_, typename ValuesXT_, typename UnitXT_> | |
| auto | wuzp::atan2 (const Quantity< ValuesYT_, UnitYT_ > &y, const Quantity< ValuesXT_, UnitXT_ > &x) |
| The angle of the point (x, y) from the positive x axis, in [-pi, pi] in radians, of two quantities with the same unit, e.g. lengths, like std::atan2 (https://en.cppreference.com/w/cpp/numeric/math/atan2): y comes first, the angle is counterclockwise from the x axis to the y axis, and its branch cut is the negative x axis, where it is pi for y = +0 and -pi for y = -0. | |
| template<typename ValuesXT_, typename UnitXT_, typename ValuesYT_, typename UnitYT_> | |
| auto | wuzp::hypot (const Quantity< ValuesXT_, UnitXT_ > &x, const Quantity< ValuesYT_, UnitYT_ > &y) |
| The length sqrt(x^2 + y^2) of two quantities with the same unit, e.g. the components of a vector, without overflow or underflow in the intermediate steps, like std::hypot (https://en.cppreference.com/w/cpp/numeric/math/hypot). | |
| template<typename ValuesLhsT_, typename UnitLhsT_, typename ValuesRhsT_, typename UnitRhsT_> | |
| auto | wuzp::min (const Quantity< ValuesLhsT_, UnitLhsT_ > &lhs, const Quantity< ValuesRhsT_, UnitRhsT_ > &rhs) |
| The smaller of two quantities with the same unit, like std::min (https://en.cppreference.com/w/cpp/algorithm/min), which returns lhs if neither is smaller, e.g. if one is NaN. | |
| template<typename ValuesT_, typename UnitT_> | |
| auto | wuzp::min (const Quantity< ValuesT_, UnitT_ > &lhs, const Quantity< ValuesT_, UnitT_ > &rhs) |
| min() of two quantities of the same type. | |
| template<typename ValuesLhsT_, typename UnitLhsT_, typename ValuesRhsT_, typename UnitRhsT_> | |
| auto | wuzp::max (const Quantity< ValuesLhsT_, UnitLhsT_ > &lhs, const Quantity< ValuesRhsT_, UnitRhsT_ > &rhs) |
| The larger of two quantities with the same unit, like std::max (https://en.cppreference.com/w/cpp/algorithm/max), which returns lhs if neither is larger, e.g. if one is NaN. | |
| template<typename ValuesT_, typename UnitT_> | |
| auto | wuzp::max (const Quantity< ValuesT_, UnitT_ > &lhs, const Quantity< ValuesT_, UnitT_ > &rhs) |
| max() of two quantities of the same type, see min(). | |