ECOCPAK v0.9
|
00001 // Copyright (C) 2011 the authors listed below 00002 // http://ecocpak.sourceforge.net 00003 // 00004 // Authors: 00005 // - Dimitrios Bouzas (bouzas at ieee dot org) 00006 // - Nikolaos Arvanitopoulos (niarvani at ieee dot org) 00007 // - Anastasios Tefas (tefas at aiia dot csd dot auth dot gr) 00008 // 00009 // This file is part of the ECOC PAK C++ library. It is 00010 // provided without any warranty of fitness for any purpose. 00011 // 00012 // You can redistribute this file and/or modify it under 00013 // the terms of the GNU Lesser General Public License (LGPL) 00014 // as published by the Free Software Foundation, either 00015 // version 3 of the License or (at your option) any later 00016 // version. 00017 // (see http://www.opensource.org/licenses for more info) 00018 00019 00022 00023 00024 00025 class op_kmeans 00026 { 00027 public: 00028 00029 // main functions 00030 00031 template<typename eT> inline static void direct_kmeans 00032 ( 00033 Col<u32>& indices_out, 00034 Col<u32>& ranks, 00035 Mat<eT>& centroids_out, 00036 const Mat<eT>& in, 00037 const u32 k, 00038 const eT lr 00039 ); 00040 00041 00042 // auxuliary functions 00043 00044 template<typename eT> inline static void compute_distance 00045 ( 00046 Row<eT>& dist_out, 00047 u32& winner, 00048 const Mat<eT>& centroids_in, 00049 const subview_row<eT>& sample_in 00050 ); 00051 00052 template<typename eT> inline static eT compute_distance 00053 ( 00054 const subview_row<eT>& sample_in, 00055 const subview_row<eT>& centroid_in 00056 ); 00057 00058 template<typename eT> inline static void init_centroids 00059 ( 00060 Mat<eT>& centroids_out, 00061 const Mat<eT>& samples_in, 00062 const u32 k 00063 ); 00064 00065 }; 00066 00067 00068