Add a layer of indirection in orthnull functions to minimize potential ambiguities#104
Add a layer of indirection in orthnull functions to minimize potential ambiguities#104
Conversation
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
|
Is it even necessary to define these overloads for the wrappers? I would have guessed that the general logic correctly dispatches to the underlying factorization, at which point we can define qr_compact etc? Ie, could it be that deleting the overloads actually solves the problem, or am I missing something? |
Good question. I think that would be ideal, the primary use case I can think of where that didn't work was for immutable types, since |
|
Maybe an alternative for these kinds of cases would be to directly overload |
I guess the subtle part with that approach is that for inputs like |
Sorry for all the noise. I tried that strategy and it seems to be a good alternative. In practice what I did was analogous to the following: function default_algorithm(::typeof(left_orth!), A::MyMatrix)
return MyMatrixAlgorithm(default_algorithm(left_orth!, parent(A)))
end
function select_algorithm(::typeof(left_orth!), A::MyMatrix, alg::Symbol)
return MyMatrixAlgorithm(select_algorithm(left_orth!, parent(A), alg))
end
function left_orth!(A, VC, alg::MyMatrixAlgorithm)
return MyMatrix.(left_orth!(parent(A), parent.(VC), parent(alg)))
endwhich seems to work and avoid the original method ambiguities this PR was designed to alleviate. |
|
I'll close this since I think there are better alternatives as discussed above. |
Followup to #79.
In some downstream packages, I want to define catch-all definitions like:
which is helpful if
Ais some kind of wrapper where I just want to forward anyLeftOrthAlgorithmbackend to the wrapper and rewrap the result. However, the current code is written like this:which means that to avoid method ambiguities, in practice I have to define:
i.e. I have to overload
left_orth!(and related functions) for every backendLeftOrthViaQR,LeftOrthViaPolar, etc.This PR is designed to address that with a layer of indirection:
with analogous changes to
check_inputandinitialize_output.