| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include <stdlib.h>
- #include <stdio.h>
- #include "MaxHeap.h"
- #include "utils.h"
- #define Point(i) (&(data[i * nFeatures]))
- void nbhSearchBruteForce(SearchParams * params) {
- pyWord i, j;
- pyReal d;
- // Berechne alle Distanzen
- for(i = 0; i < nPoints; i ++) {
- const pyReal *x = Point(i);
-
- for(j = i + 1; j < nPoints; j ++) {
- const pyReal * y = Point(j);
- d = distSquared(x, y, nFeatures);
-
- maxHeap_insert(&(params.nbhHeaps.heaps[i]), j, d);
- maxHeap_insert(&(params.nbhHeaps.heaps[j]), i, d);
- }
- }
- }
- void Neighborhood(const pyWord nbhSize, const pyWord nPoints, const pyWord nFeatures, const pyReal * data, pyWord * neighborhoods) {
- SearchParams params = {
- .nbhSize = nbhSize,
- .nPoints = nPoints,
- .nFeatures = nFeatures,
- .data = data,
- .neighborhoods = neighborhoods
- };
- if(initNbhHeaps(¶ms)) {
- return;
- }
- nbhSearchBruteForce(params);
-
- freeNbhHeaps(¶ms);
- }
|