KernelFunctions.jl
KernelFunctions.jl copied to clipboard
iskroncompatible
iskroncompatibleappears to be incorrectly implemented in a couple of places. For example, I don't believe that anExponentialKernelshould not be marked as compatible, or have I misunderstood something?- Do we really want to try and do this with a flag method? Would be not be better off introducing a
RectilinearGridinput type (that is a subtype ofAbstractVector) and then using dispatch to figure out whether it's correct to return aKroneckerMatrixwhenkernelmatrixis called?
Back to this :
-
- Yep that's a mistake, I will take care of it
-
- How would you figure out automatically the factorization of the kernel? Also wouldn't that lead to type instability?
I wouldn't imagine that you would need to introduce a type instability. One would just implement specialised kernelmatrix functions for kernels that are separable when they receive a RectilinearGrid, that spit out Kronecker matrices (e.g. from Kronecker.jl). Everything else in the pipeline would just specialise on that.
Am I missing something?
e.g.
kernelmatrix(k::SqExponentialKernel, x::RectilinearGrid) = Kronecker(...)
and all of the other SqExponentialKernel methods would remain unchanged.
Coming back to this issue:
- I think the
RectilinearGridsolution would be too restrictive (I don't think a uniform grid is needed to compute a Kronecker matrix?). I don't see a problem having it, but I think dispatching separately for every kernel able to do it is too much unnecessary work. - The other solution would be to rely on traits, but that would be doing the exact same thing no?
Additional point we can also define the TensorProduct as "kroncompatible"
I think the RectilinearGrid solution would be too restrictive (I don't think a uniform grid is needed to compute a Kronecker matrix?). I don't see a problem having it, but I think dispatching separately for every kernel able to do it is too much unnecessary work.
It's just unclear to me what other contexts Kronecker product structure arises in. You need to have some kind of cartesian-product-like structure, and a rectilinear grid is the most general manifestation of that in Euclidean space, if I'm not mistaken. Maybe CartesianProductVector would be a better name?
More structured output, such as Toeplitz or circulant matrices, would be useful also when working with Gaussian random fields.
Yes! It's even in the README! :laughing:
For Toeplitz matrices, it would be good to fix https://github.com/JuliaMatrices/ToeplitzMatrices.jl/issues/36 :grimacing:
Edit: I opened a PR: https://github.com/JuliaMatrices/ToeplitzMatrices.jl/pull/60