| 1 | /* HMM_def.h |
| 2 | * |
| 3 | * Copyright (C) 2010-2018 David Weenink |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | |
| 20 | #define ooSTRUCT HMMState |
| 21 | oo_DEFINE_CLASS (HMMState, Daata) |
| 22 | |
| 23 | oo_STRING (label) |
| 24 | |
| 25 | oo_END_CLASS (HMMState) |
| 26 | #undef ooSTRUCT |
| 27 | |
| 28 | |
| 29 | #define ooSTRUCT HMMObservation |
| 30 | oo_DEFINE_CLASS (HMMObservation, Daata) |
| 31 | |
| 32 | oo_STRING (label) |
| 33 | oo_OBJECT (GaussianMixture, 0, gm) |
| 34 | |
| 35 | oo_END_CLASS (HMMObservation) |
| 36 | #undef ooSTRUCT |
| 37 | |
| 38 | |
| 39 | #define ooSTRUCT HMM |
| 40 | oo_DEFINE_CLASS (HMM, Daata) |
| 41 | |
| 42 | oo_INT (notHidden) // to model a Markov model instead of HMM |
| 43 | oo_INT (leftToRight) |
| 44 | oo_INTEGER (numberOfStates) |
| 45 | oo_INTEGER (numberOfObservationSymbols) |
| 46 | oo_INTEGER (numberOfMixtureComponents) |
| 47 | oo_INTEGER (componentDimension) |
| 48 | oo_ENUM (kHMMstorage, componentStorage) |
| 49 | oo_FROM (1) |
| 50 | oo_VEC (initialStateProbs, numberOfStates) |
| 51 | oo_ENDFROM |
| 52 | #if oo_READING |
| 53 | oo_VERSION_UNTIL (1) |
| 54 | oo_MAT (transitionProbs, numberOfStates + 1, numberOfStates + 1) |
| 55 | our initialStateProbs = copy_VEC (our transitionProbs.row (1).part (1, our numberOfStates)); |
| 56 | our transitionProbs = copy_MAT (our transitionProbs.horizontalBand (2, our numberOfStates + 1)); |
| 57 | oo_VERSION_ELSE |
| 58 | oo_MAT (transitionProbs, numberOfStates, numberOfStates + 1) |
| 59 | oo_VERSION_END |
| 60 | #else |
| 61 | oo_MAT (transitionProbs, numberOfStates, numberOfStates + 1) |
| 62 | #endif |
| 63 | oo_MAT (emissionProbs, numberOfStates, numberOfObservationSymbols) |
| 64 | oo_OBJECT (HMMStateList, 0, states) |
| 65 | oo_OBJECT (HMMObservationList, 0, observationSymbols) |
| 66 | |
| 67 | #if oo_DECLARING |
| 68 | void v1_info () |
| 69 | override; |
| 70 | #endif |
| 71 | |
| 72 | oo_END_CLASS (HMM) |
| 73 | #undef ooSTRUCT |
| 74 | |
| 75 | |
| 76 | #define ooSTRUCT HMMViterbi |
| 77 | oo_DEFINE_CLASS (HMMViterbi, Daata) |
| 78 | |
| 79 | oo_INTEGER (numberOfTimes) |
| 80 | oo_INTEGER (numberOfStates) |
| 81 | oo_DOUBLE (prob) |
| 82 | oo_MAT (viterbi, numberOfStates, numberOfTimes) |
| 83 | oo_INTMAT (bp, numberOfStates, numberOfTimes) |
| 84 | oo_INTVEC (path, numberOfTimes) |
| 85 | |
| 86 | oo_END_CLASS (HMMViterbi) |
| 87 | #undef ooSTRUCT |
| 88 | |
| 89 | |
| 90 | /* End of file HMM_def.h */ |