automatic commit
[folded-ctf.git] / sample_set.h
diff --git a/sample_set.h b/sample_set.h
new file mode 100644 (file)
index 0000000..ed870e8
--- /dev/null
@@ -0,0 +1,62 @@
+
+///////////////////////////////////////////////////////////////////////////
+// This program is free software: you can redistribute it and/or modify  //
+// it under the terms of the version 3 of the GNU General Public License //
+// as published by the Free Software Foundation.                         //
+//                                                                       //
+// This program is distributed in the hope that it will be useful, but   //
+// WITHOUT ANY WARRANTY; without even the implied warranty of            //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      //
+// General Public License for more details.                              //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with this program. If not, see <http://www.gnu.org/licenses/>.  //
+//                                                                       //
+// Written by Francois Fleuret, (C) IDIAP                                //
+// Contact <francois.fleuret@idiap.ch> for comments & bug reports        //
+///////////////////////////////////////////////////////////////////////////
+
+#ifndef SAMPLE_SET_H
+#define SAMPLE_SET_H
+
+#include "pose_cell.h"
+#include "pi_feature_family.h"
+#include "shared_responses.h"
+
+class SampleSet {
+  int _nb_features;
+  int _nb_samples;
+  SharedResponses *_shared_feature_values;
+  scalar_t **_feature_values;
+  int *_labels;
+
+public:
+
+  inline int nb_samples() { return _nb_samples; }
+  inline int nb_features() { return _nb_features; }
+
+  inline int label(int n_sample) {
+    ASSERT(n_sample >= 0 && n_sample < _nb_samples);
+    return _labels[n_sample];
+  }
+
+  inline scalar_t feature_value(int n_sample, int n_feature) {
+    ASSERT(n_sample >= 0 && n_sample < _nb_samples &&
+           n_feature >= 0 && n_feature < _nb_features);
+    ASSERT(!isnan(_feature_values[n_sample][n_feature]));
+    return _feature_values[n_sample][n_feature];
+  }
+
+  SampleSet(int nb_features, int nb_samples);
+  SampleSet(SampleSet *father, int nb, int *indexes);
+
+  ~SampleSet();
+
+  void set_sample(int n,
+                  PiFeatureFamily *pi_feature_family,
+                  RichImage *image,
+                  PoseCell *cell,
+                  int label);
+};
+
+#endif