// file: hmm.h // // this file defines a class the implements a discrete hmm // // make sure definitions are only made once // #ifndef __ISIP_HMM #define __ISIP_HMM // system include files // #include // isip include files // #include "integral.h" //----------------------------------------------------------------------------- // // Hmm: a class that implements a discrete hmm // // the notation in this code closely parallels the following textbook: // // J.R. Deller, Jr., J.G. Proakis, and J.H.L. Hansen, // Discrete-Time Processing of Speech Signals, // MacMillan, 1993, ISBN: 0-02-328301-7. // // specifically, see Section 12.2.2, starting on page 684. // //----------------------------------------------------------------------------- class Hmm { //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // parameters of a discrete hmm // int_4 S; int_4 K; char_1* y; float_4** a; float_4** b; float_4* pi; // parameters used to update an hmm using the viterbi algorithm // float_4** a_new; float_4** b_new; float_4* pi_new; //--------------------------------------------------------------------------- // // public methods // //--------------------------------------------------------------------------- public: // cstr: constructors/destructors // Hmm(); ~Hmm(); // cmdl: command line processing // logical_1 get_parameters_cc(int argc, char** argv, int_4& S, int_4& K, int_4& P, int_4& L, int_4& mode, int_4& alg, int_4& debug, char_1* file1, char_1* file2); volatile void help_cc(); // io: i/o of data and models // logical_1 load_cc(char_1* file); logical_1 convert_cc(int_4* O, int_4& T, char_1* O_buffer, char_1* line_bufer); logical_1 save_cc(char_1* fname); // disp: display methods // logical_1 display_cc(FILE* fp); logical_1 display_symbol_table_cc(FILE* fp); logical_1 display_sequence_info_cc(int_4 seq_num, float_4 seq_prob, int_4 T, char_1* O_sym, int_4* O, int_4* x, int_4 debug, FILE* fp); // init: initialization // logical_1 init_cc(int_4 S, int_4 K); logical_1 init_counters_cc(); logical_1 seed_cc(); // test: test-related methods // float_4 test_cc(int_4* x, int_4* O, int_4 T, int_4 alg, int_4 debug); float_4 test_viterbi_cc(int_4* x, int_4* O, int_4 T, int_4 debug); float_4 test_baumwelch_cc(int_4* x, int_4* O, int_4 T, int_4 debug); // train: train-related methods // logical_1 train_symbol_table_cc(FILE* fp); float_4 train_cc(int_4* x, int_4* O, int_4 T, int_4 alg, int_4 debug); logical_1 replace_cc(int_4 alg); logical_1 train_viterbi_cc(int_4* x, int_4* O, int_4 T, int_4 debug); logical_1 replace_viterbi_cc(); float_4 train_baumwelch_cc(int_4* x, int_4* O, int_4 T, int_4 debug); logical_1 replace_baumwelch_cc(); // generate: generate data from a model // float_4 generate_cc(int_4& T, char_1* O_sym, int_4* O, int_4* x); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // oper: simple operators // float_4 log10_cc(float_4 value); float_4 inv_log10_cc(float_4 value); float_4 invert_cc(float_4 value); int_4 match_cc(char_1 val); // mem: memory allocation // logical_1 cleanup_cc(); logical_1 allocate_cc(int_4 S, int_4 K); logical_1 cleanup_counters_cc(); logical_1 allocate_counters_cc(); // generate: random number generation // int_4 generate_node_cc(float_4* v, int_4 nv); // // end of class }; // // end of include file #endif