#include "tests/helpers.h" //auxiliary to check vectors equality int checkEqualV(double* v1, double* v2, int n) { double epsilon = 1e-10; // arbitrary small value to make comparisons for (int i=0; i= epsilon) return S_FALSE; } return S_TRUE; } // auxiliary to count distinct values in an integer array int countDistinctValues(int* v, int n) { int maxVal = v[0]; for (int i=1; i maxVal) maxVal = v[i]; } int* kountArray = (int*)calloc(maxVal+1,sizeof(int)); int res = 0; for (int i=0; i= n) break; int label = clusters[i]; processedLabels[countProcessedLabels++] = label; // count elements in current cluster (represented by label) int countDataWithCurLabel = 0; for (int ii=0; ii tol ) { free(processedLabels); return S_FALSE; } // now check counts per cluster (repartition); // the labels should not be spread between different (true) groups int maxCountLabelInClust = 0; for (int kounter=0; kounter maxCountLabelInClust) maxCountLabelInClust = countLabelInClust; } // we must have max(repartition) / clustSize >= 1 - tol if ((double)maxCountLabelInClust / clustSize < 1.0 - tol) { free(processedLabels); return S_FALSE; } } free(processedLabels); return S_TRUE; }