SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Subset.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011 Heiko Strathmann
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
10 
11 #include <shogun/features/Subset.h>
12 #include <shogun/io/SGIO.h>
13 #include <shogun/base/Parameter.h>
14 
15 using namespace shogun;
16 
17 CSubset::CSubset() : m_subset_idx(SGVector<index_t>())
18 {
19  init();
20 }
21 
22 CSubset::CSubset(SGVector<index_t> subset_idx) : m_subset_idx(subset_idx)
23 {
24  init();
25 }
26 
28  SG_FREE(m_subset_idx.vector);
29 }
30 
32  SGVector<index_t> idx_copy(m_subset_idx.vlen);
33 
34  memcpy(idx_copy.vector, m_subset_idx.vector,
35  sizeof(index_t)*m_subset_idx.vlen);
36 
37  CSubset* copy_subset=new CSubset(idx_copy);
38 
39  return copy_subset;
40 }
41 
42 void CSubset::init() {
43  m_parameters->add((CSGObject**)&m_subset_idx, "subset",
44  "Vector of subset indices");
45 }

SHOGUN Machine Learning Toolbox - Documentation