Closed tpgillam closed 5 months ago
This is certainly a bug. As you correctly pointed out, this package became independent of WavePropBase
at some point, and I was not sufficiently careful to test the changes thoroughly. And the documentation is certainly outdated in the places you mentioned!
Let me take a look at these issues, and I will get back to you soon with more information.
If you have a MWE of what you are trying to achieve, that would be quite helpful in understanding/fixing the problem! Thanks.
I made some small changes here and added a simple example to kernelmatrix.md
of how you may achieve something similar to what you asked. Let me know if this is not it :-)
If you have a MWE
Here's a very minimal MWE. (In my case the type actually represents a some geometry of finite extent, and the kernel is a function of a pair of elements, in case that were to change anything)
using HMatrices
using StaticArrays
struct MyType
a::Float64
b::Float64
end
HMatrices.center(t::MyType) = SVector(t.a, t.b)
X = [MyType(x, 2 * x) for x in 1:10]
Y = X
f(x::MyType, y::MyType) = (x.a + x.b + y.a + y.b) / 4
K = KernelMatrix(f, X, Y)
assemble_hmatrix(K)
which gives
ERROR: LoadError: MethodError: no method matching ClusterTree(::Vector{…}, ::HyperRectangle{…}, ::UnitRange{…}, ::Vector{…}, ::Vector{…}, ::Nothing, ::Nothing)
Closest candidates are:
ClusterTree(::Array{SVector{N, T}, 1}, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) where {N, T}
@ HMatrices ~/.julia/packages/HMatrices/prQKn/src/clustertree.jl:25
ClusterTree(::Any, ::Any; copy_elements, threads)
@ HMatrices ~/.julia/packages/HMatrices/prQKn/src/clustertree.jl:123
ClusterTree(::Any; ...)
@ HMatrices ~/.julia/packages/HMatrices/prQKn/src/clustertree.jl:123
Stacktrace:
[1] ClusterTree(elements::Vector{MyType}, splitter::CardinalitySplitter; copy_elements::Bool, threads::Bool)
@ HMatrices ~/.julia/packages/HMatrices/prQKn/src/clustertree.jl:138
[2] ClusterTree(elements::Vector{MyType}, splitter::CardinalitySplitter)
@ HMatrices ~/.julia/packages/HMatrices/prQKn/src/clustertree.jl:123
[3] assemble_hmatrix(K::KernelMatrix{…}; atol::Int64, rank::Int64, rtol::Float64, kwargs::@Kwargs{})
@ HMatrices ~/.julia/packages/HMatrices/prQKn/src/hmatrix.jl:324
[4] assemble_hmatrix(K::KernelMatrix{typeof(f), Vector{MyType}, Vector{MyType}, Float64})
@ HMatrices ~/.julia/packages/HMatrices/prQKn/src/hmatrix.jl:313
[5] top-level scope
@ ~/Documents/hmoo.jl:17
[6] include(fname::String)
@ Base.MainInclude ./client.jl:489
[7] top-level scope
@ REPL[3]:1
I made some small changes here and added a simple example to
kernelmatrix.md
of how you may achieve something similar to what you asked. Let me know if this is not it :-)
Thank you! I've tried running the example you give there (against the current release), and I get the same ClusterTree
error as I quoted above.
Ahh sorry, I just saw the map(center, ...)
that you added when moving the function. Won't test it right now but I suspect that should do the trick.
Thanks for the MWE. I just tested it, and it runs on the dev
branch. I will probably get this merged today, together with some other small changes I want to add, and tag a minor version. Let me know if that does not fix your issues.
For reference, it was indeed the commit simplifying the ClusterTree
structure that broke the functionality you wanted!
Fixed in #52
In Kernel matrices documentation it's stated that elements can be of any type:
However, I run into problems constructing
ClusterTree
s if I try to exercise this ability. Some assorted observations:as suggested in WavePropBase, I've implemented
HMatrices.center(::MyType)::SVector{3,Float64}
in the documentation, it's stated that
ClusterTree
comes fromWavePropBase
, but actually it seems this is no longer true.whilst
WavePropBase
's ClusterTree supports arbitrary element types, the current version inHMatrices
only supports SVectors.Trying to use
WavePropBase.ClusterTree
explicitly results in a MethodError forisleaf
.Am I approaching this case incorrectly? Or is this a bug? In any case, I'm looking forward to using HMatrices, as it should be directly applicable to my problem if it can handle this case. Thanks!