diff --git a/fastlib/u/nvasil/kernel_pca/kernel_pca.h b/fastlib/u/nvasil/kernel_pca/kernel_pca.h new file mode 100644 index 0000000000..afc7dc584e --- /dev/null +++ b/fastlib/u/nvasil/kernel_pca/kernel_pca.h @@ -0,0 +1,67 @@ +/* + * ===================================================================================== + * + * Filename: kernel_pca.h + * + * Description: + * + * Version: 1.0 + * Created: 11/30/2007 08:34:19 PM EST + * Revision: none + * Compiler: gcc + * + * Author: Nikolaos Vasiloglou (NV), nvasil@ieee.org + * Company: Georgia Tech Fastlab-ESP Lab + * + * ===================================================================================== + */ + +#ifndef KERNEL_PCA_H_ +#define KERNEL_PCA_H_ +#ifndef HAVING_CONFIG_H +#define HAVE_CONFIG_H +#endif +#include +#include "fastlib/fastlib.h" +#include "fastlib/la/matrix.h" +#include "u/nvasil/binary_dataset.h" +#include "Epetra_SerialDenseMatrix.h" +#include "Epetra_SerialComm.h" +#include "Epetra_Version.h" + +template +class KernelPCA { + typedef typename TREE::Precision_t Precision_t; + typedef TREE Tree_t; + typdef enum OutputMode_t {Matrix_E=0, TexFile_E, BinaryFile_E}; + public: + void Init(); + void Destruct(); + void ComputeAffinity(index_t knn); + template + void ComputeGeneralKernelPCA(DISTANCEKERNEL kernel, index_t num_of_eigenvalues); + void ComputeIsomap(index_t num_of_eigenvalues); + void ComputeLLE(index_t num_of_eigenvalues); + template + void ComputeDiffusionMaps(KERNEL kernel, index_t num_of_eigenvalues); + void ComputeLaplacialnEigenmaps(index_t); + void ComputeSpectralRegression(std::string label_file); + Vector get_eigenvalues(); + Matrix get_eigenvectors(); + void SaveToTextFile(std::string file); + void SaveToBinaryFile(std::string file); + void set_output_mode(OutputMode_t mode) { + output_mode_ = mode; + } + + private: + Tree_t tree_; + Epetra_SerialComm comm_; + Epetra_CrsMatrix kernel_matrix_; + BinaryDataset data_; + OutputMode_t output_mode_; + +} ; + +#include "u/nvasil/kernel_pca/kernel_pca_impl.h" +#endif diff --git a/fastlib/u/nvasil/kernel_pca/kernel_pca_impl.h b/fastlib/u/nvasil/kernel_pca/kernel_pca_impl.h new file mode 100644 index 0000000000..568922f52d --- /dev/null +++ b/fastlib/u/nvasil/kernel_pca/kernel_pca_impl.h @@ -0,0 +1,58 @@ +/* + * ===================================================================================== + * + * Filename: kernel_pca_impl.h + * + * Description: + * + * Version: 1.0 + * Created: 11/30/2007 09:03:12 PM EST + * Revision: none + * Compiler: gcc + * + * Author: Nikolaos Vasiloglou (NV), nvasil@ieee.org + * Company: Georgia Tech Fastlab-ESP Lab + * + * ===================================================================================== + */ + +#define TEMPLATE__ \ +template +#define KERNELPCA__ KernelPCA + +TEMPLATE__ +void KERNELPCA::Init(std::string data_file, + std::string index_file) { + if (index_file.empty()) { + data_.Init(data_file); + } else { + data_.Init(data_file, index_file); + } + tree_.Init(&data_); +} + +TEMPLATE__ +void KERNELPCA::Destruct() { + tree_.Destruct(); + data_.Destruct(); +} + +TEMPLATE__ +void KERNELPCA::ComputeAffinity(index_t knns) { + fx_timer_start(fx_root, "build_tree") + test_tree.BuildDepthFirst(); + fx_timer_start(fx_root, "duall_tree"); + train_tree.AllNearestNeighbors(tree_.get_parent(), knns); + fx_timer_stop(fx_root, "duall_tree"); +} + +TEMPLATE__ +template +void KERNELPCA::ComputeGeneralKernelPCA(DISTANCEKERNEL kernel, + index_t num_of_eigenvalues){ + + +} + + +