THGreedy.c 647 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
#ifndef TH_GENERIC_FILE
#define TH_GENERIC_FILE "generic/THGreedy.c"
#else

rusty1s's avatar
rusty1s committed
5
6
void THGreedy_(THLongTensor *cluster, THLongTensor *row, THLongTensor *col, THLongTensor *deg,
               THTensor *weight) {
rusty1s's avatar
rusty1s committed
7
  real *weightData = DATA(weight);
rusty1s's avatar
rusty1s committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  real maxWeight = 0, tmpWeight;
  TH_GREEDY_CLUSTER(cluster, row, col, deg,
    for (neighborIdx = rowIdx; neighborIdx < rowIdx + degData[rowValue]; neighborIdx++) {
      tmp = colData[neighborIdx];
      tmpWeight = weightData[neighborIdx];
      if (clusterData[tmp] < 0 && tmpWeight > maxWeight) {
        colValue = tmp;
        maxWeight = tmpWeight;
      }
    }
  )
}

#endif  // TH_GENERIC_FILE