-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.. _natural-unit-class: | ||
|
||
Natural Unit | ||
============ | ||
|
||
.. ditaa:: | ||
|
||
+----------------+----------------+ | ||
| quantity | xquantity | | ||
+----------------+----------------+ | ||
| scaled_unit | | ||
+---------------------------------+ | ||
|cYEL natural_unit | | ||
+---------------------------------+ | ||
| bpu | | ||
+----------------+ | | ||
| bu_store | | | ||
+----------------+----------------+ | ||
| basis_unit | | ||
+---------------------------------+ | ||
| dimension | | ||
+---------------------------------+ | ||
|
||
.. code-block:: cpp | ||
#include <xo/unit/natural_unit.hpp> | ||
Representation for the unit associated with a @ref quantity or xquantity. | ||
|
||
- represents a cartesian product of basis units. | ||
- constexpr implementation | ||
- limited support for fractional dimensions such as time^-1/2 | ||
|
||
.. doxygenclass:: xo::qty::natural_unit | ||
|
||
.. doxygengroup:: natural-unit-instance-vars | ||
.. doxygengroup:: natural-unit-ctors | ||
.. doxygengroup:: natural-unit-access-methods | ||
.. doxygengroup:: natural-unit-methods | ||
.. doxygengroup:: natural-unit-conversion-methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.. _scaled-unit-class: | ||
|
||
Scaled Unit | ||
=========== | ||
|
||
.. ditaa:: | ||
|
||
+----------------+----------------+ | ||
| quantity | xquantity | | ||
+----------------+----------------+ | ||
|cYEL scaled_unit | | ||
+---------------------------------+ | ||
| natural_unit | | ||
+---------------------------------+ | ||
| bpu | | ||
+----------------+ | | ||
| bu_store | | | ||
+----------------+----------------+ | ||
| basis_unit | | ||
+---------------------------------+ | ||
| dimension | | ||
+---------------------------------+ | ||
|
||
|
||
.. code-block::cpp | ||
#include <xo/unit/scaled_unit.hpp> | ||
Result of mutliplication or division of natural units (:doc:`natural-unit-class`). | ||
|
||
Motivation | ||
---------- | ||
|
||
Consider multiplying two units: | ||
|
||
.. code-block:: cpp | ||
using namespace xo::qty; | ||
constexpr auto u_prod = u::meter * u::kilometer; | ||
How should we represent the product? | ||
|
||
We don't want to mix units. Instead we consolidate on a common unit; | ||
to do this we accumulate a product of conversion factors from such consolidation. | ||
|
||
For example: | ||
|
||
.. code-block:: cpp | ||
static_assert(u_prod.natural_unit[0].bu() == detail::bu::meter); | ||
static_assert(u_prod.natural_unit[0].power() == power_ratio_type(2)); | ||
static_assert(u_prod.outer_scale_factor_ == xo::ratio::ratio<int64_t>(1000)); | ||
static_assert(u_prod.outer_scale_sq_ == 1.0); // used if fractional dimension | ||
Class | ||
----- | ||
|
||
.. doxygenclass:: xo::qty::scaled_unit |