1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @file geospatial.h
* @brief SIMD-accelerated Geo-Spatial distance functions.
* @author Ash Vardanian
* @date July 1, 2023
*
* Contains:
* - Haversine (Great Circle) distance
* - Vincenty's distance function for Oblate Spheroid Geodesics
*
* For datatypes:
* - 32-bit IEEE-754 floating point
* - 64-bit IEEE-754 floating point
*
* For hardware architectures:
* - Arm: NEON
* - x86: Haswell
*
* In most cases, for distance computations, we don't need the exact Haversine formula.
* The very last part of the computation applies `asin(sqrt(x))` non-linear transformation.
* Both `asin` and `sqrt` are monotonically increasing functions, so their product is also
* monotonically increasing. This means, for relative similarity/closeness computation we
* can avoid that expensive last step.
*
* x86 intrinsics: https://www.intel.com/content/www/us/en/docs/intrinsics-guide/
* Arm intrinsics: https://developer.arm.com/architectures/instruction-sets/intrinsics/
* Oblate Spheroid Geodesic: https://mathworld.wolfram.com/OblateSpheroidGeodesic.html
* Staging experiments: https://github.com/ashvardanian/HaversineSimSIMD
*/
extern "C" __cplusplus
}