1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
12 #include "core/nns/kernel/Pair.cuh"
14 namespace cloudViewer {
20 // Unfortunately we can't use constexpr because there is no
21 // constexpr constructor for half
22 // FIXME: faiss CPU uses +/-FLT_MAX instead of +/-infinity
23 constexpr float kFloatMax = std::numeric_limits<float>::max();
24 constexpr float kFloatMin = std::numeric_limits<float>::lowest();
27 struct Limits<float> {
28 static __device__ __host__ inline float getMin() { return kFloatMin; }
29 static __device__ __host__ inline float getMax() { return kFloatMax; }
32 constexpr double kDoubleMax = std::numeric_limits<double>::max();
33 constexpr double kDoubleMin = std::numeric_limits<double>::lowest();
36 struct Limits<double> {
37 static __device__ __host__ inline double getMin() { return kDoubleMin; }
38 static __device__ __host__ inline double getMax() { return kDoubleMax; }
41 constexpr int kIntMax = std::numeric_limits<int>::max();
42 constexpr int kIntMin = std::numeric_limits<int>::lowest();
46 static __device__ __host__ inline int getMin() { return kIntMin; }
47 static __device__ __host__ inline int getMax() { return kIntMax; }
50 template <typename K, typename V>
51 struct Limits<Pair<K, V>> {
52 static __device__ __host__ inline Pair<K, V> getMin() {
53 return Pair<K, V>(Limits<K>::getMin(), Limits<V>::getMin());
56 static __device__ __host__ inline Pair<K, V> getMax() {
57 return Pair<K, V>(Limits<K>::getMax(), Limits<V>::getMax());
62 } // namespace cloudViewer