automatic commit
[folded-ctf.git] / sample_set.h
1
2 ///////////////////////////////////////////////////////////////////////////
3 // This program is free software: you can redistribute it and/or modify  //
4 // it under the terms of the version 3 of the GNU General Public License //
5 // as published by the Free Software Foundation.                         //
6 //                                                                       //
7 // This program is distributed in the hope that it will be useful, but   //
8 // WITHOUT ANY WARRANTY; without even the implied warranty of            //
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      //
10 // General Public License for more details.                              //
11 //                                                                       //
12 // You should have received a copy of the GNU General Public License     //
13 // along with this program. If not, see <http://www.gnu.org/licenses/>.  //
14 //                                                                       //
15 // Written by Francois Fleuret, (C) IDIAP                                //
16 // Contact <francois.fleuret@idiap.ch> for comments & bug reports        //
17 ///////////////////////////////////////////////////////////////////////////
18
19 #ifndef SAMPLE_SET_H
20 #define SAMPLE_SET_H
21
22 #include "pose_cell.h"
23 #include "pi_feature_family.h"
24 #include "shared_responses.h"
25
26 class SampleSet {
27   int _nb_features;
28   int _nb_samples;
29   SharedResponses *_shared_feature_values;
30   scalar_t **_feature_values;
31   int *_labels;
32
33 public:
34
35   inline int nb_samples() { return _nb_samples; }
36   inline int nb_features() { return _nb_features; }
37
38   inline int label(int n_sample) {
39     ASSERT(n_sample >= 0 && n_sample < _nb_samples);
40     return _labels[n_sample];
41   }
42
43   inline scalar_t feature_value(int n_sample, int n_feature) {
44     ASSERT(n_sample >= 0 && n_sample < _nb_samples &&
45            n_feature >= 0 && n_feature < _nb_features);
46     ASSERT(!isnan(_feature_values[n_sample][n_feature]));
47     return _feature_values[n_sample][n_feature];
48   }
49
50   SampleSet(int nb_features, int nb_samples);
51   SampleSet(SampleSet *father, int nb, int *indexes);
52
53   ~SampleSet();
54
55   void set_sample(int n,
56                   PiFeatureFamily *pi_feature_family,
57                   RichImage *image,
58                   PoseCell *cell,
59                   int label);
60 };
61
62 #endif