Manifolds.jl icon indicating copy to clipboard operation
Manifolds.jl copied to clipboard

Elementwise distance

Open mateuszbaran opened this issue 3 years ago • 2 comments
trafficstars

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

mateuszbaran avatar Feb 07 '22 18:02 mateuszbaran

This could indeed just be added to ManifoldsBase?

kellertuer avatar Feb 07 '22 19:02 kellertuer

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

mateuszbaran avatar Feb 07 '22 19:02 mateuszbaran