Skip to content

Draft: MNT: Use a common base class to share logic betwen the `CostFxnLobJacobianSingularValues[DiagHess]` classes

Paul McCarthy requested to merge mnt/merge-logjacobian-costfxns into master

The CostFxnLogJacobianSingularValues and CostFxnLogJacobianSingularValuesDiagHess classes contain many lines of identical code - the following functions are identical:

  • Constructor and data fields
  • get_parameters()
  • set_parameters()
  • cost()
  • grad()
  • hess()
  • calculate_cost_per_sample_
  • calculate_grad_per_jacobian_element_
  • calculate_grad_per_spline_
  • calculate_sub_grad_
  • spline_as_vec_

The only way in they differ is the manner in which the hessian matrix is calculated. This MR proposes that the common logic is pushed up to a common base class, CostFxnLogJacobianSingularValuesBase, with the unique logic defined in the derived classes.

In order to perform this re-organisation without introducing a large amount of boilerplate code, the two classes have been restructured so that they no longer use the PIMPL pattern.

This MR has also removed some debugging functionality from the CostFxnLobJacobianSingularValues class - we can add this back in in the future if/when needed.

Edited by Paul McCarthy

Merge request reports

Loading