-
Notifications
You must be signed in to change notification settings - Fork 78
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
Does a base_dimension belong to particular quantity_system(s)? #44
Comments
Here is where I am at as regards base_dimension A base_dimension is a globally unique entity within an application. exponents of base_dimensions can be combined in a set known as a dimension. For convenience c++ classes representing unique base_dimensions must be totally ordered at compile time. Alternatively you have to restrict a base_dimension to a particular system e.g Newtonian Physics or Quantum Physics etc Ideally you can plug in a set of base dimensions ( which meets the necessary requirements) to the units 'engine' and it will just work. For myself I would hope there would be a standard <units/si_base_dimensions> header included. Ideally it should be possible to unplug (say) physical base_dimensions and plug in apples and pears base_dimensions or even append apples and pears to physical base dimensions. Even though apples and pears base_dimensions might seem ridiculous, yet it helps to use as a test case to verify separation of concerns in the library. For example The SI system can then be verified as a plug in to the basic units engine rather than being a dependency |
Hi, thanks for the review of a new design :-) You raised a few interesting questions here and well, even though I designed and implemented all of this I am not sure if I know how to answer them ;-) We always had Right now a physical dimension is still identified by a unique text identifier (i.e. "length") that is the most important part of the ordering (BTW, I fixed a potential bug there based on your comment, thanks! :-) ), but additionally gets a base unit that is adopted in a specific system of units. So: namespace units::si {
struct dim_length : base_dimension<"length", metre> {};
struct dim_mass : base_dimension<"mass", kilogram> {};
struct dim_time : base_dimension<"time", second> {};
struct dim_current : base_dimension<"current", ampere> {};
struct dim_temperature : base_dimension<"temperature", kelvin> {};
struct dim_substance : base_dimension<"substance", mole> {};
struct dim_luminous_intensity : base_dimension<"luminous intensity", candela> {};
} namespace units::cgs {
using si::centimetre;
using si::gram;
using si::second;
struct dim_length : base_dimension<"length", centimetre> {};
struct dim_mass : base_dimension<"mass", gram> {};
using si::dim_time;
} You ask "Is there a dependency of base_dimension on the particular system(s) in use as suggested here?". I think that the answer is no. Base dimensions do not depend on a system. They define one. A set of base dimensions for all system's base quantities yields a system of those base quantities. They are not closed to this system. You can freely mix base dimensions from different systems to form one derived dimension (if one wishes so). One more use case for this feature is not strictly connected to define a system of units but opens the doors to provide units that have the same dimensions but different units in the numerator and denominator like the Hubble parameter mentioned by Vincent Reverdy in https://wg21.link/p1930. BTW, if you would like to discuss some stuff more interactively please reach me on Cpplang Slack. I really value your feedback. Thanks! |
@mpusz That is very helpful. Thankyou. |
I am wondering about the uses of template strings to uniquely identify base_dimension. 2 issues.
For uniquely identifying base_dimension, an alternative to string is a UUID No need to re-invent the wheel here either, since there are already some UUIDs assigned for(nearly) the purpose in the bluetooth specification, which are at least a standardised useful starting point to work from. |
This is a library using c++20 features. Strings as NTTP is only one of many C++20 features used there and all of them will be the reason for your code to not compile on a pre C++20 compiler. Also, I do not care much about other strange quantity systems. If it is a physical "length" than just reuse it with the same name and a unit that is a base unit for length for this system of units (this exactly why With the above, I do not think that introducing UUID to the C++ Standard Library is a good idea here. |
OK. I have one other issue. I think this thing we are calling base_dimension, should be called base_quantity I renamed things in one branch of my library and I think it is much easier to read. |
I am really open to bikeshedding of names if needed, but in this particular case, I have a really strong opinion. First of all, please note that I am fully aware of the official terms and definitions. If you do not have access to ISO 80000, you can find most of them in chapter 4.1 of my paper: https://wg21.link/p1935. It is true that officially the SI specs define quantity (divided to a base and derived quantity) and "just" a dimension (no base or derived) that is a list of exponents. If I would like to follow exactly this nomenclature than:
However, please note that ISO 80000, even in the official definitions chapter, often mentions dimensions of base quantities which clearly states that base quantities also have their own dimensions ;-). For example, the definition of dimension looks as follows:
Above clearly states that base quantities have their own dimensions that then are used to form exponents of a "dimension" (in our case This is why I believe that in this particular case we are really OK with our design. From the implementation point of view I have to know which factor of a derived dimension definition is a base quantity and which is a derived one because if I get a derived one from the user than I have to unpack it to a list of base quantities. This is why we need to have two strong types in the design:
As you know both have also different properties (i.e. I also believe that it is much easier for the user to have only one |
Mpusz units on new_design branch splits into quantity_systems { physical.si, physical.cgs, data }
Does a base_dimension belong to particular quantity_system(s) or is a base_dimension allowed in any quantity_system? Or alternatively do quantity systems themselves belong to a particular quantity "universe"? (The base_dimension then exists in that universe rather than a particular quantity system.
Is there a dependency of base_dimension on the particular system(s) in use as suggested here?
https://github.com/mpusz/units/blob/new_design/src/include/units/base_dimension.h#L39
One dependency, for example might be if base-dimensions are ordered differently in different systems, or maybe two base_dimensions from different systems compare the same for ordering. Then what happens if various systems are used simultaneously?
If there is a dependency then instead of
is_base_dimension
one might have to do
is_base_dimension_of<QuantityUniverse,T>
Now the next issue. It is necessary to know what universe the computation applies to at compile time, so how one finds and applies the quantity_system a computation is in during compilation? .
(Maybe by choosing a custom header eg, as for example (std::cout availability is dependent on iostream header for example)
The text was updated successfully, but these errors were encountered: