Uh oh!
There was an error while loading. Please reload this page.
Refactor algorithm selection in type domain - #30
Conversation
Codecov ReportAttention: Patch coverage is
🚀 New features to boost your workflow:
|
mtfishman
commented
May 27, 2025
Looks good to me, this will be helpful. |
Jutho
commented
May 27, 2025
While I am not opposed to this change, I was wondering if this helps with anything? Semantically, I guess it makes sense that the default algorithm only depends on the type of Furthermore, there might actually be cases where the default algorithm selection does want to depend on properties of
Not really, as the |
lkdvos
commented
May 27, 2025
The main point where this appeared was in trying to select a default algorithm for either TensorMap or BlockSparseArrays: I wanted to reuse the I somehow assumed this solution was the easiest, since both TensorMap and BlockSparseArrays can quite easily tell you their blocktype, but an alternative solution is to simply define a I'll reintroduce the other |
EDIT: Sorry for repeating your points you Lukas, I posted this before noticing your post.
The use case we have in mind is a block diagonal matrix, where you might want to extract the type of the block to determine the default algorithm for the blocks, i.e.: default_algorithm(f::typeof(svd_compact!), A::BlockDiagonalMatrix) =BlockDiagonalAlgorithm(default_algorithm(f, blocktype(A))It's a bit easier to reason about working in the type domain, rather than grabbing instances of blocks.
That's true, but from what I can tell this PR still allows customizing based on instances if you want to.
I agree with this, I think it is a bit easier to reason about code like: default_svd_algorithm(A) =LAPACK_DivideAndConquer()
default_algorithm(::typeof(svd_compact!), A) =default_svd_algorithm(A)
default_algorithm(::typeof(svd_full!), A) =default_svd_algorithm(A)rather than: default_algorithm(::typeof(svd_compact!), A) =LAPACK_DivideAndConquer()
default_algorithm(::typeof(svd_full!), A) =default_algorithm(svd_compact!, A)since you can more easily remember that the actual definition is |
A |
Jutho
commented
May 27, 2025
I see the argument about the type domain, that is indeed a very valid remark. The lack of certain No strong opinions on the |
lkdvos
commented
May 28, 2025
I've reinstated the desired functions and opened an issue to remind myself to add the default algorithm, which I'll implement in a separate PR. |
mtfishman
commented
May 29, 2025
@Jutho do you have any more comments on this? I think it would be nice to merge this, I have some ongoing work that would benefit from this. |
Jutho
commented
May 30, 2025
Yes looks good to me, feel free to merge. |
This alters the algorithm selection and default algorithms to be implemented in the type domain instead.
While doing this, I also realized that the new
default_algorithm(f, ...)anddefault_f_algare tautologous, so I removed the latter.Given that these were not public, and the implementations in the "value domain" still dispatch to the type domain, I think this is non-breaking, so should be v0.2.1.
Fixes#29.