diff --git a/src/shogun/preprocessor/Isomap.cpp b/src/shogun/preprocessor/Isomap.cpp new file mode 100644 index 00000000000..01145a2df21 --- /dev/null +++ b/src/shogun/preprocessor/Isomap.cpp @@ -0,0 +1,95 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Written (W) 2011 Sergey Lisitsyn + * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society + */ + +#include +#ifdef HAVE_LAPACK +#include +#include +#include +#include +#include + +using namespace shogun; + +CCustomDistance* CIsomap::isomap_distance(CDistance* distance) +{ + int32_t N,k,i,j; + SGMatrix D_matrix=distance->get_distance_matrix(); + N=D_matrix.num_cols; + + if (m_type==EISOMAP) + { + // just replace distances >e with infty + for (i=0; im_epsilon) + D_matrix.matrix[i] = CMath::ALMOST_INFTY; + } + } + if (m_type==KISOMAP) + { + // cut by k-nearest neighbors + + float64_t* col = new float64_t[N]; + int32_t* col_idx = new int32_t[N]; + + // -> INFTY edges connecting NOT neighbors + for (i=0; i= CMath::ALMOST_INFTY) + D_matrix.matrix[i*N+j] = D_matrix.matrix[j*N+i]; + } + + delete[] col; + delete[] col_idx; + } + + // Floyd-Warshall on distance matrix + // TODO replace by dijkstra + for (k=0; k D_matrix=distance->get_distance_matrix(); - N=D_matrix.num_cols; - - if (m_type==EISOMAP) - { - // just replace distances >e with infty - - for (i=0; im_epsilon) - D_matrix.matrix[i] = CMath::ALMOST_INFTY; - } - } - if (m_type==KISOMAP) - { - // cut by k-nearest neighbors - - float64_t* col = new float64_t[N]; - int32_t* col_idx = new int32_t[N]; - - // -> INFTY edges connecting NOT neighbors - for (i=0; i= CMath::ALMOST_INFTY) - D_matrix.matrix[i*N+j] = D_matrix.matrix[j*N+i]; - } - - delete[] col; - delete[] col_idx; - } - - // Floyd-Warshall on distance matrix - // TODO replace by dijkstra - for (k=0; k mds_embed(CDistance* distance) = 0;