[units] conversion performance

AMDG Unless some precision benefit accrues from multiplying the factors for each dimension individually, it would be better to compute the complete factor for the conversion once static quantity<unit<System2,Dim1>,Y> convert(const quantity<unit<System1,Dim1>,Y>& source) { Y val = source.value(); static Y fac(compute_factor()); val *= fac; return quantity<unit<System2,Dim1>,Y>::from_value(val); } In Christ, Steven Watanabe

Unless some precision benefit accrues from multiplying the factors for each dimension individually, it would be better to compute the complete factor for the conversion once
[snip] Good point - I don't think there's a precision issue, but I should think about it some more. I'll take a look at this later this evening. I guess it can be rendered down even more: static quantity<unit<System2,Dim1>,Y> convert(const quantity<unit<System1,Dim1>,Y>& source) { static Y fac(compute_factor()); return quantity<unit<System2,Dim1>,Y>::from_value (source.value()*fac); }
participants (2)
-
Matthias Schabel
-
Steven Watanabe