1129 Commits

Author SHA1 Message Date
Mateusz Pusz 88d40e7ce5 fix: hep::velocity should be a child of hep::speed 2026-07-03 23:56:50 +02:00
Mateusz Pusz 7ac9474066 docs: "Why a Quantity Has a Character" published 2026-06-29 18:09:25 +02:00
Mateusz Pusz e0cc4eec90 docs(utility): document the utility component, namespace tiers, and the safe_int/constrained move
Add a Namespaces section to the project structure docs describing the three
public tiers (mp_units / mp_units::utility / mp_units::detail), show the
core -> systems -> utility module layering, and list the utility headers.
Update the representation and custom-representation guides to introduce the
built-in cartesian types via mp_units::utility, and update the safe_int /
constrained material (guide, blog posts, tutorials) to the new
<mp-units/utility/...> include paths and mp_units::utility names.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 18:07:49 +02:00
Mateusz Pusz f5a5062f7a docs: mention the 2D cartesian_vector/tensor in the framework guides
Describe `cartesian_vector<T, N>` / `cartesian_tensor<T, N>` as N-dimensional /
NxN with a compile-time dimension N (2 or 3, default 3), and show dimension
deduction plus embed/project converting between the plane and space.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 23:00:55 +02:00
Mateusz Pusz a2bf639be0 docs: "Documentation is prose, not a Doxygen dump" blog article
Add the draft blog post on documentation philosophy and its two Diátaxis diagrams.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 18:41:27 +02:00
Mateusz Pusz 40a10be65a docs: note tensor and complex quantities also expose quantity-level magnitude()
Broaden the "a vector quantity supports magnitude()" note to "vector or tensor quantity" and
name the norm variants (Euclidean for a real vector, Frobenius for a tensor, Hermitian for a
complex one), matching the shipped magnitude() character constraint.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 18:40:10 +02:00
Mateusz Pusz 7d832d6fca docs: ground the quantity-character article in ISO 80000-2 rank-ordering
Move the "a vector is a tensor of the first order and a scalar is a tensor of order zero"
quote to the underdetermined-type section, where the article shows one double serving scalar,
vector, and tensor quantities, and add a matrix-vs-tensor paragraph to "The type lies": a
matrix is storage, a tensor is defined by its transformation law, so whether a Matrix3d is a
tensor is a fact about the quantity, not the type.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 17:41:18 +02:00
Mateusz Pusz aa2f91346d docs: document the two-axis quantity character
Rework the "Character of a Quantity" chapter for the order x field model and record the change
in the changelog.

- character_of_a_quantity.md: two-axis framing up front; a new "Real and complex quantities"
  section; the `quantity_tensor_order`/`quantity_field` enum and `quantity_character` struct
  definitions shown before use; an expanded ordering example (explicit vector, inherited
  vector, explicit tensor) and a complex declaration; the ISO 80000-2 rank-ordering quote; and
  the experimental warning removed. Deprecated `quantity_character::vector` examples updated to
  the two-axis spelling.
- CHANGELOG.md: 2.6.0 entries for the two-axis split, `cartesian_tensor`, the
  `numeric_field`/`tensor_order` customization points, the flat-enum deprecation and
  customization rework, and the magnitude/decomposition fixes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 17:41:12 +02:00
Mateusz Pusz 34b1cade2c docs: revise the "Why a Quantity Has a Character" article
Iterate the in-progress essay (still draft). Restructure the motivation as a three-tab
strong-quantities comparison (plain double, loose auto parameters, proper constraints) built
on a speedometer `closing_speed` example, and split character's two jobs into a bulleted list.

Correct several technical claims surfaced in review:

