Use CMSIS-DSP distance functions

CMSIS-DSP provides most of the distance functions which are generally used In clustering algorithms. It includes distance functions for float but also for booleans.

All distance functions in the CMSIS-DSP have a similar API. Let's use the Manhattan distance, also known as the city block distance, as an example.

The API of the city block distance is described in the following code:

float32_t arm_cityblock_distance_f32(const float32_t *pA,
const float32_t *pB,
uint32_t blockSize);

This function computes the distance between two vectors, pA and pB, of the dimension blockSize.

The folder CMSIS/DSP/DistanceFunctions also contains functions which are not really distances from a mathematical point of view. For instance, the cosine distance is a measure of similarity.

Previous Next