JuliaManifolds / ManifoldsBase.jl

Basic interface for manifolds in Julia
https://juliamanifolds.github.io/ManifoldsBase.jl/
MIT License
87 stars 8 forks source link

Elementwise distance #136

Open mateuszbaran opened 2 years ago

mateuszbaran commented 2 years ago

A function for calculating elementwise distance between points might be useful. Something like this for example:

function elementwise_distance(M::AbstractPowerManifold, p, q)
    dists = similar(p, number_eltype(p), power_dimensions(M))
    return elementwise_distance!(M, dists, p, q)
end

function elementwise_distance!(M::AbstractPowerManifold, dists, p, q)
    rep_size = representation_size(M.manifold)
    for i in get_iterator(M)
        dists[i...] = distance(M.manifold, _read(M, rep_size, p, i), _read(M, rep_size, q, i))
    end
    return dists
end
kellertuer commented 2 years ago

This could indeed just be added to ManifoldsBase?

mateuszbaran commented 2 years ago

Yes, I'd also say that this should be in ManifoldsBase.jl.