cannam@484: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@244: /* c@244: * hmm.h c@244: * c@244: * Created by Mark Levy on 12/02/2006. c@309: * Copyright 2006 Centre for Digital Music, Queen Mary, University of London. c@309: c@309: This program is free software; you can redistribute it and/or c@309: modify it under the terms of the GNU General Public License as c@309: published by the Free Software Foundation; either version 2 of the c@309: License, or (at your option) any later version. See the file c@309: COPYING included with this distribution for more information. c@244: * c@244: */ c@244: cannam@483: #ifndef _HMM_H cannam@483: #define _HMM_H cannam@483: cannam@483: #ifdef __cplusplus cannam@483: extern "C" { cannam@483: #endif cannam@483: c@244: #ifndef PI c@244: #define PI 3.14159265358979323846264338327950288 c@244: #endif c@244: c@244: typedef struct _model_t { cannam@483: int N; /* number of states */ cannam@483: double* p0; /* initial probs */ cannam@483: double** a; /* transition probs */ cannam@483: int L; /* dimensionality of data */ cannam@483: double** mu; /* state means */ cannam@483: double** cov; /* covariance, tied between all states */ c@244: } model_t; c@244: cannam@483: void hmm_train(double** x, int T, model_t* model); /* with scaling */ cannam@483: cannam@483: void forward_backwards(double*** xi, double** gamma, cannam@483: double* loglik, double* loglik1, double* loglik2, cannam@483: int iter, int N, int T, cannam@483: double* p0, double** a, double** b); cannam@483: cannam@483: void baum_welch(double* p0, double** a, double** mu, double** cov, cannam@483: int N, int T, int L, double** x, double*** xi, double** gamma); cannam@483: cannam@483: void viterbi_decode(double** x, int T, model_t* model, int* q); /* using logs */ cannam@483: c@244: model_t* hmm_init(double** x, int T, int L, int N); c@244: void hmm_close(model_t* model); cannam@483: cannam@483: void invert(double** cov, int L, double** icov, double* detcov); /* uses LAPACK */ cannam@483: cannam@483: double gauss(double* x, int L, double* mu, double** icov, cannam@483: double detcov, double* y, double* z); cannam@483: cannam@483: double loggauss(double* x, int L, double* mu, double** icov, cannam@483: double detcov, double* y, double* z); cannam@483: c@244: void hmm_print(model_t* model); c@244: c@245: #ifdef __cplusplus c@245: } c@244: #endif c@244: c@245: #endif c@245: