Skip to main content

Calculate Euclidean distances between two sets of coordinates (Cython and Numexpr)

Project description

Calculate Euclidean distances between two sets of coordinates (Cython and Numexpr)

Tested against Windows / Python 3.11 / Anaconda

pip install cythoneuclideandistance

Calculate Euclidean distances between two sets of coordinates.

This function computes the Euclidean distance matrix between two sets of coordinates.

Args:
    coords1 (numpy.ndarray): An array of shape (n, 2) containing the first set of coordinates.
    coords2 (numpy.ndarray): An array of shape (m, 2) containing the second set of coordinates.

Returns:
    numpy.ndarray: A 2D array of shape (n, m) containing the Euclidean distances between all pairs of coordinates.

Example:
    import random
    import cythoneuclideandistance
    import numpy as np

    coords1 = np.array(
        [[random.randint(1, 1000), random.randint(1, 1000)] for _ in range(23000)],
        dtype=np.int32,
    )
    coords2 = np.array(
        [[random.randint(1, 1000), random.randint(1, 1000)] for _ in range(22150)],
        dtype=np.int32,
    )

    distance_matrix = cythoneuclideandistance.calculate_euc_distance(coords1, coords2)
    print(distance_matrix)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cythoneuclideandistance-0.11.tar.gz (21.5 kB view hashes)

Uploaded Source

Built Distribution

cythoneuclideandistance-0.11-py3-none-any.whl (22.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page