forked from mpusz/mp-units
@@ -18,7 +18,7 @@ For example the speed of light constant in :term:`SI` is defined as::
|
||||
|
||||
namespace si::si2019 {
|
||||
|
||||
template<Scalar Rep = double>
|
||||
template<ScalableNumber Rep = double>
|
||||
inline constexpr auto speed_of_light = speed<metre_per_second, Rep>(299792458);
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ The same constant defined for natural units may be provided as::
|
||||
|
||||
namespace natural {
|
||||
|
||||
template<Scalar Rep = double>
|
||||
template<ScalableNumber Rep = double>
|
||||
inline constexpr auto speed_of_light = speed<unitless, Rep>(1);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ each other and the result will always be a quantity of the same dimension:
|
||||
Length auto res2 = dist1 - dist2;
|
||||
|
||||
Additionally, we can always multiply or divide a quantity by a
|
||||
:term:`scalar` and in such a case the quantity's dimension will also
|
||||
:term:`scalable number` and in such a case the quantity's dimension will also
|
||||
not change:
|
||||
|
||||
.. code-block::
|
||||
@@ -35,7 +35,7 @@ not change:
|
||||
Length auto res3 = res2 / 2; // 6 m
|
||||
|
||||
However, if we try to multiply or divide quantities of the same or
|
||||
different dimensions, or we will divide a scalar by a quantity, we most
|
||||
different dimensions, or we will divide a scalable number by a quantity, we most
|
||||
probably will always end up in a quantity of a yet another dimension:
|
||||
|
||||
.. code-block::
|
||||
@@ -50,7 +50,7 @@ probably will always end up in a quantity of a yet another dimension:
|
||||
|
||||
However, please note that there is an exception from the above rule.
|
||||
In case we divide the same dimensions, or multiply by the inverted
|
||||
dimension, than we will end up with just a scalar type:
|
||||
dimension, than we will end up with just a scalable number type:
|
||||
|
||||
.. code-block::
|
||||
:emphasize-lines: 4-5
|
||||
@@ -58,8 +58,8 @@ dimension, than we will end up with just a scalar type:
|
||||
Time auto dur1 = 10q_s;
|
||||
Time auto dur2 = 2q_s;
|
||||
Frequency auto fr1 = 5q_Hz;
|
||||
Scalar auto v1 = dur1 / dur2; // 5
|
||||
Scalar auto v2 = dur1 * fr1; // 50
|
||||
ScalableNumber auto v1 = dur1 / dur2; // 5
|
||||
ScalableNumber auto v2 = dur1 * fr1; // 50
|
||||
|
||||
Quantity points have a more restricted set of operations.
|
||||
Quantity points can't be added together,
|
||||
|
||||
@@ -11,7 +11,7 @@ with a specific representation and is represented in the library with a
|
||||
Quantity Construction
|
||||
---------------------
|
||||
|
||||
To create the quantity object from a :term:`scalar` we just have to pass
|
||||
To create the quantity object from a :term:`scalable number` we just have to pass
|
||||
the value to the `quantity` class template explicit constructor::
|
||||
|
||||
quantity<si::dim_length, si::kilometre, double> d(123);
|
||||
@@ -33,7 +33,7 @@ type to ``double`` by default::
|
||||
|
||||
namespace si {
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
template<Unit U, ScalableNumber Rep = double>
|
||||
using length = quantity<dim_length, U, Rep>;
|
||||
|
||||
}
|
||||
@@ -73,7 +73,8 @@ be used::
|
||||
|
||||
All instances of `quantity` class always match the `Quantity` concept.
|
||||
All other regular types that are not quantities are called
|
||||
:term:`scalars <scalar>` by the library and match the `Scalar` concept.
|
||||
:term:`scalable numbers <scalable number>` by the library and match the
|
||||
`ScalableNumber` concept.
|
||||
|
||||
However, the above is not the most important usage of those concepts. Let's
|
||||
assume that the user wants to implement an ``avg_speed`` function that will
|
||||
@@ -183,7 +184,7 @@ are provided::
|
||||
template<typename T>
|
||||
concept Dimensionless = QuantityOf<T, dim_one>;
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
template<Unit U, ScalableNumber Rep = double>
|
||||
using dimensionless = quantity<dim_one, U, Rep>;
|
||||
|
||||
There are two special units provided for usage with such a quantity:
|
||||
|
||||
Reference in New Issue
Block a user