484 Commits

Author SHA1 Message Date
Mateusz Pusz ce833d344d refactor(utility): deprecate the mp_units:: rep shims and migrate consumers
The cartesian_vector and random distribution types now live in
mp_units::utility. Turn the transitional mp_units:: shims into proper
[[deprecated]] aliases (gcc-12 keeps a plain using-declaration because
CTAD through a deprecated alias template is broken there), and migrate
all in-tree consumers to mp_units::utility:: so the deprecations don't
trip -Werror. cartesian_tensor keeps no shim: it is unreleased (added in
2.6.0, never shipped), so it lives only at mp_units::utility.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 18:55:19 +02:00
Mateusz Pusz 25c402528b fix(example): migrate examples off the deprecated flat character spelling
`linear_algebra.cpp` and `measurement.cpp` still used `quantity_character::vector` and
`::real_scalar`, which now warn under the 2.6.0 deprecation and break the `-Werror` example
builds. Switch the comparisons to `quantity_character{quantity_tensor_order::vector}` and the
`RepresentationOf` arguments to the bare `quantity_tensor_order` axis.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 09:35:24 +02:00
Mateusz Pusz 9275fd2a63 fix(example): missing header file added 2026-06-23 17:06:21 +02:00
Mateusz Pusz 5e19c2cf89 fix(example): C++23-style quantity_spec replaced with QUANTITY_SPEC macro. 2026-06-23 16:39:44 +02:00
Mateusz Pusz d37414ac7b feat: vector quantity decomposition support added 2026-06-23 16:11:47 +02:00
Mateusz Pusz 4a8fc8cb40 refactor(example): print helper added for all quantities in the example 2026-06-22 19:20:10 +02:00
Mateusz Pusz 5c8c4ad5ae feat: external linear algebra libraries integrations added + quantity::magnitude() member function
Resolves #301
2026-06-22 18:51:56 +02:00
Mateusz Pusz 982fc526c0 feat: 💥 quantity_from_unit_zero() renamed back to quanity_from_zero() and limited to default_point_origin + qp.in(Unit) changes the origin for offset units 2026-05-21 22:46:12 +02:00
Mateusz Pusz 2690296059 feat: quantity_point text output added for default_point_origin 2026-05-21 18:38:09 +02:00
Mateusz Pusz 6e6ff299b5 feat(example): trade_execution example added 2026-05-14 19:57:28 +02:00
Mateusz Pusz 478f86eedc feat(example): geographic.h now supports converting between bearing and azimuth 2026-05-13 19:00:22 +02:00
Mateusz Pusz 2978c1963f fix: missing constraints for qp.quantity_from_unit_zero() added + fixed all incorrect usa cases 2026-05-06 22:12:50 +02:00
Mateusz Pusz 423db353e1 feat(example): currency example improved
Co-authored-by: Copilot <copilot@github.com>
2026-04-30 14:07:35 +02:00
Mateusz Pusz 15417cb167 refactor(example): c should be a unit and not a quantity in the total_energy example
Co-authored-by: Copilot <copilot@github.com>
2026-04-29 16:24:33 +02:00
Mateusz Pusz 1fed23f58c feat(example): bounds removed from equator and coordinates normalization added to position
Co-authored-by: Copilot <copilot@github.com>
2026-04-28 10:51:28 +02:00
Mateusz Pusz 0a33e0a0e6 refactor: quantity point bounds are now specified directly in origin - quantity_bounds_for customization point removed 2026-04-25 21:00:31 +02:00
Mateusz Pusz a1e1e7cb21 feat: non-negative quantities support added
Resolves #468
2026-04-06 22:51:42 +02:00
Mateusz Pusz a89b93bab2 feat: 💥 Celsius_temperature removed from ISQ 2026-04-04 09:11:33 +02:00
Mateusz Pusz 459211fc7a feat: quantity point bounds design finalized 2026-04-03 23:38:47 +02:00
Mateusz Pusz 26fc830903 fix: stop to use deprecated quanity_from_zero 2026-03-31 22:54:22 +02:00
Mateusz Pusz 16056181ce feat: range checking for points added 2026-03-30 21:39:06 +02:00
Mateusz Pusz 16cdd23e04 style: pre-commit rules updated 2026-03-27 22:49:05 +00:00
Mateusz Pusz d8b72fc431 refactor: scaling the value by magnitude heavily refactored 2026-03-19 00:28:15 +01:00
Mateusz Pusz efbc844199 fix: fixed-point arithmetic for integer unit conversions (#580) (#764)
* Fix #580: use fixed-point arithmetic for integer unit conversions

Introduce a fixed-point implementation for unit conversions involving
integer representations, avoiding loss of significant digits that
previously occurred when the conversion factor was not a whole number.

New files:
- src/core/include/mp-units/bits/fixed_point.h: double_width_int<T> and
  fixed_point<T,n> types for exact rational scaling of integer values.
  Uses __int128 when available (__SIZEOF_INT128__) for 64-bit integers.
- src/core/include/mp-units/framework/scaling.h: public scaling_traits<>
  customization point and scale<To>(M, value) free function. Provides
  built-in specializations for floating-point and integer-like types.
- test/static/fixed_point_test.cpp: static assertions for the new types.
- test/runtime/fixed_point_test.cpp: runtime arithmetic edge-case tests.

Modified:
- sudo_cast.h: replace hand-rolled conversion_value_traits / sudo_cast_value
  machinery with a single scale<To::rep>(c_mag, ...) call.
- representation_concepts.h: add MagnitudeScalable concept; replace
  ComplexScalar with HasComplexOperations (which is its definition).
- customization_points.h: add unspecified_rep tag and declare the primary
  scaling_traits<> template.
- framework.h / CMakeLists.txt: wire in the new headers.
- hacks.h: add MP_UNITS_DIAGNOSTIC_IGNORE_PEDANTIC and
  MP_UNITS_DIAGNOSTIC_IGNORE_SIGN_CONVERSION macros.
- example/measurement.cpp: add scaling_traits specializations for
  measurement<T> to demonstrate the customization point.
- test/static/{international,usc}_test.cpp: disable two tests that are
  blocked on issue #614.

Co-authored-by: Tobias Hanhart <burnpanck@users.noreply.github.com>

* Fix value_Type typo in floating_point_scaling_factor_type specialization

The partial specialization for types with a nested value_type used
'value_Type' (capital T) instead of 'value_type', making the entire
specialization dead code as the requires-clause could never be satisfied.

Also fix 'mantiassa' -> 'mantissa' in the adjacent comment.

* Fix docstring typos in scaling_traits documentation

- 'quantitiy' -> 'quantity'
- 'dictatet' -> 'dictated'
- 'convetrible' -> 'convertible'
- 'implemenation' -> 'implementation'
- 'availabe' -> 'available'

* Fix conflict resolution error: keep ComplexScalar name from master

When resolving the merge conflict in representation_concepts.h, the
PR's renamed version of the concept ('HasComplexOperations') was used
instead of master's established name ('ComplexScalar'). The two concepts
are semantically equivalent — burnpanck simply renamed it in his branch.

Revert to the canonical 'ComplexScalar' name while retaining the new
'MagnitudeScalable' concept which was the actual addition from the PR.

* Fix measurement.cpp: remove duplicate class definition from merge

The PR branched from a version where measurement<T> was defined inline
in measurement.cpp. Master later moved the class to example/include/
measurement.h and changed measurement.cpp to #include that header.

The squash merge therefore introduced a duplicate definition: the class
from the header and the PR's inline class were both visible, causing
an 'ambiguous reference' error. Remove the now-redundant inline class;
the scaling_traits specializations added by the PR work correctly with
the class from measurement.h.

* style: pre-commit

* docs: chapters anchors improved in the "custom representation" chapter

* docs: value conversions chapter improved

* refactor: scaling support refactored

* fix: clang-16 crash fixed

* docs: `measurement` example documentation updated to match changes

* fix: use exact wide-integer arithmetic for rational unit conversions on all platforms

On ARM / Apple Silicon, long double == double (64-bit mantissa).  The old
fixed_point<T>(long double) initialiser lost ~12 bits of precision for 64-bit
integer types when representing the scaling ratio, producing an error of ~49
units for the 10/9 (degree → gradian) conversion with a 10^18 input value.

Fix by splitting the integer-path else-branch into two cases:

  • Pure rational M (is_integral(M * (denominator(M) / numerator(M))) == true):
    use (value * numerator) / denominator via double_width_int_for_t<> arithmetic.
    This is exact on every platform regardless of long double width.

  • Irrational M (involves π etc.): keep the long double fixed_point approximation.
    These conversions are inherently approximate; small values still produce correct
    truncated results on all platforms.

Update the test comment to reflect the new exact-arithmetic path.

Fixes CI failures on clang-18/ARM and apple-clang-16.

* fix: replace floating-point TeX-point test with exact integer equivalent

72.27 is not exactly representable as double (it rounds to 72.2699...96).
Multiplying by the conversion factor 100/7227 via long double gives a result
≥ 1.0 on x86 (80-bit long double, 64-bit mantissa) only by chance, but
0.99999...978 on ARM / Apple Silicon where long double == double (52-bit).

The correct mathematical statement is: 7227 tex_point = 100 inch (exact
rational relationship).  Use that integer form instead of the inexact 72.27
double literal so the test is correct and platform-independent.

---------

Co-authored-by: Tobias Hanhart <burnpanck@users.noreply.github.com>
2026-03-07 21:02:37 +01:00
Mateusz Pusz 8e007d5cd8 perf: formatters compile-time performance improved 2026-02-26 02:16:17 +01:00
Mateusz Pusz 6f3ef66d4b feat: comparisons against literal 0
Resolves #487
2026-02-23 11:07:22 +01:00
Mateusz Pusz b2904cbde2 feat: improve type conversions to raise compile-time warnings on truncation
Resolves #762
2026-02-11 20:12:33 +01:00
Mateusz Pusz d194af7b97 fix: some stupid MSVC errors workarounds 2026-02-04 23:06:03 +01:00
Mateusz Pusz a931152285 refactor: refactor example to benefit from making si2019 inline 2026-01-18 16:42:41 +01:00
Mateusz Pusz 8d1a111728 feat: si2019 namespace made inline 2026-01-18 16:25:24 +01:00
Mateusz Pusz 9c5f2412bc refactor: 💥 international system renamed to yard_pound 2026-01-14 12:21:45 +01:00
Mateusz Pusz 9a374a5646 refactor: isq::time swapped with isq::duration 2026-01-09 09:22:37 +01:00
Mateusz Pusz a2128c8eb1 docs: documentation-related comment added to total_energy example 2026-01-07 12:04:29 +01:00
Mateusz Pusz e770a40910 feat: 💥 natural units reworked from scratch
`system_reference` and `AssociatedUnit` removed
2026-01-04 20:11:53 +01:00
Mateusz Pusz 6d10a154fa feat: 💥 pi and π is now a unit constant (pi magnitude constant renamed to pi_c) 2025-12-28 13:35:54 +01:00
Mateusz Pusz 381cb7b9b0 refactor(example): is_hae function refactored to HAEAltitude concept 2025-12-22 18:15:09 +01:00
Mateusz Pusz c54d18e489 refactor(example): kalman filter examples refactored to better match their documentation 2025-12-16 13:27:48 +01:00
Mateusz Pusz 801d3cb681 fix(example): text formatting fixed for glide_computer 2025-12-16 08:47:06 +01:00
Mateusz Pusz c0939d0c04 fix(example): value truncation warnings silenced for measurement 2025-12-14 18:17:40 +01:00
Mateusz Pusz cd6d27104e style: pre-commit 2025-12-13 16:51:42 +01:00
Mateusz Pusz 37f4a57495 fix: VERIFY_INTERFACE_HEADER_SETS fixed for example_utils-headers target 2025-12-13 16:34:09 +01:00
Mateusz Pusz 472d3a4fb0 refactor(example): slight refactoring of examples while working on their documentation 2025-12-13 13:21:47 +01:00
Mateusz Pusz 04c0822ffb feat(example): clcpp_response and conversion_factor examples removed 2025-12-13 13:19:38 +01:00
Mateusz Pusz 4d8726fd87 feat(example): measurement.h extracted for easier reuse 2025-12-13 13:18:59 +01:00
Mateusz Pusz 2a2a53d5e8 build: projectPrefix CMake variable removed 2025-11-02 15:08:20 -08:00
Mateusz Pusz 0350cb4500 fix: MSVC compilation fixed 2025-09-16 19:51:19 -06:00
Mateusz Pusz e058a47baf feat: natural units support is now opt-in 2025-07-09 20:05:03 +02:00
Mateusz Pusz 35798a0f39 refactor: ostream.h header file made deprecated 2025-06-20 10:40:10 +02:00
Mateusz Pusz 50c05bddb3 refactor: format.h header file made deprecated 2025-06-20 09:06:49 +02:00
Mateusz Pusz f7fc8dd715 Revert "refactor(example): explicit conversions added for ranged_representation arguments"
This reverts commit 0811ca92e1.
2025-04-03 08:17:54 +01:00