-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add support for easier math expressions in mp-units/math.h
#536
Comments
You need to explicitly mark |
Neat! Thanks! Although it will not solve the non-existing |
It seems like some are marked |
You should actually use |
When we have more time, we will probably extend the |
All math functions aside the trigonometric ones are |
Amazing! Thanks for the explanations 👍🏽 I will try to put together a PR 🤔 |
Hi mp-units team! template <QuantityOf<isq::length> Distance = mp_units::quantity<mp_units::si::metre>> struct MyStruct {
// ...
static constexpr auto pdf(Distance r, param_type const &p)
{
Distance a = p.a;
double b = p.b;
assert(a > 0. * m && b > 0. && r >= 0. * m);
return b / (2. * std::numbers::pi * a * a * tgamma(2. / b)) * exp(- pow(r, b*one) / pow(a, b*one));
}
}; But I get a |
|
@Becheler, it will always help us to answer you faster and more accurately if you provide a short repro in the Compiler Explorer. |
Calling |
@mpusz @JohelEGP Indeed with a CE example it makes more sense. |
Maybe you wanted to just do |
#483 rears it head? |
It's not just about the unit but, first and foremost, about the quantity type. |
Yeah, that's the first bullet of #483 (comment). |
Thanks guys! At least in this expression, calling pow on the numerical values of the quantites does not change the dimension of the resulting expression (1/m^2). I will have to look at others distributions to make sure of it though (what defeats a bit the automation of dimension analysis but oh well, mp_units rocks as it is! 🥇 Here is a working example: https://godbolt.org/z/5n8dreTez |
Time for 2 more suggestions! <3
I began to adapt this utility:
But I encountered two problems:
std::pow
whendouble
are manipulated (mp_units::pow
does not allow dimensionless types), and to usemp_units::pow
when dimensions quantities are manipulated. This mix made the code a bit weirder than it should be, as I expected to be able to usemp_units::pow
everywhere.mp_unit::log
function seems to have been forgotten during the implementation ;)I have been super happy with v2.0 so far! Great great job! I don't know exactly why but I find it easier to use than v1 :p
The text was updated successfully, but these errors were encountered: