karenyyng / shear_gp

code for using GP for inferring the 2D lensing potential. Accompanying gaussian process repo is:
https://github.com/karenyyng/george
1 stars 0 forks source link

Make consistent indexing of metric parameters in DerivativeExpSquaredKernel #6

Open mdschneider opened 9 years ago

mdschneider commented 9 years ago

The calls to metric_->get_parameter(ix) in DerivativeExpSquaredKernel pass values ix from 0 to 3, which implicitly assumes that the metric passed to the constructor is of type AxisAlignedMetric.

If, on the other hand, a metric of type IsotropicMetric is passed to DerivativeExpSquaredKernel then there will be memory access outside of the allocated memory for the metric parameter vector (unless the std::vector bounds checking is used).

A simple solution would be to remove the template type for the metric member variable. But this then doesn't match the interface of existing george kernels.

A more complete solution would do some checking of the metric subclass type before passing indexes to the get_parameter method of the metric object.

mdschneider commented 9 years ago

I should have specified this is all about the C++ layer of george.

karenyyng commented 9 years ago

Thanks @mdschneider. I agree with the type checking of the metric subclass.