X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=sample_set.h;fp=sample_set.h;h=ed870e8481b304e4f7fb9c5586b31075b8579439;hb=d922ad61d35e9a6996730bec24b16f8bf7bc426c;hp=0000000000000000000000000000000000000000;hpb=3bb118f5a9462d02ff7d99ef28ecc0d7e23529f9;p=folded-ctf.git diff --git a/sample_set.h b/sample_set.h new file mode 100644 index 0000000..ed870e8 --- /dev/null +++ b/sample_set.h @@ -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 . // +// // +// Written by Francois Fleuret, (C) IDIAP // +// Contact 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