-
Notifications
You must be signed in to change notification settings - Fork 4
/
data.h
83 lines (66 loc) · 2.71 KB
/
data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
liblrhsmm
===
Copyright (c) 2016-2017 Kanru Hua. All rights reserved.
This file is part of liblrhsmm.
liblrhsmm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
liblrhsmm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with liblrhsmm. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LRHSMM_DATA_H
#define LRHSMM_DATA_H
typedef struct {
FP_TYPE** data; // stream-wise array of matrices (time * dimension)
int nstream, nt;
int* ndim; // dimension of each stream
} lrh_observ;
// access the content of a lrh_observ at time t, l-th stream, i-th dimension
#define lrh_obm(obj, t, i, l) (((obj) -> data[l])[(t) * ((obj) -> ndim[l]) + i])
typedef struct {
int* time; // right boundary of each segment
int** outstate; // stream-wise array of vectors of indices of output pdfs in lrh_stream
int* durstate; // vector of indices of duration pdfs in lrh_model
int nstream;
int nseg;
int** djump_out; // jump delta (out-bound), terminates in 1
FP_TYPE** pjump_out; // jump probability (out-bound), terminates in next-trans prob.
int** djump_in; // jump delta (in-bound), terminates in -1
FP_TYPE** pjump_in; // jump probability (in-bound), terminates in prev-trans prob.
} lrh_seg;
// container for unsegmented data
typedef struct {
lrh_observ** samples;
int nsample;
} lrh_observset;
// container for segmentations
typedef struct {
lrh_seg** samples;
int nsample;
} lrh_segset;
typedef struct {
lrh_observset* observset;
lrh_segset* segset;
} lrh_dataset;
lrh_observ* lrh_create_observ(int nstream, int nt, int* ndim);
lrh_seg* lrh_create_seg(int nstream, int nseg);
lrh_seg* lrh_seg_copy(lrh_seg* src);
lrh_segset* lrh_segset_copy(lrh_segset* src);
void lrh_delete_observ(lrh_observ* dst);
void lrh_delete_seg(lrh_seg* dst);
void lrh_seg_buildjumps(lrh_seg* dst);
lrh_observset* lrh_create_empty_observset(int nsample);
lrh_segset* lrh_create_empty_segset(int nsample);
void lrh_delete_observset(lrh_observset* dst);
void lrh_delete_segset(lrh_segset* dst);
// regroup observation and segmentation into smaller units
lrh_dataset* lrh_regroup_data(lrh_observset* srcobset, lrh_segset* srcsgset, int unitsize);
// shuffle the segments based on the sequence returned from lrh_viterbi
lrh_seg* lrh_seg_shuffle(lrh_seg* src, int* shufidx);
#endif