Open giordano opened 7 years ago
Different approach in dispatch-on-constant
branch: no new type, the only change is the dispatch of result
for 1-arg functions is based on constants (Val{...}
), but this isn't very fast. The branch is left there only as a proof-of-concept.
We could make
Measurement
type abstract, and define two concrete types,IndependentMeasurement
andDependentMeasurement
(the latter may be an abuse of language but gives the idea):
I support this evolution. As far as I understand, the Python uncertainties packages works in this way. I have written code to do elaborations of uncertain and correlated quantities in R and resorted to the same concepts. It seems to me the most straightforward way to easily track down correlations when doing elaborations using quantities that themselves depend on overlapping sets of uncertain variables.
The reason why that I never went on with this idea is that it creates lots of type-instabilities, or it makes it more likely to have inhomogeneous containers which include both IndependentMeasurement
s and DependentMeasurement
s, which is really not a good idea performance-wise.
If one wants to distinguish an "independent" measure from a derived quantity, I believe traits would be a better approach.
We could make
Measurement
type abstract, and define two concrete types,IndependentMeasurement
andDependentMeasurement
(the latter may be an abuse of language but gives the idea):measurement
function would createIndependentMeasurement
objects, whileresult
function insrc/math.jl
would createDependentMeasurement
objects. This function could have a specialized method forIndependentMeasurement
only arguments, which could be fairly efficient.Ideally, there would not be user-visible changes, apart from performance improvements.
I'm not sure this proposal will actually improve performance, I'm leaving this as a memo for me open for discussion.