stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

[RFC]: City Block (Manhattan) distance between two strided arrays

Open Planeshifter opened this issue 2 years ago • 3 comments

This RFC proposes adding a function to calculate the City Block (Manhattan) distance between two strided arrays.

Package: @stdlib/math/strided/distances/cityblock

The function should have the following signature cityblock( N, x, strideX, y, strideY ).

  • N: Number of elements
  • x: First array
  • strideX: Stride for the first array
  • y: Second array
  • strideY: Stride for the second array

The function should return the City Block distance between the two arrays. It is calculated by summing the absolute differences between corresponding elements for each array.

The City Block (Manhattan) distance is a useful measure of distance between two points or vectors in a multidimensional space. It is commonly used in machine learning and data science applications. The ability to calculate the City Block distance between two strided arrays would make it easier to implement these algorithms in JavaScript.

See:

Related Issues

None.

Questions

No.

Other

No.

Checklist

  • [X] I have read and understood the Code of Conduct.
  • [X] Searched for existing issues and pull requests.
  • [X] The issue name begins with RFC:.

Planeshifter avatar Feb 01 '23 22:02 Planeshifter

For compute.io, we named as manhattan; SciPy names as cityblock. Is there a reason to prefer one over the other? Atm, the OP uses cityblock.

kgryte avatar Feb 01 '23 22:02 kgryte

Both SciPy and Julia use cityblock, so I was leaning towards that name. Either choice would be appropriate, I think.

Planeshifter avatar Feb 01 '23 22:02 Planeshifter

Fine with me. cityblock it is.

kgryte avatar Feb 01 '23 22:02 kgryte

Hi @Planeshifter. Is this RFC available to work on?

AhmedKhaled590 avatar Feb 26 '24 06:02 AhmedKhaled590

@AhmedKhaled590 This one is probably not ideal at the moment, as we need to do some R&D in terms of the interface. @Planeshifter and I will be putting up some new good first issues within the next day or so, some of which will be oriented toward C and native add-ons.

kgryte avatar Feb 26 '24 06:02 kgryte