cannam@484
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
c@244
|
2 /*
|
c@244
|
3 * hmm.h
|
c@244
|
4 *
|
c@244
|
5 * Created by Mark Levy on 12/02/2006.
|
c@309
|
6 * Copyright 2006 Centre for Digital Music, Queen Mary, University of London.
|
c@309
|
7
|
c@309
|
8 This program is free software; you can redistribute it and/or
|
c@309
|
9 modify it under the terms of the GNU General Public License as
|
c@309
|
10 published by the Free Software Foundation; either version 2 of the
|
c@309
|
11 License, or (at your option) any later version. See the file
|
c@309
|
12 COPYING included with this distribution for more information.
|
c@244
|
13 *
|
c@244
|
14 */
|
c@244
|
15
|
cannam@489
|
16 #ifndef QM_DSP_HMM_H
|
cannam@489
|
17 #define QM_DSP_HMM_H
|
cannam@483
|
18
|
cannam@483
|
19 #ifdef __cplusplus
|
cannam@483
|
20 extern "C" {
|
cannam@483
|
21 #endif
|
cannam@483
|
22
|
c@244
|
23 typedef struct _model_t {
|
cannam@483
|
24 int N; /* number of states */
|
cannam@483
|
25 double* p0; /* initial probs */
|
cannam@483
|
26 double** a; /* transition probs */
|
cannam@483
|
27 int L; /* dimensionality of data */
|
cannam@483
|
28 double** mu; /* state means */
|
cannam@483
|
29 double** cov; /* covariance, tied between all states */
|
c@244
|
30 } model_t;
|
c@244
|
31
|
cannam@483
|
32 void hmm_train(double** x, int T, model_t* model); /* with scaling */
|
cannam@483
|
33
|
cannam@483
|
34 void forward_backwards(double*** xi, double** gamma,
|
cannam@483
|
35 double* loglik, double* loglik1, double* loglik2,
|
cannam@483
|
36 int iter, int N, int T,
|
cannam@483
|
37 double* p0, double** a, double** b);
|
cannam@483
|
38
|
cannam@483
|
39 void baum_welch(double* p0, double** a, double** mu, double** cov,
|
cannam@483
|
40 int N, int T, int L, double** x, double*** xi, double** gamma);
|
cannam@483
|
41
|
cannam@483
|
42 void viterbi_decode(double** x, int T, model_t* model, int* q); /* using logs */
|
cannam@483
|
43
|
c@244
|
44 model_t* hmm_init(double** x, int T, int L, int N);
|
c@244
|
45 void hmm_close(model_t* model);
|
cannam@483
|
46
|
cannam@483
|
47 void invert(double** cov, int L, double** icov, double* detcov); /* uses LAPACK */
|
cannam@483
|
48
|
cannam@483
|
49 double gauss(double* x, int L, double* mu, double** icov,
|
cannam@483
|
50 double detcov, double* y, double* z);
|
cannam@483
|
51
|
cannam@483
|
52 double loggauss(double* x, int L, double* mu, double** icov,
|
cannam@483
|
53 double detcov, double* y, double* z);
|
cannam@483
|
54
|
c@244
|
55 void hmm_print(model_t* model);
|
c@244
|
56
|
c@245
|
57 #ifdef __cplusplus
|
c@245
|
58 }
|
c@244
|
59 #endif
|
c@244
|
60
|
c@245
|
61 #endif
|
c@245
|
62
|