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) 2011 Sergey Lisitsyn 00008 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society 00009 */ 00010 00011 #ifndef MULTIDIMENSIONALSCALING_H_ 00012 #define MULTIDIMENSIONALSCALING_H_ 00013 #include <shogun/lib/config.h> 00014 #ifdef HAVE_LAPACK 00015 #include <shogun/converter/EmbeddingConverter.h> 00016 #include <shogun/features/Features.h> 00017 #include <shogun/distance/Distance.h> 00018 00019 namespace shogun 00020 { 00021 00022 class CFeatures; 00023 class CDistance; 00024 00059 class CMultidimensionalScaling: public CEmbeddingConverter 00060 { 00061 public: 00062 00063 /* constructor */ 00064 CMultidimensionalScaling(); 00065 00066 /* destructor */ 00067 virtual ~CMultidimensionalScaling(); 00068 00073 virtual CSimpleFeatures<float64_t>* embed_distance(CDistance* distance); 00074 00080 virtual CFeatures* apply(CFeatures* features); 00081 00083 const char* get_name() const; 00084 00088 SGVector<float64_t> get_eigenvalues() const; 00089 00095 void set_landmark_number(int32_t num); 00096 00100 int32_t get_landmark_number() const; 00101 00105 void set_landmark(bool landmark); 00106 00110 bool get_landmark() const; 00111 00113 protected: 00114 00116 virtual void init(); 00117 00122 SGMatrix<float64_t> classic_embedding(SGMatrix<float64_t> distance_matrix); 00123 00128 SGMatrix<float64_t> landmark_embedding(SGMatrix<float64_t> distance_matrix); 00129 00134 virtual SGMatrix<float64_t> process_distance_matrix(SGMatrix<float64_t> distance_matrix); 00135 00137 protected: 00138 00140 SGVector<float64_t> m_eigenvalues; 00141 00143 bool m_landmark; 00144 00146 int32_t m_landmark_number; 00147 00149 protected: 00150 00154 static void* run_triangulation_thread(void* p); 00155 00162 static SGVector<int32_t> shuffle(int32_t count, int32_t total_count); 00163 00164 }; 00165 00166 } 00167 #endif /* HAVE_LAPACK */ 00168 #endif /* MULTIDIMENSIONALSCALING_H_ */