00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 1999-2008 Soeren Sonnenburg 00008 * Written (W) 1999-2008 Gunnar Raetsch 00009 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society 00010 */ 00011 00012 #include "preproc/SortUlongString.h" 00013 #include "features/Features.h" 00014 #include "features/StringFeatures.h" 00015 #include "lib/Mathematics.h" 00016 00017 CSortUlongString::CSortUlongString() 00018 : CStringPreProc<uint64_t>("SortUlongString", "STUS") 00019 { 00020 } 00021 00022 CSortUlongString::~CSortUlongString() 00023 { 00024 } 00025 00027 bool CSortUlongString::init(CFeatures* f) 00028 { 00029 ASSERT(f->get_feature_class()==C_STRING); 00030 ASSERT(f->get_feature_type()==F_ULONG); 00031 00032 return true; 00033 } 00034 00036 void CSortUlongString::cleanup() 00037 { 00038 } 00039 00041 bool CSortUlongString::load(FILE* f) 00042 { 00043 return false; 00044 } 00045 00047 bool CSortUlongString::save(FILE* f) 00048 { 00049 return false; 00050 } 00051 00055 bool CSortUlongString::apply_to_string_features(CFeatures* f) 00056 { 00057 int32_t i; 00058 int32_t num_vec=((CStringFeatures<uint64_t>*)f)->get_num_vectors(); 00059 00060 for (i=0; i<num_vec; i++) 00061 { 00062 int32_t len=0; 00063 uint64_t* vec=((CStringFeatures<uint64_t>*)f)-> 00064 get_feature_vector(i, len); 00065 SG_DEBUG( "sorting string of length %i\n", len); 00066 00067 //CMath::qsort(vec, len); 00068 CMath::radix_sort(vec, len); 00069 } 00070 return true; 00071 } 00072 00074 uint64_t* CSortUlongString::apply_to_string(uint64_t* f, int32_t& len) 00075 { 00076 uint64_t* vec=new uint64_t[len]; 00077 int32_t i=0; 00078 00079 for (i=0; i<len; i++) 00080 vec[i]=f[i]; 00081 00082 //CMath::qsort(vec, len); 00083 CMath::radix_sort(vec, len); 00084 00085 return vec; 00086 } 00087 00089 bool CSortUlongString::load_init_data(FILE* src) 00090 { 00091 return true; 00092 } 00093 00095 bool CSortUlongString::save_init_data(FILE* dst) 00096 { 00097 return true; 00098 }