Giter VIP home page Giter VIP logo

rust-emd's Introduction

EMD

Build Status

A simple Rust library for computing the Earth Mover's Distance (or "Wasserstein distance" or "Kantorovich–Rubinstein distance").

This is a wrapper of Gary Doran's pyemd.

Basic usage

Include the following in Cargo.toml:

emd = "0.1.1"

Then:

extern crate emd;
#[macro_use(array)]
extern crate ndarray;

use emd::*;
use ndarray::*;

let x = array![0., 1.];
let y = array![5., 3.];
assert_eq!(distance(&x.view(), &y.view()), 3.5);

Check out the docs for more.

Maintainers

gchers, ehentgen

rust-emd's People

Contributors

gchers avatar

Stargazers

Dilawar Singh avatar Tadas Šubonis avatar Thiago Vieira avatar

Watchers

James Cloos avatar  avatar

rust-emd's Issues

ndarray 13.1 incompatibility

I've found that distance() expects a ndarray 12.1 specific ArrayView:

= note: expected reference `&ndarray::ArrayBase<ndarray::ViewRepr<&f64>, ndarray::dimension::dim::Dim<[usize; 2]>>`
               found reference `&ndarray::ArrayBase<ndarray::ViewRepr<&f64>, ndarray::Dim<[usize; 2]>>`
= note: perhaps two different versions of crate `ndarray` are being used?

Would you mind updating the dependency to 13.1? I'm quite new to rust, but maybe this would solve the issue.

Memory leakage in `distance_generic`

After function distance_generic uses Box::into_raw, it is responsible for releasing the memory previously managed by the Box. Otherwise, there will be a memory leakage.

cost.push(Box::into_raw(cost_i.into_boxed_slice()) as *const c_double);

The easiest way to do this is to convert the raw pointer back into a Box with the Box::from_raw function, allowing the Box destructor to perform the cleanup.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.