Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 1998-2006 George Tzanetakis <gtzan@cs.uvic.ca> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef MARSYAS_NORMCUT_H 00020 #define MARSYAS_NORMCUT_H 00021 00022 #include <marsyas/system/MarSystem.h> 00023 00024 namespace Marsyas 00025 { 00034 //typedef struct { 00035 // mrs_real offset; 00036 // mrs_natural verbose; // not implemented yet 00037 // mrs_natural maxiterations; 00038 // mrs_real eigsErrorTolerance; 00039 //} dataNcutParams, *dataNcutParamsPtr; 00040 00041 class NormCut: public MarSystem 00042 { 00043 00044 private: 00045 realvec nCutDiscrete_; 00046 realvec nCutEigVectors_; 00047 realvec nCutEigValues_; 00048 00049 mrs_natural numClusters_; 00050 00051 mrs_real paramOffset_; 00052 mrs_natural paramVerbose_; // not implemented yet 00053 mrs_natural paramMaxiterations_; 00054 mrs_real paramEigsErrorTolerance_; 00055 00056 MarControlPtr ctrl_numClusters_; 00057 // MarControlPtr ctrl_offset_; 00058 // MarControlPtr ctrl_verbose_; 00059 // MarControlPtr ctrl_maxIters_; 00060 // MarControlPtr ctrl_eigsErrorTol_; 00061 00062 /* 00063 * Function : ncutW (driver function) 00064 * Description : Clusters data items using the normalized cut algorithm given an n x n similarity matrix 00065 * 00066 * Arguments: mrs_natural *n -- size of data set (input) 00067 * realvec &W -- n x n symmetric similarity matrix (input) 00068 * mrs_natural *nbcluster -- desired number of clusters (input) 00069 * dataNcutPtr params -- algorithm parameters (input) 00070 * realvec &NcutDiscrete -- nbcluster x n clustering results (output) 00071 * realvec &NcutEigenvectors -- resulting eigenvectors (output) 00072 * realvec &NcutEigenvalues -- resulting eigenvalues (output) 00073 */ 00074 //void ncutW(mrs_natural *n, realvec &W, mrs_natural *nbcluster, realvec &NcutDiscrete, realvec &NcutEigenvectors, realvec &NcutEigenvalues, dataNcutParamsPtr params=0); 00075 00076 void ncut(mrs_natural n, realvec &W, mrs_natural nbcluster, realvec &NcutEigenvectors, realvec &NcutEigenvalues); 00077 void discretisation(mrs_natural n, mrs_natural nbcluster, realvec &NcutEigenvectors, realvec &NcutDiscrete); 00078 void discretisationEigenvectorData(mrs_natural n, mrs_natural nbcluster, realvec &V, realvec &Vdiscrete); 00079 00080 /* 00081 * Display column-oriented matrices 00082 * Note : Matrices are stored in column-wise order for compatibility with CLAPACK (translated from FORTRAN) 00083 * Note2: n=1 --> display column vector n=2 --> display row vector 00084 */ 00085 void prmrs_natural( realvec &A, mrs_natural m , mrs_natural n ); 00086 void prmrs_natural( mrs_natural *A, mrs_natural m , mrs_natural n ); 00087 00088 void print( realvec &A, int m , int n ); 00089 00090 void addControls(); 00091 void myUpdate(MarControlPtr sender); 00092 00093 public: 00094 NormCut(std::string name); 00095 NormCut(const NormCut& a); 00096 ~NormCut(); 00097 MarSystem* clone() const; 00098 00099 void myProcess(realvec& in, realvec& out); 00100 }; 00101 00102 } 00103 00104 #endif 00105 // MARSYAS_NormCut_H 00106