SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DecompressString.cpp
Go to the documentation of this file.
2 
3 namespace shogun
4 {
5 
7 template <class ST>
9 {
10  compressor=NULL;
11  CSGObject::set_generic<ST>();
12 }
13 
14 template <class ST>
16 {
17  compressor=new CCompressor(ct);
18  CSGObject::set_generic<ST>();
19 }
20 
21 template <class ST>
23 {
24  delete compressor;
25 }
26 
27 template <class ST>
29 {
31  return true;
32 }
33 
34 template <class ST>
36 {
37 }
38 
39 template <class ST>
41 {
44  return false;
45 }
46 
47 template <class ST>
49 {
52  return false;
53 }
54 
55 template <class ST>
57 {
58  int32_t i;
59  int32_t num_vec=((CStringFeatures<ST>*)f)->get_num_vectors();
60 
61  for (i=0; i<num_vec; i++)
62  {
63  int32_t len=0;
64  bool free_vec;
65  ST* vec=((CStringFeatures<ST>*)f)->
66  get_feature_vector(i, len, free_vec);
67 
68  ST* decompressed=apply_to_string(vec, len);
69  ((CStringFeatures<ST>*)f)->
70  free_feature_vector(vec, i, free_vec);
71  ((CStringFeatures<ST>*)f)->
72  cleanup_feature_vector(i);
73  ((CStringFeatures<ST>*)f)->
74  set_feature_vector(i, decompressed, len);
75  }
76  return true;
77 }
78 
79 template <class ST>
81 {
82  uint64_t compressed_size=((int32_t*) f)[0];
83  uint64_t uncompressed_size=((int32_t*) f)[1];
84 
85  int32_t offs=CMath::ceil(2.0*sizeof(int32_t)/sizeof(ST));
86  ASSERT(uint64_t(len)==uint64_t(offs)+compressed_size)
87 
88  len=uncompressed_size;
89  uncompressed_size*=sizeof(ST);
90  ST* vec=SG_MALLOC(ST, len);
91  compressor->decompress((uint8_t*) (&f[offs]), compressed_size,
92  (uint8_t*) vec, uncompressed_size);
93 
94  ASSERT(uncompressed_size==((uint64_t) len)*sizeof(ST))
95  return vec;
96 }
97 
98 template <class ST>
100 {
101  return P_DECOMPRESSSTRING;
102 }
103 
104 template class CDecompressString<bool>;
105 template class CDecompressString<char>;
106 template class CDecompressString<int8_t>;
107 template class CDecompressString<uint8_t>;
108 template class CDecompressString<int16_t>;
109 template class CDecompressString<uint16_t>;
110 template class CDecompressString<int32_t>;
111 template class CDecompressString<uint32_t>;
112 template class CDecompressString<int64_t>;
113 template class CDecompressString<uint64_t>;
114 template class CDecompressString<float32_t>;
115 template class CDecompressString<float64_t>;
116 template class CDecompressString<floatmax_t>;
117 }

SHOGUN Machine Learning Toolbox - Documentation