mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-25 01:01:33 +02:00
check: run pre-commit on all files
This commit is contained in:
@ -86,7 +86,7 @@ EmptyLineBeforeAccessModifier: Leave
|
||||
# IfMacros:
|
||||
# - KJ_IF_MAYBE
|
||||
IncludeBlocks: Merge
|
||||
IncludeCategories:
|
||||
IncludeCategories:
|
||||
- Regex: '^".*'
|
||||
Priority: 1
|
||||
- Regex: '^".+/.*'
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -42,4 +42,4 @@ _build/
|
||||
|
||||
# Conan
|
||||
*.pyc
|
||||
/test_package/build/
|
||||
/test_package/build/
|
||||
|
@ -2,9 +2,9 @@
|
||||
find_program(SPHINX_EXECUTABLE
|
||||
NAMES sphinx-build
|
||||
DOC "Path to sphinx-build executable")
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
|
||||
# Handle standard arguments to find_package like REQUIRED and QUIET
|
||||
find_package_handle_standard_args(Sphinx
|
||||
"Failed to find sphinx-build executable"
|
||||
|
@ -39,27 +39,27 @@ endmacro()
|
||||
# [ACCOUNT_FOR_MODULES]
|
||||
# [PREFIXES prefixes...]
|
||||
# )
|
||||
#
|
||||
#
|
||||
# BASE_DIR
|
||||
# Set this option to ${CMAKE_BINARY_DIR} if you use FetchContent a lot for many projects with the same build options.
|
||||
# Otherwise, if most of the sources come from the project itself then the default ${CMAKE_SOURCE_DIR} may be
|
||||
# a better choice.
|
||||
#
|
||||
#
|
||||
# ACCOUNT_FOR_COMPILE_TIME_HEADER_CHANGES
|
||||
# Use it if some header files are being generated by the compilation process.
|
||||
#
|
||||
#
|
||||
# ACCOUNT_FOR_PCH
|
||||
# Use it if precompiled headers are enabled in your project. Automatically includes uses
|
||||
# ACCOUNT_FOR_COMPILE_TIME_HEADER_CHANGES as well.
|
||||
# See here for details: https://ccache.dev/manual/4.2.1.html#_precompiled_headers
|
||||
#
|
||||
#
|
||||
# ACCOUNT_FOR_MODULES
|
||||
# Use it for projects with C++20 modules. Requires DIRECT_DEPEND mode.
|
||||
#
|
||||
# PREFIXES
|
||||
# A list of other tools that should be used together with ccache as a compiler launcher
|
||||
# (i.e. distcc, icecc, sccache-dist, ...).
|
||||
#
|
||||
#
|
||||
function(enable_ccache)
|
||||
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
message(FATAL_ERROR "'enable_ccache' function should be called from the top-level CMakeLists.txt file!")
|
||||
@ -86,7 +86,7 @@ function(enable_ccache)
|
||||
message(FATAL_ERROR "'MODE' should be one of ${_valid_mode_values}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT _enable_ccache_QUIET)
|
||||
message(STATUS "Enabling ccache")
|
||||
endif()
|
||||
|
2
docs/_static/img/concepts.svg
vendored
2
docs/_static/img/concepts.svg
vendored
@ -113,4 +113,4 @@ JVM: Java HotSpot(TM) 64-Bit Server VM
|
||||
Default Encoding: UTF-8
|
||||
Language: en
|
||||
Country: US
|
||||
--></g></svg>
|
||||
--></g></svg>
|
||||
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
4
docs/_static/img/dimensions.svg
vendored
4
docs/_static/img/dimensions.svg
vendored
@ -18,7 +18,7 @@ package Dimension <<Frame>> {
|
||||
abstract base_dimension<Symbol, Unit> [[../../framework/units.html]]
|
||||
abstract exponent<Dimension, Num, Den> [[../../framework/dimensions.html#derived-dimensions]]
|
||||
abstract derived_dimension<Unit, Exponent...> [[../../framework/dimensions.html#derived-dimensions]]
|
||||
|
||||
|
||||
base_dimension <.. exponent
|
||||
exponent <.. "0..n" derived_dimension
|
||||
exponent ..> derived_dimension
|
||||
@ -32,4 +32,4 @@ JVM: Java HotSpot(TM) 64-Bit Server VM
|
||||
Default Encoding: UTF-8
|
||||
Language: en
|
||||
Country: US
|
||||
--></g></svg>
|
||||
--></g></svg>
|
||||
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
6
docs/_static/img/units.svg
vendored
6
docs/_static/img/units.svg
vendored
@ -58,7 +58,7 @@ package Unit <<Frame>> [[../../framework/units.html]] {
|
||||
abstract named_scaled_unit<Symbol, PrefixFamily, Ratio, Unit> [[../../framework/units.html#named-scaled-units]]
|
||||
abstract named_unit<Symbol, PrefixFamily> [[../../framework/units.html#base-units]]
|
||||
abstract unit [[../../framework/units.html#derived-unnamed-units]]
|
||||
|
||||
|
||||
scaled_unit <|- - unit
|
||||
scaled_unit <|- - named_unit
|
||||
scaled_unit <|- - named_scaled_unit
|
||||
@ -100,7 +100,7 @@ package Unit <<Frame>> [[../../framework/units.html]] {
|
||||
abstract named_scaled_unit<Symbol, PrefixFamily, Ratio, Unit> [[../../framework/units.html#named-scaled-units]]
|
||||
abstract named_unit<Symbol, PrefixFamily> [[../../framework/units.html#base-units]]
|
||||
abstract unit [[../../framework/units.html#derived-unnamed-units]]
|
||||
|
||||
|
||||
scaled_unit <|- - unit
|
||||
scaled_unit <|- - named_unit
|
||||
scaled_unit <|- - named_scaled_unit
|
||||
@ -119,4 +119,4 @@ JVM: Java HotSpot(TM) 64-Bit Server VM
|
||||
Default Encoding: UTF-8
|
||||
Language: en
|
||||
Country: US
|
||||
--></g></svg>
|
||||
--></g></svg>
|
||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
@ -345,7 +345,7 @@ html_static_path = ['_static']
|
||||
# configuration directory) that is the logo of the docs. It is placed at the
|
||||
# top of the sidebar; its width should therefore not exceed 200 pixels.
|
||||
# Default: None.
|
||||
# html_logo =
|
||||
# html_logo =
|
||||
|
||||
# These paths are either relative to html_static_path or fully qualified
|
||||
# paths (eg. https://...)
|
||||
@ -359,10 +359,10 @@ html_css_files = [
|
||||
def configureDoxyfile(input_dir, output_dir):
|
||||
with open('Doxyfile.in', 'r') as file:
|
||||
filedata = file.read()
|
||||
|
||||
|
||||
filedata = filedata.replace('@DOXYGEN_INPUT_DIR@', input_dir)
|
||||
filedata = filedata.replace('@DOXYGEN_OUTPUT_DIR@', output_dir)
|
||||
|
||||
|
||||
with open('Doxyfile', 'w') as file:
|
||||
file.write(filedata)
|
||||
|
||||
|
@ -45,7 +45,7 @@ to use inheritance:
|
||||
.. image:: /_static/img/downcast_1.png
|
||||
:align: center
|
||||
|
||||
..
|
||||
..
|
||||
http://www.nomnoml.com
|
||||
|
||||
[derived_dimension_base<exponent<si::dim_length, 2>>]<:-[dim_area]
|
||||
@ -76,7 +76,7 @@ The downcasting facility is provided by injecting two classes into our hierarchy
|
||||
.. image:: /_static/img/downcast_2.png
|
||||
:align: center
|
||||
|
||||
..
|
||||
..
|
||||
http://www.nomnoml.com
|
||||
|
||||
[downcast_base<detail::derived_dimension_base<exponent<si::dim_length, 2>>>]<:-[detail::derived_dimension_base<exponent<si::dim_length, 2>>]
|
||||
@ -93,7 +93,7 @@ In the above example:
|
||||
idiom, stores the base of a downcasting operation in a ``downcast_base_type`` member type,
|
||||
and provides only a Hidden Friend non-member function declaration of ``downcast_guide`` which is an
|
||||
:abbr:`ADL (Argument Dependent Lookup)` entry point for the downcasting operation::
|
||||
|
||||
|
||||
template<typename BaseType>
|
||||
struct downcast_base {
|
||||
using downcast_base_type = BaseType;
|
||||
|
@ -13,7 +13,7 @@ The most important concepts in the library are `Unit`, `Dimension`,
|
||||
|
||||
..
|
||||
https://www.planttext.com
|
||||
|
||||
|
||||
@startuml
|
||||
|
||||
skinparam monochrome true
|
||||
|
@ -12,7 +12,7 @@ dimensions.
|
||||
|
||||
<object data="../_images/dimensions.svg" type="image/svg+xml" class="align-center" style="max-width: 100%;"></object>
|
||||
|
||||
..
|
||||
..
|
||||
https://www.planttext.com
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ Quantity Construction Helpers
|
||||
quantities of different dimensions and units. Users are encourages to try them
|
||||
out, vote, and share feedback in this
|
||||
`discussion on GitHub <https://github.com/mpusz/units/discussions/274>`_.
|
||||
|
||||
|
||||
Most probably only one of the options will be included in the final product so
|
||||
please do not hesitate to vote on the one that suits you the best.
|
||||
|
||||
@ -83,7 +83,7 @@ each and every :term:`unit` in the library::
|
||||
|
||||
template<Representation Rep = double> using m_per_s = units::isq::si::speed<units::isq::si::metre_per_second, Rep>;
|
||||
template<Representation Rep = double> using km_per_h = units::isq::si::speed<units::isq::si::kilometre_per_hour, Rep>;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // UNITS_NO_ALIASES
|
||||
@ -159,7 +159,7 @@ It is also possible to easily define custom quantity references from existing on
|
||||
|
||||
User Defined Literals (Experimental)
|
||||
++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
Alternatively, to construct quantities with compile-time known values the library provides
|
||||
:abbr:`UDL (User Defined Literal)` s for each :term:`unit` of every :term:`dimension`::
|
||||
|
||||
@ -191,7 +191,7 @@ Thanks to them the same code can be as simple as::
|
||||
language (i.e. ``F`` (farad), ``J`` (joule), ``W`` (watt), ``K`` (kelvin),
|
||||
``d`` (day), ``l`` or ``L`` (litre), ``erg``, ``ergps``). This is why the
|
||||
``_q_`` prefix was consistently applied to all the UDLs.
|
||||
|
||||
|
||||
UDLs vs Quantity References
|
||||
+++++++++++++++++++++++++++
|
||||
|
||||
@ -258,12 +258,12 @@ UDLs are helpful but they also have some disadvantages compared to Quantity Refe
|
||||
4. UDLs are verbose to define and standardize
|
||||
|
||||
- UDLs:
|
||||
|
||||
|
||||
- for each unit an integral and a floating-point UDL have to be defined
|
||||
- have to be provided for unnamed derived units (i.e. ``_q_km_per_h``)
|
||||
|
||||
|
||||
- Quantity References:
|
||||
|
||||
|
||||
- one reference per unit
|
||||
- unnamed derived units are constructed from base references so no explicit
|
||||
definition is required (i.e. ``km / h``)
|
||||
@ -276,9 +276,9 @@ UDLs are helpful but they also have some disadvantages compared to Quantity Refe
|
||||
by the user so there is no chance for a truncating conversion on a quantity construction.
|
||||
|
||||
6. UDLs take long to compile
|
||||
|
||||
|
||||
- UDLs:
|
||||
|
||||
|
||||
Every unit requires two UDLs to be defined which in turns requires two instantiations
|
||||
of "heavy" `quantity` class template. Those are then not often used by non-UDL construction
|
||||
as most users instantiate `quantity` class template with `int` or `double` which
|
||||
@ -298,7 +298,7 @@ Quantity References vs Unit-specific Aliases
|
||||
++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
1. Shadowing issues
|
||||
|
||||
|
||||
- Quantity References
|
||||
|
||||
References occupy a pool of many short identifiers which sometimes shadow the variables,
|
||||
@ -357,11 +357,11 @@ Quantity References vs Unit-specific Aliases
|
||||
using namespace units::isq::si::time_references;
|
||||
return d * m / (t * s);
|
||||
}
|
||||
|
||||
|
||||
Notice that if ``using namespace units::isq::si::references;`` was used instead above it could
|
||||
cause a clash of ``t`` function parameter with ``si::tonne`` unit symbol if ``si/mass.h`` was
|
||||
included.
|
||||
|
||||
|
||||
- Unit-specific Aliases
|
||||
|
||||
The same using aliases can look as follows::
|
||||
@ -392,7 +392,7 @@ Quantity References vs Unit-specific Aliases
|
||||
static_assert(2 * km / (2 * (km / h)) == 1 * h);
|
||||
|
||||
- Unit-specific Aliases
|
||||
|
||||
|
||||
Aliases do not use operator syntax thus they are not affected by the precedence issue.
|
||||
|
||||
5. Composition for unnamed derived units
|
||||
@ -425,7 +425,7 @@ Quantity References vs Unit-specific Aliases
|
||||
|
||||
constexpr auto meter = 1 * m;
|
||||
std::cout << " = " << quantity_cast<si::international::foot>(meter) << '\n';
|
||||
|
||||
|
||||
The above code for references may look as follows::
|
||||
|
||||
constexpr auto meter = m(1);
|
||||
|
@ -25,7 +25,7 @@ of a `scaled_unit` class template:
|
||||
|
||||
<object data="../_images/units.svg" type="image/svg+xml" class="align-center" style="max-width: 100%;"></object>
|
||||
|
||||
..
|
||||
..
|
||||
https://www.planttext.com
|
||||
|
||||
@startuml
|
||||
@ -65,7 +65,7 @@ of a `scaled_unit` class template:
|
||||
abstract named_scaled_unit<Symbol, PrefixFamily, Ratio, Unit> [[../../framework/units.html#named-scaled-units]]
|
||||
abstract named_unit<Symbol, PrefixFamily> [[../../framework/units.html#base-units]]
|
||||
abstract unit [[../../framework/units.html#derived-unnamed-units]]
|
||||
|
||||
|
||||
scaled_unit <|-- unit
|
||||
scaled_unit <|-- named_unit
|
||||
scaled_unit <|-- named_scaled_unit
|
||||
@ -209,7 +209,7 @@ and define units like::
|
||||
struct electronvolt : named_scaled_unit<electronvolt, "eV", prefix,
|
||||
ratio(1'602'176'634, 1'000'000'000, -19), joule> {};
|
||||
|
||||
..
|
||||
..
|
||||
TODO Submit a bug for above lexing problem
|
||||
|
||||
Finally, the last of the `named_scaled_unit` class template parameters
|
||||
@ -256,16 +256,16 @@ Alternative hierarchy of prefixes is the one used in data information
|
||||
domain::
|
||||
|
||||
namespace iec80000 {
|
||||
|
||||
|
||||
struct binary_prefix : prefix_family {};
|
||||
|
||||
|
||||
struct kibi : units::prefix<kibi, binary_prefix, "Ki", ratio( 1'024)> {};
|
||||
struct mebi : units::prefix<mebi, binary_prefix, "Mi", ratio( 1'048'576)> {};
|
||||
struct gibi : units::prefix<gibi, binary_prefix, "Gi", ratio( 1'073'741'824)> {};
|
||||
struct tebi : units::prefix<tebi, binary_prefix, "Ti", ratio( 1'099'511'627'776)> {};
|
||||
struct pebi : units::prefix<pebi, binary_prefix, "Pi", ratio( 1'125'899'906'842'624)> {};
|
||||
struct exbi : units::prefix<exbi, binary_prefix, "Ei", ratio(1'152'921'504'606'846'976)> {};
|
||||
|
||||
|
||||
}
|
||||
|
||||
With the definitions like above we can easily define prefixed unit. For
|
||||
|
@ -48,20 +48,20 @@ of basic library features::
|
||||
#include <units/isq/si/time.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace units::isq;
|
||||
|
||||
|
||||
constexpr Speed auto avg_speed(Length auto d, Time auto t)
|
||||
{
|
||||
return d / t;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::isq::si::literals;
|
||||
using namespace units::isq::si::references;
|
||||
using namespace units::aliases::isq::si::international;
|
||||
|
||||
|
||||
constexpr Speed auto v1 = 110 * (km / h);
|
||||
constexpr Speed auto v2 = mi_per_h(70.);
|
||||
constexpr Speed auto v3 = avg_speed(220_q_km, 2_q_h);
|
||||
@ -69,7 +69,7 @@ of basic library features::
|
||||
constexpr Speed auto v5 = quantity_cast<si::speed<si::metre_per_second>>(v3);
|
||||
constexpr Speed auto v6 = quantity_cast<si::metre_per_second>(v4);
|
||||
constexpr Speed auto v7 = quantity_cast<int>(v6);
|
||||
|
||||
|
||||
std::cout << v1 << '\n'; // 110 km/h
|
||||
std::cout << v2 << '\n'; // 70 mi/h
|
||||
std::cout << std::format("{}", v3) << '\n'; // 110 km/h
|
||||
|
@ -144,11 +144,11 @@ Concepts
|
||||
.. concept:: template<typename QK1, typename QK2> QuantityKindEquivalentTo
|
||||
|
||||
A concept matching two equivalent quantity kinds. Satisfied by quantity kinds having equivalent kinds.
|
||||
|
||||
|
||||
.. concept:: template<typename QPK, typename PK> QuantityPointKindOf
|
||||
|
||||
|
||||
A concept matching only quantity point kinds of a specific point kind.
|
||||
|
||||
|
||||
:tparam QPK: Quantity point kind to verify.
|
||||
:tparam PK: Point kind type to use for verification.
|
||||
|
||||
|
@ -12,7 +12,7 @@ International System of Quantities (ISQ)
|
||||
|
||||
Systems of Units based on the SI
|
||||
--------------------------------
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
using namespace units::aliases::isq;
|
||||
|
||||
// Some basic specs for the warship
|
||||
// Some basic specs for the warship
|
||||
struct Ship {
|
||||
si::fps::length::ft<> length;
|
||||
si::fps::length::ft<> draft;
|
||||
@ -45,7 +45,7 @@ struct Ship {
|
||||
si::fps::speed::ft_per_s<> speed;
|
||||
si::fps::mass::lb<> mass;
|
||||
|
||||
si::fps::length::in<> mainGuns;
|
||||
si::fps::length::in<> mainGuns;
|
||||
si::fps::mass::lb<> shellMass;
|
||||
si::fps::speed::ft_per_s<> shellSpeed;
|
||||
si::fps::power::ft_pdl_per_s<> power;
|
||||
@ -80,7 +80,7 @@ int main()
|
||||
using namespace units::aliases::isq::si;
|
||||
using namespace units::aliases::isq::si::fps;
|
||||
using units::aliases::isq::si::fps::length::ft; // to disambiguate from si::femptotonne
|
||||
|
||||
|
||||
// KMS Bismark, using the units the Germans would use, taken from Wiki
|
||||
auto bismark = Ship{.length{m<>(251.)}, .draft{m<>(9.3)}, .beam{m<>(36)}, .speed{km_per_h<>(56)}, .mass{t<>(50'300)}, .mainGuns{mm<>(380)}, .shellMass{kg<>(800)}, .shellSpeed{m_per_s<>(820.)}, .power{kW<>(110.45)}};
|
||||
|
||||
|
@ -157,7 +157,7 @@ void matrix_of_quantity_add()
|
||||
void matrix_of_quantity_multiply_same()
|
||||
{
|
||||
std::cout << "\nmatrix_of_quantity_multiply_same:\n";
|
||||
|
||||
|
||||
matrix<length::m<>> v = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }};
|
||||
vector<length::m<>> u = { m<>(3), m<>(2), m<>(1) };
|
||||
|
||||
@ -304,7 +304,7 @@ void quantity_of_matrix_add()
|
||||
void quantity_of_matrix_multiply_same()
|
||||
{
|
||||
std::cout << "\nquantity_of_matrix_multiply_same:\n";
|
||||
|
||||
|
||||
length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }});
|
||||
length_v<> u(vector<>{ 3, 2, 1 });
|
||||
|
||||
|
@ -73,7 +73,7 @@ int main()
|
||||
|
||||
const auto process_noise_variance = 0.0001 * (deg_C * deg_C);
|
||||
const estimation initial = { state{ quantity_point(10. * deg_C) }, pow<2>(100. * deg_C) };
|
||||
const std::array measurements = {
|
||||
const std::array measurements = {
|
||||
quantity_point(49.95 * deg_C),
|
||||
quantity_point(49.967 * deg_C),
|
||||
quantity_point(50.1 * deg_C),
|
||||
|
@ -73,7 +73,7 @@ int main()
|
||||
|
||||
const auto process_noise_variance = 0.0001 * (deg_C * deg_C);
|
||||
const estimation initial = { state{ quantity_point(10. * deg_C) }, pow<2>(100. * deg_C) };
|
||||
const std::array measurements = {
|
||||
const std::array measurements = {
|
||||
quantity_point(50.45 * deg_C),
|
||||
quantity_point(50.967 * deg_C),
|
||||
quantity_point(51.6 * deg_C),
|
||||
|
@ -73,7 +73,7 @@ int main()
|
||||
|
||||
const auto process_noise_variance = 0.15 * (deg_C * deg_C);
|
||||
const estimation initial = { state{ quantity_point(10. * deg_C) }, pow<2>(100. * deg_C) };
|
||||
const std::array measurements = {
|
||||
const std::array measurements = {
|
||||
quantity_point(50.45 * deg_C),
|
||||
quantity_point(50.967 * deg_C),
|
||||
quantity_point(51.6 * deg_C),
|
||||
|
@ -37,7 +37,7 @@
|
||||
using namespace units::isq;
|
||||
|
||||
|
||||
// Some basic specs for the warship
|
||||
// Some basic specs for the warship
|
||||
struct Ship {
|
||||
si::fps::length<si::fps::foot> length;
|
||||
si::fps::length<si::fps::foot> draft;
|
||||
@ -46,7 +46,7 @@ struct Ship {
|
||||
si::fps::speed<si::fps::foot_per_second> speed;
|
||||
si::fps::mass<si::fps::pound> mass;
|
||||
|
||||
si::fps::length<si::fps::inch> mainGuns;
|
||||
si::fps::length<si::fps::inch> mainGuns;
|
||||
si::fps::mass<si::fps::pound> shellMass;
|
||||
si::fps::speed<si::fps::foot_per_second> shellSpeed;
|
||||
si::fps::power<si::fps::foot_poundal_per_second> power;
|
||||
@ -81,7 +81,7 @@ int main()
|
||||
{
|
||||
using namespace units::isq::si::literals;
|
||||
using namespace units::isq::si::fps::literals;
|
||||
|
||||
|
||||
// KMS Bismark, using the units the Germans would use, taken from Wiki
|
||||
auto bismark = Ship{.length{251._q_m}, .draft{9.3_q_m}, .beam{36_q_m}, .speed{56_q_km_per_h}, .mass{50'300_q_t}, .mainGuns{380_q_mm}, .shellMass{800_q_kg}, .shellSpeed{820._q_m_per_s}, .power{110.45_q_kW}};
|
||||
|
||||
|
@ -158,7 +158,7 @@ void matrix_of_quantity_add()
|
||||
void matrix_of_quantity_multiply_same()
|
||||
{
|
||||
std::cout << "\nmatrix_of_quantity_multiply_same:\n";
|
||||
|
||||
|
||||
matrix<si::length<si::metre>> v = {{ 1_q_m, 2_q_m, 3_q_m }, { 4_q_m, 5_q_m, 6_q_m }, { 7_q_m, 8_q_m, 9_q_m }};
|
||||
vector<si::length<si::metre>> u = { 3_q_m, 2_q_m, 1_q_m };
|
||||
|
||||
@ -303,7 +303,7 @@ void quantity_of_matrix_add()
|
||||
void quantity_of_matrix_multiply_same()
|
||||
{
|
||||
std::cout << "\nquantity_of_matrix_multiply_same:\n";
|
||||
|
||||
|
||||
length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }});
|
||||
length_v<> u(vector<>{ 3, 2, 1 });
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
using namespace units::isq;
|
||||
|
||||
|
||||
// Some basic specs for the warship
|
||||
// Some basic specs for the warship
|
||||
struct Ship {
|
||||
si::fps::length<si::fps::foot> length;
|
||||
si::fps::length<si::fps::foot> draft;
|
||||
@ -49,7 +49,7 @@ struct Ship {
|
||||
si::fps::speed<si::fps::foot_per_second> speed;
|
||||
si::fps::mass<si::fps::pound> mass;
|
||||
|
||||
si::fps::length<si::fps::inch> mainGuns;
|
||||
si::fps::length<si::fps::inch> mainGuns;
|
||||
si::fps::mass<si::fps::pound> shellMass;
|
||||
si::fps::speed<si::fps::foot_per_second> shellSpeed;
|
||||
si::fps::power<si::fps::foot_poundal_per_second> power;
|
||||
@ -85,7 +85,7 @@ int main()
|
||||
using namespace units::isq::si::references;
|
||||
using namespace units::isq::si::fps::references;
|
||||
using units::isq::si::fps::references::ft; // collides with si::femtotonne (alias unit of mass)
|
||||
|
||||
|
||||
// KMS Bismark, using the units the Germans would use, taken from Wiki
|
||||
auto bismark = Ship{.length{251. * m}, .draft{9.3 * m}, .beam{36 * m}, .speed{56 * (km / h)}, .mass{50'300 * t}, .mainGuns{380 * mm}, .shellMass{800 * kg}, .shellSpeed{820. * (m / s)}, .power{110.45 * kW}};
|
||||
|
||||
|
@ -158,7 +158,7 @@ void matrix_of_quantity_add()
|
||||
void matrix_of_quantity_multiply_same()
|
||||
{
|
||||
std::cout << "\nmatrix_of_quantity_multiply_same:\n";
|
||||
|
||||
|
||||
matrix<si::length<si::metre>> v = {{ 1 * m, 2 * m, 3 * m }, { 4 * m, 5 * m, 6 * m }, { 7 * m, 8 * m, 9 * m }};
|
||||
vector<si::length<si::metre>> u = { 3 * m, 2 * m, 1 * m };
|
||||
|
||||
@ -303,7 +303,7 @@ void quantity_of_matrix_add()
|
||||
void quantity_of_matrix_multiply_same()
|
||||
{
|
||||
std::cout << "\nquantity_of_matrix_multiply_same:\n";
|
||||
|
||||
|
||||
length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }});
|
||||
length_v<> u(vector<>{ 3, 2, 1 });
|
||||
|
||||
|
@ -35,7 +35,7 @@ struct percent : named_scaled_unit<percent, "%", no_prefix, ratio(1, 100), one>
|
||||
|
||||
/**
|
||||
* @brief Dimension one
|
||||
*
|
||||
*
|
||||
* Dimension for which all the exponents of the factors corresponding to the base
|
||||
* dimensions are zero. Also commonly named as "dimensionless".
|
||||
*/
|
||||
|
@ -44,7 +44,7 @@ struct pound_force : named_scaled_unit<pound_force, "lbf", si::prefix, ratio(32'
|
||||
|
||||
struct kilopound_force : prefixed_unit<kilopound_force, si::kilo, pound_force> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Kip_(unit),
|
||||
// https://en.wikipedia.org/wiki/Kip_(unit),
|
||||
struct kip : alias_unit<kilopound_force, "klbf", no_prefix> {};
|
||||
|
||||
struct dim_force : isq::dim_force<dim_force, poundal, dim_mass, dim_acceleration> {};
|
||||
|
@ -29,9 +29,9 @@ namespace {
|
||||
constexpr basic_fixed_string txt1('a');
|
||||
static_assert(txt1.size() == 1);
|
||||
static_assert(txt1[0] == 'a');
|
||||
static_assert(txt1 == basic_fixed_string("a"));
|
||||
static_assert(txt1 < basic_fixed_string("b"));
|
||||
static_assert(txt1 < basic_fixed_string("aa"));
|
||||
static_assert(txt1 == basic_fixed_string("a"));
|
||||
static_assert(txt1 < basic_fixed_string("b"));
|
||||
static_assert(txt1 < basic_fixed_string("aa"));
|
||||
static_assert(txt1 + basic_fixed_string('b') == basic_fixed_string("ab"));
|
||||
static_assert(basic_fixed_string('b') + txt1 == basic_fixed_string("ba"));
|
||||
static_assert(txt1 + basic_fixed_string("bc") == basic_fixed_string("abc"));
|
||||
@ -42,9 +42,9 @@ static_assert(txt2.size() == 3);
|
||||
static_assert(txt2[0] == 'a');
|
||||
static_assert(txt2[1] == 'b');
|
||||
static_assert(txt2[2] == 'c');
|
||||
static_assert(txt2 == basic_fixed_string("abc"));
|
||||
static_assert(txt2 < basic_fixed_string("b"));
|
||||
static_assert(txt2 > basic_fixed_string("aa"));
|
||||
static_assert(txt2 == basic_fixed_string("abc"));
|
||||
static_assert(txt2 < basic_fixed_string("b"));
|
||||
static_assert(txt2 > basic_fixed_string("aa"));
|
||||
static_assert(txt2 + basic_fixed_string('d') == basic_fixed_string("abcd"));
|
||||
static_assert(basic_fixed_string('d') + txt2 == basic_fixed_string("dabc"));
|
||||
static_assert(txt2 + basic_fixed_string("def") == basic_fixed_string("abcdef"));
|
||||
|
@ -42,11 +42,11 @@ static_assert(si::fps::time<si::fps::second>(1) == si::time<si::second>(1));
|
||||
static_assert(si::fps::speed<si::fps::foot_per_second>(1) == si::speed<si::metre_per_second>(0.3048));
|
||||
static_assert(si::fps::area<si::fps::square_foot>(1) == si::area<si::square_metre>(0.09290304));
|
||||
static_assert(si::fps::acceleration<si::fps::foot_per_second_sq>(1) == si::acceleration<si::metre_per_second_sq>(0.3048));
|
||||
static_assert(si::fps::force<si::fps::poundal>(1) > si::force<si::newton>(0.138254) &&
|
||||
static_assert(si::fps::force<si::fps::poundal>(1) > si::force<si::newton>(0.138254) &&
|
||||
si::fps::force<si::fps::poundal>(1) < si::force<si::newton>(0.138256));
|
||||
static_assert(si::fps::energy<si::fps::foot_poundal>(1) > si::energy<si::joule>(0.042140110093804) &&
|
||||
static_assert(si::fps::energy<si::fps::foot_poundal>(1) > si::energy<si::joule>(0.042140110093804) &&
|
||||
si::fps::energy<si::fps::foot_poundal>(1) < si::energy<si::joule>(0.042140110093806));
|
||||
static_assert(si::fps::power<si::fps::foot_poundal_per_second>(1) > si::power<si::watt>(0.042140110093804) &&
|
||||
static_assert(si::fps::power<si::fps::foot_poundal_per_second>(1) > si::power<si::watt>(0.042140110093804) &&
|
||||
si::fps::power<si::fps::foot_poundal_per_second>(1) < si::power<si::watt>(0.042140110093806));
|
||||
static_assert(si::fps::pressure<si::fps::poundal_per_foot_sq>(1) > si::pressure<si::pascal>(1.4881639435) &&
|
||||
si::fps::pressure<si::fps::poundal_per_foot_sq>(1) < si::pressure<si::pascal>(1.4881639437));
|
||||
@ -61,11 +61,11 @@ static_assert(si::fps::time<si::fps::second>(1) == 1_q_s);
|
||||
static_assert(si::fps::speed<si::fps::foot_per_second>(1) == 0.3048_q_m_per_s);
|
||||
static_assert(si::fps::area<si::fps::square_foot>(1) == 0.09290304_q_m2);
|
||||
static_assert(si::fps::acceleration<si::fps::foot_per_second_sq>(1) == 0.3048_q_m_per_s2);
|
||||
static_assert(si::fps::force<si::fps::poundal>(1) > 0.138254_q_N &&
|
||||
static_assert(si::fps::force<si::fps::poundal>(1) > 0.138254_q_N &&
|
||||
si::fps::force<si::fps::poundal>(1) < 0.138256_q_N);
|
||||
static_assert(si::fps::energy<si::fps::foot_poundal>(1) > 0.042140110093804_q_J &&
|
||||
static_assert(si::fps::energy<si::fps::foot_poundal>(1) > 0.042140110093804_q_J &&
|
||||
si::fps::energy<si::fps::foot_poundal>(1) < 0.042140110093806_q_J);
|
||||
static_assert(si::fps::power<si::fps::foot_poundal_per_second>(1) > 0.042140110093804_q_W &&
|
||||
static_assert(si::fps::power<si::fps::foot_poundal_per_second>(1) > 0.042140110093804_q_W &&
|
||||
si::fps::power<si::fps::foot_poundal_per_second>(1) < 0.042140110093806_q_W);
|
||||
static_assert(si::fps::pressure<si::fps::poundal_per_foot_sq>(1) > 1.4881639435_q_Pa &&
|
||||
si::fps::pressure<si::fps::poundal_per_foot_sq>(1) < 1.4881639437_q_Pa);
|
||||
@ -82,11 +82,11 @@ static_assert(1_q_s == si::time<si::second>(1));
|
||||
static_assert(1_q_ft_per_s == si::speed<si::metre_per_second>(0.3048));
|
||||
static_assert(1_q_ft2 == si::area<si::square_metre>(0.09290304));
|
||||
static_assert(1_q_ft_per_s2 == si::acceleration<si::metre_per_second_sq>(0.3048));
|
||||
static_assert(1_q_pdl > si::force<si::newton>(0.138254) &&
|
||||
static_assert(1_q_pdl > si::force<si::newton>(0.138254) &&
|
||||
1_q_pdl < si::force<si::newton>(0.138256));
|
||||
static_assert(1_q_ft_pdl > si::energy<si::joule>(0.042140110093804) &&
|
||||
static_assert(1_q_ft_pdl > si::energy<si::joule>(0.042140110093804) &&
|
||||
1_q_ft_pdl < si::energy<si::joule>(0.042140110093806));
|
||||
static_assert(1_q_ft_pdl_per_s > si::power<si::watt>(0.042140110093804) &&
|
||||
static_assert(1_q_ft_pdl_per_s > si::power<si::watt>(0.042140110093804) &&
|
||||
1_q_ft_pdl_per_s < si::power<si::watt>(0.042140110093806));
|
||||
static_assert(1_q_pdl_per_ft2> si::pressure<si::pascal>(1.4881639435) &&
|
||||
1_q_pdl_per_ft2 < si::pressure<si::pascal>(1.4881639437));
|
||||
@ -106,11 +106,11 @@ static_assert(1_q_s == 1_q_s);
|
||||
static_assert(1_q_ft_per_s == 0.3048_q_m_per_s);
|
||||
static_assert(1_q_ft2 == 0.09290304_q_m2);
|
||||
static_assert(1_q_ft_per_s2 == 0.3048_q_m_per_s2);
|
||||
static_assert(1_q_pdl > 0.138254_q_N &&
|
||||
static_assert(1_q_pdl > 0.138254_q_N &&
|
||||
1_q_pdl < 0.138256_q_N);
|
||||
static_assert(1_q_ft_pdl > 0.042140110093804_q_J &&
|
||||
static_assert(1_q_ft_pdl > 0.042140110093804_q_J &&
|
||||
1_q_ft_pdl < 0.042140110093806_q_J);
|
||||
static_assert(1_q_ft_pdl_per_s > 0.042140110093804_q_W &&
|
||||
static_assert(1_q_ft_pdl_per_s > 0.042140110093804_q_W &&
|
||||
1_q_ft_pdl_per_s < 0.042140110093806_q_W);
|
||||
static_assert(1_q_pdl_per_ft2> 1.4881639435_q_Pa &&
|
||||
1_q_pdl_per_ft2 <1.4881639437_q_Pa);
|
||||
@ -144,7 +144,7 @@ static_assert(quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre
|
||||
// multiplication
|
||||
|
||||
// static_assert(2 * ft * si::length<si::metre>(2) == si::area<si::square_metre>(1.2192)); // TODO Add support for comparing of an unknown_dimension
|
||||
static_assert(quantity_cast<si::length<si::metre>>(2. * ft) * si::length<si::metre>(2) == si::area<si::square_metre>(1.2192));
|
||||
static_assert(quantity_cast<si::length<si::metre>>(2. * ft) * si::length<si::metre>(2) == si::area<si::square_metre>(1.2192));
|
||||
static_assert(quantity_cast<si::length<si::metre>>(2. * ft) * si::length<si::metre>(0.6096) == si::area<si::square_metre>(0.371612160)); // 2 ft * 2 ft == 4 sq ft
|
||||
static_assert(2. * ft * quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre>(0.6096)) == 4._q_ft2);
|
||||
|
||||
|
Reference in New Issue
Block a user