GenSVM
gensvm_checks.c
Go to the documentation of this file.
1 
27 #include "gensvm_checks.h"
28 
44 {
45  bool in_uniq, is_contiguous = true;
46  long i, j, K = 1;
47  long max_y = -1,
48  min_y = LONG_MAX;
49  long *uniq_y = Calloc(long, K);
50  uniq_y[0] = data->y[0];
51 
52  for (i=1; i<data->n; i++) {
53  in_uniq = false;
54  for (j=0; j<K; j++) {
55  if (uniq_y[j] == data->y[i]) {
56  in_uniq = true;
57  break;
58  }
59  }
60 
61  if (!in_uniq) {
62  uniq_y = Realloc(uniq_y, long, K+1);
63  uniq_y[K++] = data->y[i];
64  }
65 
66  max_y = maximum(max_y, data->y[i]);
67  min_y = minimum(min_y, data->y[i]);
68  }
69 
70  if (min_y < 1 || max_y > K) {
71  is_contiguous = false;
72  }
73 
74  free(uniq_y);
75 
76  return is_contiguous;
77 }
#define Calloc(type, size)
Definition: gensvm_memory.h:40
long K
number of classes for the workspace
Definition: gensvm_base.h:156
Header file for gensvm_checks.c.
long * y
array of class labels, 1..K
Definition: gensvm_base.h:66
A structure to represent the data.
Definition: gensvm_base.h:57
#define Realloc(var, type, size)
Definition: gensvm_memory.h:55
#define maximum(a, b)
bool gensvm_check_outcome_contiguous(struct GenData *data)
Check if the labels are contiguous on [1 .. K].
Definition: gensvm_checks.c:43
#define minimum(a, b)
long n
number of instances
Definition: gensvm_base.h:60