support.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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