nix
nix copied to clipboard
Handle polynomial when reading data in DataArray
When reading data and a polynomial is defined in the DataArray we have to apply it.
Related to this: as far as I see the "DataArray::expansionOrigin" & "DataArray::polynomCoefficients" re just getting & setting the values without them being used by e.g. applyPolynomial. Should this not yet be changed? Also: would it not be better to use boost::math::tools::evaluate_polynomial (as the UnitTest does), since it handles bigger numbers?
Pull-request #378 handles the basic reading part but leaves following things to do:
- [ ] throw exception when writing data with a (non-invertable?) polynomial set
- [ ] throw exception when setting a polynomial for unsupported datatypes (string!)
- [x] handle expansion origin (should be straight forward with #378 applied)
- [ ] SPEED, i.e. we currently optimisation like e.g. parallelization in place
- [ ] Check strict-aliasing (cf. comment below )
Regarding speed: if applyPolynomial
would have the following signature:
vector<double> applyPolynomial(std::vector<double> &coefficients, double origin, const &vector<double> input)
we could have alternative implementations of the function depending on the availability of certain extensions e.g. openMP or AVX intrinsic functions or both.
@stoewer yes. In order to support optimisations that require special memory handling (e.g. OpenCL) we probably have to abstract even more then just applyPolynomial
, i.e. the allocation of temporary buffer and such. But, be correct first, be fast afterwards, right? ;-)
Just as a heads-up: with #378 I will take care of expansionOrigin
next.
OK, thanks a lot.
Note to self (and others): I am not really 100% comfortable with read_buffer = reinterpret_cast<double *>(data);
(introduced by pull-request #378) due to strict aliasing. Before we close this bug, I want to make sure what we are doing is correct.