Draft: Towards better handling of new JacobiSVD in Eigen3/4 code

This is a proof-of-concept attempt (developed up to the point that the jacobiSvd tests compile) to provide an implementation of the new JacobiSVD that is slightly better to handle in code that needs to support multiple versions of Eigen. The code is currently built on top of !658 (merged).

The changes are: The Compute{Thin,Full}{U,V} enum constants and the preconditioners have been turned into tag types. This allows calls like

m.jacobiSVD(ComputeThinU | ComputeFullV)

to be syntactically the same in old and new versions.

Code that explicitly creates a JacobiSVD object needs to be updated, though. This patch provides a function makeJacobiSVD which can be called as

auto svd = makeJacobiSVD<MatrixType>(options);

Code that needs to be Eigen3 compatible could define its own version of makeJacobiSVD that takes the runtime values of the options as parameters instead of tag types.

This should solve all cases when the generated svd and the corresponding options are local to the scope. What it cannot solve are situations in which the svd is returned or passed as a parameter, or in which the options are truly runtime options.

An advantage of the auto svd = make... pattern is that it would allow some internal refactoring of the JacobiSVD (which could be made internal::JacobiSVD) class in the future without breaking the API.

Edited by Erik Schultheis

Merge request reports

Loading