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) 2012 Heiko Strathmann 00008 */ 00009 00010 #include <shogun/features/streaming/generators/MeanShiftDataGenerator.h> 00011 00012 using namespace shogun; 00013 00014 template<class T> 00015 CMeanShiftDataGenerator<T>::CMeanShiftDataGenerator() : 00016 CStreamingDenseFeatures<T>() 00017 { 00018 init(); 00019 } 00020 00021 template<class T> 00022 CMeanShiftDataGenerator<T>::CMeanShiftDataGenerator(T mean_shift, 00023 index_t dimension): CStreamingDenseFeatures<T>() 00024 { 00025 init(); 00026 set_mean_shift_model(mean_shift, dimension); 00027 } 00028 00029 template<class T> 00030 CMeanShiftDataGenerator<T>::~CMeanShiftDataGenerator() 00031 { 00032 } 00033 00034 template<class T> 00035 void CMeanShiftDataGenerator<T>::set_mean_shift_model(T mean_shift, 00036 index_t dimension) 00037 { 00038 m_dimension=dimension; 00039 m_mean_shift=mean_shift; 00040 } 00041 00042 template<class T> 00043 void CMeanShiftDataGenerator<T>::init() 00044 { 00045 m_dimension=0; 00046 m_mean_shift=0; 00047 } 00048 00049 template<class T> 00050 bool CMeanShiftDataGenerator<T>::get_next_example() 00051 { 00052 SG_SDEBUG("entering CMeanShiftDataGenerator::get_next_example()\n"); 00053 00054 /* allocate space */ 00055 SGVector<T> result=SGVector<T>(m_dimension); 00056 00057 /* fill with std normal data */ 00058 for (index_t i=0; i<m_dimension; ++i) 00059 result[i]=CMath::randn_double(); 00060 00061 /* mean shift in first dimension */ 00062 result[0]+=m_mean_shift; 00063 00064 /* save example back to superclass */ 00065 CMeanShiftDataGenerator<T>::current_vector=result; 00066 00067 SG_SDEBUG("leaving CMeanShiftDataGenerator::get_next_example()\n"); 00068 return true; 00069 } 00070 00071 template<class T> 00072 void CMeanShiftDataGenerator<T>::release_example() 00073 { 00074 SGVector<T> temp=SGVector<T>(); 00075 CMeanShiftDataGenerator<T>::current_vector=temp; 00076 } 00077 00078 template class CMeanShiftDataGenerator<bool>; 00079 template class CMeanShiftDataGenerator<char>; 00080 template class CMeanShiftDataGenerator<int8_t>; 00081 template class CMeanShiftDataGenerator<uint8_t>; 00082 template class CMeanShiftDataGenerator<int16_t>; 00083 template class CMeanShiftDataGenerator<uint16_t>; 00084 template class CMeanShiftDataGenerator<int32_t>; 00085 template class CMeanShiftDataGenerator<uint32_t>; 00086 template class CMeanShiftDataGenerator<int64_t>; 00087 template class CMeanShiftDataGenerator<uint64_t>; 00088 template class CMeanShiftDataGenerator<float32_t>; 00089 template class CMeanShiftDataGenerator<float64_t>; 00090 template class CMeanShiftDataGenerator<floatmax_t>;