Skip to content

Commit 0e57bd9

Browse files
committed
Merge branch 'main' of github.com:algo-hhu/k-min-sum-radii
2 parents ae1acc8 + 49fab73 commit 0e57bd9

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

build_extension.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ class BuildExt(build_ext):
7171
"""A custom build extension for adding -stdlib arguments for clang++."""
7272

7373
def build_extensions(self) -> None:
74-
support = check_openmp_support()
74+
if os.name == "nt":
75+
support = True
76+
else:
77+
support = check_openmp_support()
7578

7679
# '-std=c++11' is added to `extra_compile_args` so the code can compile
7780
# with clang++. This works across compilers (ignored by MSVC).

kmsr/cpp/gonzales.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ double gonzalesrmax(const vector<Point> &points, int k, int seed)
2525
while (static_cast<int>(centers.size()) < k)
2626
{
2727
// Choose the next center based on the maximum distance
28-
int nextCenterIndex = distance(
28+
size_t nextCenterIndex = distance(
2929
distances.begin(), max_element(distances.begin(), distances.end()));
3030
Point nextCenter = points[nextCenterIndex];
3131
centers.push_back(nextCenter);

kmsr/cpp/heuristic.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace std;
1818
vector<Cluster> gonzales(vector<Point> &points, int k, int seed)
1919
{
2020
srand(seed);
21-
int n = points.size();
21+
int n = static_cast<int>(points.size());
2222
vector<Point> centers;
2323
centers.push_back(points[rand() % n]);
2424

@@ -54,7 +54,7 @@ vector<Cluster> gonzales(vector<Point> &points, int k, int seed)
5454

5555
vector<Cluster> kMeansPlusPlus(vector<Point> &points, int k, int seed)
5656
{
57-
int n = points.size();
57+
int n = static_cast<int>(points.size());
5858
vector<Point> centers;
5959
mt19937 gen(seed);
6060
uniform_int_distribution<> dis(0, n - 1);
@@ -130,7 +130,7 @@ vector<Cluster> kMeansPlusPlus(vector<Point> &points, int k, int seed)
130130

131131
vector<Cluster> heuristik(vector<Point> &points, int k)
132132
{
133-
int n = points.size();
133+
int n = static_cast<int>(points.size());
134134
vector<Cluster> bestCluster;
135135
bestCluster.push_back(
136136
Cluster(points)); // Initialize with all points in one cluster

kmsr/cpp/k_MSR.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ vector<vector<double>> getRadii(double rmax, int k, double epsilon)
2020
vector<double> set;
2121

2222
// Calculate the number of radii needed to ensure sufficient coverage
23-
int limit = ceil(logBase((k / epsilon), (1 + epsilon)));
23+
int limit = static_cast<int>(ceil(logBase((k / epsilon), (1 + epsilon))));
2424

2525
// Create the set of radii whose permutations will be formed.
2626
for (int i = 0; i <= limit; i++)
@@ -63,7 +63,7 @@ vector<vector<double>> getRandomRadii(double rmax, int k, double epsilon,
6363
vector<double> set;
6464

6565
// Calculate the number of radii needed to ensure sufficient coverage
66-
int limit = ceil(logBase((k / epsilon), (1 + epsilon)));
66+
int limit = static_cast<int>(ceil(logBase((k / epsilon), (1 + epsilon))));
6767

6868
// Create the set of radii whose permutations will be formed.
6969
for (int i = 0; i <= limit; i++)
@@ -77,7 +77,7 @@ vector<vector<double>> getRandomRadii(double rmax, int k, double epsilon,
7777
mt19937 gen(seed);
7878

7979
// Define a uniform distribution for integers between 0 and set.size()-1.
80-
uniform_int_distribution<> distrib(0, set.size() - 1);
80+
uniform_int_distribution<> distrib(0, static_cast<int>(set.size()) - 1);
8181

8282
// Generate numVectors number of vectors.
8383
for (int i = 0; i < numRadiiVectors; i++)
@@ -131,7 +131,7 @@ vector<vector<int>> getU(int n, int k, double epsilon, int numUVectors, int seed
131131
vector<Ball> selection(const vector<Point> &points, int k, const vector<int> &u,
132132
const vector<double> &radii, double epsilon)
133133
{
134-
vector<Ball> balls(k, Ball(points.front().getCoordinates().size()));
134+
vector<Ball> balls(k, Ball(static_cast<int>(points.front().getCoordinates().size())));
135135
vector<vector<Point>> Si(k);
136136
double lambda = 1 + epsilon + 2 * sqrt(epsilon);
137137

@@ -181,7 +181,7 @@ vector<Cluster> clustering(const vector<Point> &points, int k, double epsilon,
181181
// Calculate the radii and u values based on 'rmax', 'k', and 'epsilon'.
182182
vector<vector<double>> radii =
183183
getRandomRadii(rmax, k, epsilon, numRadiiVectors, seed);
184-
vector<vector<int>> u = getU(points.size(), k, epsilon, numUVectors, seed);
184+
vector<vector<int>> u = getU(static_cast<int>(points.size()), k, epsilon, numUVectors, seed);
185185

186186
// Initialize the 'bestCluster' by making all points part of a cluster.
187187
bestCluster[0].setPoints(points);

kmsr/cpp/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bool clustersOverlap(const Cluster &c1, const Cluster &c2)
3131
std::vector<Cluster> assignPointsToCluster(const std::vector<Point> &points,
3232
const std::vector<Point> &centers, int k)
3333
{
34-
int n = points.size();
34+
int n = static_cast<int>(points.size());
3535
std::vector<Cluster> clusters(k);
3636

3737
// Create clusters based on the centers
@@ -59,7 +59,7 @@ std::vector<Cluster> assignPointsToCluster(const std::vector<Point> &points,
5959
// Computes the centroid of the cluster
6060
Point computeCentroid(const std::vector<Point> &points)
6161
{
62-
int dimension = points[0].getCoordinates().size();
62+
int dimension = static_cast<int>(points[0].getCoordinates().size());
6363
std::vector<double> centroidCoords(dimension, 0.0);
6464

6565
// Sum of the coordinates of all points in the cluster

kmsr/cpp/welzl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct PointCoordAccessor
1818

1919
Ball findMinEnclosingBall(const vector<Point> &points)
2020
{
21-
int dimension = points.front().getCoordinates().size();
21+
int dimension = static_cast<int>(points.front().getCoordinates().size());
2222

2323
Miniball::Miniball<PointCoordAccessor> mb(dimension, points.begin(),
2424
points.end());

kmsr/cpp/yildirim.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using namespace std;
88
// Function to find the furthest point from a given point
99
int findFurthestPoint(const std::vector<Point> &points, const Point &p)
1010
{
11-
int furthestIndex = 0;
11+
size_t furthestIndex = 0;
1212
double maxDistSquared = 0.0;
1313
for (size_t i = 0; i < points.size(); i++)
1414
{
@@ -21,7 +21,7 @@ int findFurthestPoint(const std::vector<Point> &points, const Point &p)
2121
furthestIndex = i;
2222
}
2323
}
24-
return furthestIndex;
24+
return static_cast<int>(furthestIndex);
2525
}
2626

2727
// Function to calculate the weighted sum of the squares of the coordinates

0 commit comments

Comments
 (0)