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

rusty1s's avatar
rusty1s committed
5
void cluster_(serial)(THLongTensor *output, THLongTensor *row, THLongTensor *col, THLongTensor *degree, THTensor *weight) {
rusty1s's avatar
rusty1s committed
6
  real *weight_data = weight->storage->data + weight->storageOffset;
rusty1s's avatar
rusty1s committed
7
  real weight_value, w;
rusty1s's avatar
rusty1s committed
8
9
  int64_t d, c;
  SERIAL(output, row, col, degree,
rusty1s's avatar
rusty1s committed
10
11
    weight_value = 0;
    for (d = 0; d < degree_data[row_value]; d++) {  // Iterate over neighbors.
rusty1s's avatar
rusty1s committed
12
13
      c = col_data[e + d];
      w = weight_data[e + d];
rusty1s's avatar
rusty1s committed
14
15
      if (output_data[c] < 0 && w >= weight_value) {
        // Neighbor is unmatched and edge has a higher weight.
rusty1s's avatar
rusty1s committed
16
        col_value = c;
rusty1s's avatar
rusty1s committed
17
        weight_value = w;
rusty1s's avatar
rusty1s committed
18
19
20
      }
    }
  )
rusty1s's avatar
fixes  
rusty1s committed
21
22
23
}

#endif