Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does 3-arg kernelmatrix_diag require same length? #552

Closed
simsurace opened this issue Feb 20, 2024 · 4 comments
Closed

Does 3-arg kernelmatrix_diag require same length? #552

simsurace opened this issue Feb 20, 2024 · 4 comments

Comments

@simsurace
Copy link
Member

The docs state that

kernelmatrix_diag(κ::Kernel, x::AbstractVector, y::AbstractVector)
Compute the diagonal of `kernelmatrix(κ, x, y)` efficiently.
Requires that `x` and `y` are the same length.

However, testing this function for different-length output works for many kernels (did not try all though).
So is the docstring wrong or is this an accidental feature? (incidentally, diag on a non-square matrix works, so the feature could in principle be useful)

@willtebbutt
Copy link
Member

Hmm this definitely isn't an intended feature. Do you know what it computes when they're not the same length?

@simsurace
Copy link
Member Author

simsurace commented Feb 21, 2024

Yes the same as what diag on the full matrix would give.

@simsurace
Copy link
Member Author

Basically,

julia> x = rand(5); y = rand(4);

julia> kernelmatrix(SEKernel(), x, y)
5×4 Matrix{Float64}:
 0.913674  0.981759  0.925923  0.984204
 0.99906   0.848392  0.999942  0.979586
 0.998322  0.796401  0.995909  0.954717
 0.996092  0.869745  0.998438  0.987599
 0.997917  0.85858   0.999488  0.983593

julia> kernelmatrix_diag(SEKernel(), x, y)
4-element Vector{Float64}:
 0.9136737830751345
 0.8483918154068688
 0.9959090633450111
 0.9875987951145452

julia> kernelmatrix(SEKernel(), x, y) |> diag
4-element Vector{Float64}:
 0.9136737830751345
 0.8483918154068689
 0.9959090633450111
 0.9875987951145452

@simsurace
Copy link
Member Author

#553 showed that the unequal-length case errors for many kernel and input type combinations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants