SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SGSparseVector.h
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) 2012 Fernando José Iglesias García
8  * Written (W) 2010,2012 Soeren Sonnenburg
9  * Copyright (C) 2010 Berlin Institute of Technology
10  * Copyright (C) 2012 Soeren Sonnenburg
11  */
12 
13 #ifndef __SGSPARSEVECTOR_H__
14 #define __SGSPARSEVECTOR_H__
15 
16 #include <shogun/lib/config.h>
17 #include <shogun/lib/DataType.h>
19 #include <map>
20 
21 namespace shogun
22 {
23 
24 
26 template <class T> struct SGSparseVectorEntry
27 {
31  T entry;
32 };
33 
35 template <class T> class SGSparseVector : public SGReferencedData
36 {
37 public:
40  {
41  init_data();
42  }
43 
46  bool ref_counting=true) :
47  SGReferencedData(ref_counting),
48  num_feat_entries(num_entries), features(feats)
49  {
50  }
51 
53  SGSparseVector(index_t num_entries, bool ref_counting=true) :
54  SGReferencedData(ref_counting),
55  num_feat_entries(num_entries)
56  {
58  }
59 
62  SGReferencedData(orig)
63  {
64  copy_data(orig);
65  }
66 
67  virtual ~SGSparseVector()
68  {
69  unref();
70  }
71 
72 protected:
73 
74  virtual void copy_data(const SGReferencedData& orig)
75  {
77  features = ((SGSparseVector*)(&orig))->features;
78  }
79 
80  virtual void init_data()
81  {
82  num_feat_entries = 0;
83  features = NULL;
84  }
85 
86  virtual void free_data()
87  {
88  num_feat_entries = 0;
90  }
91 
92 public:
95 
98 
99 };
100 
101 }
102 
103 #endif // __SGSPARSEVECTOR_H__

SHOGUN Machine Learning Toolbox - Documentation