annotate hmm/hmm.h @ 484:d48276a3ae24

Add emacs/vi indent directives
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 31 May 2019 12:09:58 +0100
parents fdaa63607c15
children 5998ee1042d3
rev   line source
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@483 16 #ifndef _HMM_H
cannam@483 17 #define _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 #ifndef PI
c@244 24 #define PI 3.14159265358979323846264338327950288
c@244 25 #endif
c@244 26
c@244 27 typedef struct _model_t {
cannam@483 28 int N; /* number of states */
cannam@483 29 double* p0; /* initial probs */
cannam@483 30 double** a; /* transition probs */
cannam@483 31 int L; /* dimensionality of data */
cannam@483 32 double** mu; /* state means */
cannam@483 33 double** cov; /* covariance, tied between all states */
c@244 34 } model_t;
c@244 35
cannam@483 36 void hmm_train(double** x, int T, model_t* model); /* with scaling */
cannam@483 37
cannam@483 38 void forward_backwards(double*** xi, double** gamma,
cannam@483 39 double* loglik, double* loglik1, double* loglik2,
cannam@483 40 int iter, int N, int T,
cannam@483 41 double* p0, double** a, double** b);
cannam@483 42
cannam@483 43 void baum_welch(double* p0, double** a, double** mu, double** cov,
cannam@483 44 int N, int T, int L, double** x, double*** xi, double** gamma);
cannam@483 45
cannam@483 46 void viterbi_decode(double** x, int T, model_t* model, int* q); /* using logs */
cannam@483 47
c@244 48 model_t* hmm_init(double** x, int T, int L, int N);
c@244 49 void hmm_close(model_t* model);
cannam@483 50
cannam@483 51 void invert(double** cov, int L, double** icov, double* detcov); /* uses LAPACK */
cannam@483 52
cannam@483 53 double gauss(double* x, int L, double* mu, double** icov,
cannam@483 54 double detcov, double* y, double* z);
cannam@483 55
cannam@483 56 double loggauss(double* x, int L, double* mu, double** icov,
cannam@483 57 double detcov, double* y, double* z);
cannam@483 58
c@244 59 void hmm_print(model_t* model);
c@244 60
c@245 61 #ifdef __cplusplus
c@245 62 }
c@244 63 #endif
c@244 64
c@245 65 #endif
c@245 66