support.h

00001 /* MLPACK 0.2
00002  *
00003  * Copyright (c) 2008, 2009 Alexander Gray,
00004  *                          Garry Boyer,
00005  *                          Ryan Riegel,
00006  *                          Nikolaos Vasiloglou,
00007  *                          Dongryeol Lee,
00008  *                          Chip Mappus, 
00009  *                          Nishant Mehta,
00010  *                          Hua Ouyang,
00011  *                          Parikshit Ram,
00012  *                          Long Tran,
00013  *                          Wee Chin Wong
00014  *
00015  * Copyright (c) 2008, 2009 Georgia Institute of Technology
00016  *
00017  * This program is free software; you can redistribute it and/or
00018  * modify it under the terms of the GNU General Public License as
00019  * published by the Free Software Foundation; either version 2 of the
00020  * License, or (at your option) any later version.
00021  *
00022  * This program is distributed in the hope that it will be useful, but
00023  * WITHOUT ANY WARRANTY; without even the implied warranty of
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025  * General Public License for more details.
00026  *
00027  * You should have received a copy of the GNU General Public License
00028  * along with this program; if not, write to the Free Software
00029  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00030  * 02110-1301, USA.
00031  */
00032 #ifndef FASTLIB_HMM_SUPPORT_H
00033 #define FASTLIB_HMM_SUPPORT_H
00034 
00035 #include "fastlib/fastlib.h"
00036 
00037 namespace hmm_support {
00039   double RAND_UNIFORM_01();
00040 
00042   double RAND_UNIFORM(double a, double b);
00043 
00045   double RAND_NORMAL_01();
00046 
00048   void RAND_NORMAL_01_INIT(int N, Vector* v);
00049 
00051   void RAND_NORMAL_INIT(const Vector& mean, const Matrix& cov, Vector* v);
00052 
00054   double MyMulExpert(const Vector& x, const Matrix& A, const Vector& y);
00055 
00057   double NORMAL_DENSITY(const Vector& x, const Vector& mean, const Matrix& inv_cov, double det_cov);
00058 
00060   void print_matrix(const Matrix& a, const char* msg);
00061 
00063   void print_matrix(TextWriter& writer, const Matrix& a, const char* msg, const char* format = "%f,");
00064   
00066   void print_vector(const Vector& a, const char* msg);
00067 
00069   void print_vector(TextWriter& writer, const Vector& a, const char* msg, const char* format = "%f,");
00070 
00072   bool kmeans(const ArrayList<Matrix>& data, int num_clusters, 
00073               ArrayList<int> *labels_, ArrayList<Vector> *centroids_, 
00074               int max_iter = 1000, double error_thresh = 1e-3);
00075 
00076   bool kmeans(Matrix const &data, int num_clusters, 
00077               ArrayList<int> *labels_, ArrayList<Vector> *centroids_, 
00078               int max_iter=1000, double error_thresh=1e-04);
00079 
00081   void mat2arrlst(Matrix& a, ArrayList<Vector> * seqs);
00082   
00084   void mat2arrlstmat(int N, Matrix& a, ArrayList<Matrix> * seqs);
00085 
00090   success_t load_matrix_list(const char* filename, ArrayList<Matrix> *matlst);
00091 
00096   success_t load_vector_list(const char* filename, ArrayList<Vector> *veclst);
00097 };
00098 
00099 #endif
00100 
Generated on Mon Jan 24 12:04:38 2011 for FASTlib by  doxygen 1.6.3