Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::quantity as a numeric type #20

Open
mpusz opened this issue Jun 15, 2023 · 5 comments
Open

std::quantity as a numeric type #20

mpusz opened this issue Jun 15, 2023 · 5 comments
Labels
units Physical Units Library related paper

Comments

@mpusz
Copy link
Owner

mpusz commented Jun 15, 2023

  • identities (dimension_one, dimensionless, one)
  • magnitude (ratio on steroids)
  • quantity_spec vs units/dimension equations
  • quantity_spec conversions and common_quantity_spec
  • quantity constructors and conversions (value preserving approach)
  • exceptions and special cases for dimensionless quantities
  • quantity arithmetics + quirks of modulo arithmetic
  • custom representation types (improve safety, provide additional info like measurement, linear algebra, minimal requirements)
  • representation type constraints
  • vector quantities and their operations
  • affine space and operations
  • Math CPOs
@mpusz mpusz added the units Physical Units Library related paper label Jun 15, 2023
@JohelEGP
Copy link
Contributor

I understand the structure.

Please, clarify the intent.
Is it also a wording paper?

For the non-wording portions,
I think we'll be able to reuse a lot of mp-units' documentation,
which is in pretty good shape.
How do you think they'll differ?
Here's what I'm thinking:

  • Clearly distinguish domain abstractions (e.g., units) from invented abstractions (e.g., quantity_spec).
    The former must exist in the design.
    The latter can be refactored (but see the next points).
  • Clearly explain the relation between domain requirements (e.g., quantities of the same kind are comparable) and invented abstractions.
  • Link back to sections of the other papers where relevant.

@mpusz
Copy link
Owner Author

mpusz commented Sep 28, 2023

Is it also a wording paper?

No. It is meant to solve all of the math-related issues and concerns before we provide the first paper for LEWG with interfaces and, eventually, wording in later revisions.

I think we'll be able to reuse a lot of mp-units' documentation,

That's the point :-) I was writing the documentation with that in mind. If not copy-and-paste, documentation still highlights most things we need to describe there. The audience is different, so pure copy-paste may not be enough,

Here's what I'm thinking:

Agree.

@mpusz
Copy link
Owner Author

mpusz commented Sep 29, 2023

We also need to describe that as long as number * unit to get the value of a quantity is defined in the SI Brochure, quantity */ unit and number / unit is added by us for the engineering convenience.

@JohelEGP
Copy link
Contributor

JohelEGP commented Sep 29, 2023

That's just math.
Let $quantity = number * unit$,
$quantity / unit = number * unit / unit = number$.
We had removed that possibility in code because [see mpusz/mp-units#262 (comment)].

@mpusz
Copy link
Owner Author

mpusz commented Sep 30, 2023

  1. Potentially more expensive when Rep is expensive to copy/move (quantity with a numeric value copied/moved many times before the final unit is obtained)
  2. Multiplication is commutative so should m * 42 be a thing? This seems wrong to me.
  3. Should 42 / s construct a quantity? If so, how to define a quantity<1 / s> or define hertz with:
inline constexpr struct hertz : named_unit<"Hz", 1 / second, kind_of<isq::frequency>> {} hertz;

It seems that only multiplication after a number has a sense, or we would have to heavily complicate the notation of inverses for units, dimensions, and quantity_specs (i.e. using std::integral_constant).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
units Physical Units Library related paper
Projects
None yet
Development

No branches or pull requests

2 participants