- mass/weight differ by dimension, not character (matching the article's own opening);
- a real representation cannot grow an imaginary part - there is no silent complex-to-real
  drop, since `std::complex` does not convert to `double`;
- the "scalar-as-vector workaround" was the `is_vector` opt-in the Kalman example carried, not
  the later `disable_vector` opt-out;
- `magnitude()` is defined on vectors and tensors, real and complex, and ships today for the
  scalar-rejection case.

Add concrete complex vector/tensor quantities (phasor field, permittivity tensor), the
degenerate stress-tensor case in the underdetermined-type example, and an admonition for the
thesis.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 16:36:39 +02:00
Mateusz Pusz e1c2b9562b fix(representation): key magnitude and vector decomposition on character order, support complex
`quantity::magnitude()` was constrained to an exact `quantity_character{vector}` (i.e.
`{vector, real}`), which silently excluded tensor quantities and complex vectors even though
both have a well-defined norm. It now requires `order >= vector` (vectors and tensors, any
field) plus `HasMagnitude<rep>` so the storage can actually produce one - the latter cleanly
withholds the member instead of letting the body hard-error when the rep has no magnitude.

The `magnitude` CPO gained the missing complex-scalar branch: a complex scalar is a degenerate
1D complex vector, so its magnitude is the modulus `|z|`, symmetric with the real-scalar
`std::abs` branch (a `double` standing in as a 1D real vector).

Vector decomposition (`vector_components` primary template and `ValidVectorAxes`) dropped the
real-field pin, keying on `order == vector` alone, so complex vector quantities decompose into
their complex 1D components. The order pin stays (a tensor is not a flat vector decomposition).

Adds static tests (magnitude over scalar/vector/tensor and real/complex/degenerate reps;
complex-field decomposition) asserting the intended design, and documents the complex-scalar
magnitude path in the representation-types guide.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 13:47:44 +02:00
Mateusz Pusz 9813a9097c docs: draft flag was not set in the previous article 2026-06-26 01:08:35 +02:00
Mateusz Pusz fe03f4b273 docs: "Why a Quantity Has a Character" blog article 2026-06-26 01:03:13 +02:00
Mateusz Pusz e061bf0ef8 refactor(representation): replace disable_real/NotQuantity with disable_representation
Consolidate the representation opt-outs into one character-agnostic customization
point and align the documentation with the two-axis model.

- Add `disable_representation<T>` in `customization_points.h`: a specializable
  opt-out that bars a type from being a quantity representation regardless of
  character. Its default (`is_quantity_abstraction<value_type_t<T>>`) rejects a
  quantity or quantity-like type, and any container of them; `bool` is opted out
  explicitly. This retires both `disable_real` and the `NotQuantity` guard.
- Rename the internal predicate `is_quantity_like` -> `is_quantity_abstraction`
  (it covers `Quantity || QuantityLike`) so it no longer collides with the
  `QuantityLike` customization family.
- The representation tier now leads with one shared `RepresentationBaseline`
  guard (not opted out + `UnitMagnitudeScalable`), which short-circuits a quantity
  before any character concept instantiates its operators (avoiding a
  satisfaction cycle).
- Docs: restructure `representation_types.md` around the two character axes
  (field via `numeric_field`, order via `tensor_order`) with a common baseline,
  the new `disable_representation` section, and consistent unit-magnitude-aware
  scaling terminology; align `concepts.md` and `using_custom_representation_types.md`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 21:36:07 +02:00
Mateusz Pusz bf82b8d28d docs: fix overlong line in representation_types disable_tensor note
Rewrap a 91-column line in the `disable_tensor` paragraph to satisfy markdownlint MD013.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 09:16:59 +02:00
Mateusz Pusz 036efbdc0b feat(scripts): two-axis character labels and a merged Traits column in the reference
Update the systems reference generator for the two-axis quantity character and to reduce
the quantities table width:

- The Character column now prints the order with a `complex` prefix only when the field is
  complex (`scalar`, `complex scalar`, `vector`, `tensor`, `complex vector`,
  `complex tensor`), replacing the old `Real`/`Complex`/`Vector`/`Tensor` labels that mixed
  the two axes and could not express complex vectors or tensors.
- The separate `is_kind` and `non_negative` boolean columns are merged into one `Traits`
  column that shows `kind` and/or `≥ 0` only when set (blank otherwise), dropping a column
  and the per-row ticks.

Regenerated the affected systems reference pages.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 00:21:18 +02:00
Mateusz Pusz d4230f46c5 chore(docs): refresh systems reference source-hash cache after character migration
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 00:10:46 +02:00
Mateusz Pusz 199cc49a7e fix(scripts): update systems reference generator for the two-axis quantity_character
The QUANTITY_SPEC parser only recognized `quantity_character::` as a character override,
and the generated metadata-extraction program `switch`ed over the character enum. Both
broke once the ISQ definitions moved to the `quantity_tensor_order` / `quantity_field`
spelling and `quantity_character` became a struct.

- Treat `quantity_tensor_order::` and `quantity_field::` (alongside `quantity_character::`)
  as character overrides when deciding whether the third macro argument is an equation.
- Rewrite `character_to_string` to compare against the two-axis values instead of switching
  on an enum.

The regenerated reference is byte-identical (only the source hash changes).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 23:53:58 +02:00
Mateusz Pusz 87257a6c5d refactor: Vector implemented in terms of Tensor 2026-06-24 22:52:24 +02:00
Mateusz Pusz 7ec072cd7b style: markdownlint-cli2 added to pre-commit 2026-06-23 23:03:04 +02:00
Mateusz Pusz d37414ac7b feat: vector quantity decomposition support added 2026-06-23 16:11:47 +02:00
Mateusz Pusz 42444316b6 docs: linear algebra blog post added 2026-06-22 19:20:00 +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 6f05862a12 docs: Brno 2026 meeting report added 2026-06-13 23:32:59 +02:00
Mateusz Pusz c4b30d9b60 Merge branch 'master' of github.com:mpusz/units 2026-06-12 23:09:41 +02:00
Mateusz Pusz 4c7639942e refactor: norm() replaced with magnitude() for vector representation types 2026-06-12 22:25:26 +02:00
Mateusz Pusz 7f1e417c06 docs: system reference cache updated 2026-06-12 09:44:57 +02:00
Mateusz Pusz 5072c138ee docs: "Two levels of format specification" chapter added 2026-06-12 09:44:28 +02:00
Mateusz Pusz 1c54623024 feat: import std; enabled for g++ 2026-06-03 21:29:55 +02:00
Mateusz Pusz 8df25adeef docs: use cl-style 19.5+ for MSVC in compiler support table
The previous `195+` is the Conan-side encoding (matching
`_feature_compatibility` in conanfile.py) and is ambiguous in prose —
the digits collide with `_MSC_VER`/cl-version/toolset variants. The
cl-version `19.5+` is what users see from `cl /version`, and what's
already used in src/CMakeLists.txt when this project talks about MSVC
versions. Realign the MSVC column to accommodate the wider cell.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 16:47:45 +02:00
Mateusz Pusz 96965634f5 feat: support import std; on MSVC
mp-units' minimum-supported MSVC 195 (VS 2026) has solid `import std;`
support, but enabling `-o import_std=True` against the build hit two
issues that this change fixes.

(1) Module scanning was only enabled when `cxx_modules=True`.

Without `CMAKE_CXX_SCAN_FOR_MODULES=ON`, CMake doesn't link the implicit
std module BMI into non-module translation units that do `import std;`,
producing C2230 "could not find module 'std'". Enable scanning whenever
`import_std=True` as well. Same bug fixed in `test_package/conanfile.py`.

(2) The std module BMI is built with mismatched compile flags.

CMake materializes the implicit std module BMI as `__cmake_cxx_std_NN`,
a separate internal target that does not link mp-units and therefore
does not inherit mp-units' target-level options. On MSVC this caused
C5050 (`_UTF8` defined on consumer but not on module command line) and
on Clang 21 there is a parallel `-Wreserved-module-identifier` issue
already partially handled in `src/CMakeLists.txt` but in a directory
scope that did not actually reach the BMI either.

Consolidate the workarounds into one `src/cmake/import-std-setup.cmake`
snippet that applies the flags project-wide via `add_compile_options`,
self-guarded by `if(NOT CMAKE_CXX_MODULE_STD) return()`. It is included
from every entry point so all delivery paths converge:
  - top-level `CMakeLists.txt` for the dev build
  - bundled `mp-unitsConfig.cmake` for `find_package` consumers
  - via `cmake_build_modules` in `package_info()` for Conan-generated
    configs (the `cxx_modules=False` consumer path)

Other pieces:
  - `test/static/unit_magnitude_test.cpp` was the only test in the repo
    missing the `MP_UNITS_IMPORT_STD` gate around `#include <type_traits>`,
    causing duplicate `std::integral_constant` definitions in this
    configuration.
  - Compiler support table announces MSVC 195+ for `import std;`.
  - Installation docs gain a consumer-side setup note covering the
    CMake cache variables required, what mp-units handles automatically
    via the snippet, and the `add_subdirectory`-vendored caveat.

Verified: `conan build . -pr msvc195 -o '&:cxx_modules=False'
-o '&:import_std=True' -s compiler.cppstd=23 -c
user.mp-units.build:all=True` -> 40/40 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 23:45:51 +02:00
Mateusz Pusz 393c671608 docs: MSVC 195 works with mp-units now
Resolves #761
2026-05-24 21:46:41 +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 779d78fce9 docs: P4185 added to the docs welcome page 2026-05-15 09:51:08 +02:00
Mateusz Pusz 6e6ff299b5 feat(example): trade_execution example added 2026-05-14 19:57:28 +02:00
Mateusz Pusz 995d5dda5f docs: workaround from "Custom Quantity Specifications" workshop removed 2026-05-14 19:06:49 +02:00
Mateusz Pusz 257c51ccc4 docs: Compiler Explorer links updated 2026-05-14 19:06:16 +02:00
Mateusz Pusz 47fdf2254b docs: frame projections tutorial added 2026-05-13 19:13:27 +02:00
Mateusz Pusz 2de1a2ff04 docs: header files with customization points updated 2026-05-13 19:12:46 +02:00
Mateusz Pusz 013c23be22 docs: quantity safety post now references absolute quantities post 2026-05-13 19:04:42 +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 7899bf4ca8 feat: explicit constructor between point in projected frames added 2026-05-13 18:11:27 +02:00
Mateusz Pusz c93778010f feat: 💥 final is not longer required for definitions and should not be used for quantity_spec 2026-05-13 15:23:47 +02:00
Mateusz Pusz 72ca96ee52 feat: frame projections support added 2026-05-12 23:02:09 +02:00
Mateusz Pusz 9ba6d2e0f6 docs: Absolute Quantities blog article updated 2026-05-12 21:42:59 +02:00
Mateusz Pusz c1212bf4da docs: "Representation Types" chapter updated 2026-05-12 20:42:15 +02:00
Mateusz Pusz 1ac0fe5336 docs: affine space SVG updated 2026-05-12 20:27:42 +02:00
Mateusz Pusz 3a27e34ea6 docs: system reference cache updated 2026-05-06 22:54:59 +02:00
Mateusz Pusz 4161608a92 docs: point origin inheritance docs added 2026-05-06 22:35:58 +02:00
Mateusz Pusz 1b8b6d222a feat: kind_of applied to more derived SI units + some quantity_spec hierarchies improved 2026-05-06 22:34:40 +02:00