Added README.md
[clueless-kmeans.git] / sample_set.cc
1 /*
2  *  clueless-kmeans is a variant of k-means which enforces balanced
3  *  distribution of classes in every cluster
4  *
5  *  Copyright (c) 2013 Idiap Research Institute, http://www.idiap.ch/
6  *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
7  *
8  *  This file is part of clueless-kmeans.
9  *
10  *  clueless-kmeans is free software: you can redistribute it and/or
11  *  modify it under the terms of the GNU General Public License
12  *  version 3 as published by the Free Software Foundation.
13  *
14  *  clueless-kmeans is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with selector.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "sample_set.h"
25 #include "arrays.h"
26
27 SampleSet::SampleSet() {
28   labels = 0;
29   points = 0;
30 }
31
32 SampleSet::~SampleSet() {
33   delete[] labels;
34   deallocate_array<scalar_t>(points);
35 }
36
37 void SampleSet::resize(int d, int np) {
38   delete[] labels;
39   deallocate_array<scalar_t>(points);
40   nb_points = np;
41   dim = d;
42   points = allocate_array<scalar_t>(nb_points, dim);
43   labels = new int[nb_points];
44 }
45