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