SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SortUlongString.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) 1999-2009 Soeren Sonnenburg
8  * Written (W) 1999-2008 Gunnar Raetsch
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
16 
17 using namespace shogun;
18 
20 : CStringPreprocessor<uint64_t>()
21 {
22 }
23 
25 {
26 }
27 
29 bool CSortUlongString::init(CFeatures* f)
30 {
33 
34  return true;
35 }
36 
39 {
40 }
41 
44 {
47  return false;
48 }
49 
52 {
55  return false;
56 }
57 
62 {
63  int32_t i;
64  int32_t num_vec=((CStringFeatures<uint64_t>*)f)->get_num_vectors();
65 
66  for (i=0; i<num_vec; i++)
67  {
68  int32_t len=0;
69  bool free_vec;
70  uint64_t* vec=((CStringFeatures<uint64_t>*)f)->
71  get_feature_vector(i, len, free_vec);
72  ASSERT(!free_vec) // won't work with non-in-memory string features
73 
74  SG_DEBUG("sorting string of length %i\n", len)
75 
76  //CMath::qsort(vec, len);
77  CMath::radix_sort(vec, len);
78  }
79  return true;
80 }
81 
83 uint64_t* CSortUlongString::apply_to_string(uint64_t* f, int32_t& len)
84 {
85  uint64_t* vec=SG_MALLOC(uint64_t, len);
86  int32_t i=0;
87 
88  for (i=0; i<len; i++)
89  vec[i]=f[i];
90 
91  //CMath::qsort(vec, len);
92  CMath::radix_sort(vec, len);
93 
94  return vec;
95 }

SHOGUN Machine Learning Toolbox - Documentation