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 }
class for adding subset support to a class. Provides an interface for getting/setting subset_matrices...
Definition: Subset.h:24
virtual ~CSubset()
Definition: Subset.cpp:27
Parameter * m_parameters
Definition: SGObject.h:297
void add(bool *param, const char *name, const char *description="")
Definition: Parameter.cpp:23
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:76
shogun vector
Definition: DataType.h:31
#define SG_FREE(ptr)
Definition: memory.h:39
int32_t index_t
Definition: DataType.h:25
index_t vlen
Definition: DataType.h:248
CSubset * duplicate()
Definition: Subset.cpp:31

SHOGUN Machine Learning Toolbox - Documentation