CUQI-DTU / CUQIpy

https://cuqi-dtu.github.io/CUQIpy/
Apache License 2.0
41 stars 7 forks source link

Support conjugacy with linear relation in conjugate parameter #453

Open nabriis opened 1 month ago

nabriis commented 1 month ago
          > Thanks for the work @nabriis , here is my take on `_regression_test_linear`.:

In terms of conditioning (I believe) we should be able to handle I can quickly come up with:

1. prec = lambda d : d

2. prec = lambda d : 10*d

3. prec = lambda d : 10_d_np.eye(n) (or any other matrix)
   or

4. cov = lambda d : 1.0/d

5. cov = lambda d : 0.1/d

6. cov = lambda d : (0.1/d)*np.eye(n) (or any other matrix)

The current version of this PR can only handle cases 1 and 4, by checking using _check_conjugate_paramter_is_scalar_identity for the prec or using _check_conjugate_parameter_is_scalar_reciprocal for cov.

If I recall correctly, replacing the identity check with a linearity check, i.e., _check_conjugate_paramter_is_scalar_identity with some improved version of _regression_test_linear, could allow for case 2 . This additional scaling of the parameters is something I do plan to use as part of #424.

I suspect that a final generalization to case 5 and cases 3 and 6 (if wanted) should not be too much additional work then.

(Please fix the paramter typo in the code)

@nabriis, I currently think that _regression_test_linear can be removed and that handling the cases 1 and 4 above can be enough for the current PR, as it does not break any current models (as far as I am aware) and the other extension can than be considered in future PR.

Originally posted by @jeverink in https://github.com/CUQI-DTU/CUQIpy/issues/444#issuecomment-2200101086