| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
#line 453 "lib/PDL/PP.pm" |
|
3
|
|
|
|
|
|
|
/* |
|
4
|
|
|
|
|
|
|
* THIS FILE WAS GENERATED BY PDL::PP from HMM.pd! Do not modify! |
|
5
|
|
|
|
|
|
|
*/ |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \ |
|
8
|
|
|
|
|
|
|
if (destroy) { \ |
|
9
|
|
|
|
|
|
|
comp_free_code \ |
|
10
|
|
|
|
|
|
|
} \ |
|
11
|
|
|
|
|
|
|
if ((trans)->dims_redone) { \ |
|
12
|
|
|
|
|
|
|
ntpriv_free_code \ |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
16
|
|
|
|
|
|
|
#include "perl.h" |
|
17
|
|
|
|
|
|
|
#include "XSUB.h" |
|
18
|
|
|
|
|
|
|
#include "pdl.h" |
|
19
|
|
|
|
|
|
|
#include "pdlcore.h" |
|
20
|
|
|
|
|
|
|
#define PDL PDL_HMM |
|
21
|
|
|
|
|
|
|
extern Core* PDL; /* Structure hold core C functions */ |
|
22
|
|
|
|
|
|
|
#line 23 "HMM.xs" |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#include |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
/*#define DEBUG_ALPHA*/ |
|
27
|
|
|
|
|
|
|
/*#define DEBUG_BETA*/ |
|
28
|
|
|
|
|
|
|
/*#define DEBUG_VITERBI*/ |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
/* logadd(x,y) = log(exp(x)+exp(y)) |
|
32
|
|
|
|
|
|
|
* + Code from Manning & Schütze (1997), Sec. 9.4, page 337 |
|
33
|
|
|
|
|
|
|
* |
|
34
|
|
|
|
|
|
|
* LOG_BIG = log(1E31) |
|
35
|
|
|
|
|
|
|
*/ |
|
36
|
|
|
|
|
|
|
#define LOG_BIG 71.3801378828154 |
|
37
|
|
|
|
|
|
|
#define LOG_ZERO -1E+38 |
|
38
|
|
|
|
|
|
|
#define LOG_ONE 0 |
|
39
|
|
|
|
|
|
|
#define LOG_NONE 1 |
|
40
|
|
|
|
|
|
|
static inline double logadd1(double x, double y) { |
|
41
|
|
|
|
|
|
|
if (y-x > LOG_BIG) return y; |
|
42
|
|
|
|
|
|
|
else if (x-y > LOG_BIG) return x; |
|
43
|
|
|
|
|
|
|
/*else return min(x,y) + log(exp(x-min(x,y)) + exp(y-min(x,y))); */ |
|
44
|
|
|
|
|
|
|
else if (x
|
|
45
|
|
|
|
|
|
|
else return y + log(exp(x-y) + 1); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
static inline double logadd0(double x, double y) { |
|
48
|
|
|
|
|
|
|
return log(exp(x)+exp(y)); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
/* logdiff(x,y) = log(exp(x)-exp(y)) |
|
52
|
|
|
|
|
|
|
* + adapted from above |
|
53
|
|
|
|
|
|
|
* + always returns positive (i.e. symmetric difference) |
|
54
|
|
|
|
|
|
|
*/ |
|
55
|
|
|
|
|
|
|
static inline double logdiff1(double x, double y) { |
|
56
|
|
|
|
|
|
|
if (y-x > LOG_BIG) { return y; } |
|
57
|
|
|
|
|
|
|
else if (x-y > LOG_BIG) { return x; } |
|
58
|
|
|
|
|
|
|
/*else { return max(x,y) + log(exp(max(x,y)-max(x,y)) - exp(min(x,y)-max(x,y))); } */ |
|
59
|
|
|
|
|
|
|
/* = max(x,y) + log( 1 - exp(min(x,y)-max(x,y))); } */ |
|
60
|
|
|
|
|
|
|
else if (x>y) { return x + log( 1 - exp(y-x)); } |
|
61
|
|
|
|
|
|
|
else { return y + log( 1 - exp(x-y)); } |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
static inline double logdiff0(double x, double y) { |
|
64
|
|
|
|
|
|
|
return log(x>y ? (exp(x)-exp(y)) : (exp(y)-exp(x))); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
/* |
|
68
|
|
|
|
|
|
|
#define logadd(x,y) logadd0(x,y) |
|
69
|
|
|
|
|
|
|
#define logdiff(x,y) logdiff0(x,y) |
|
70
|
|
|
|
|
|
|
*/ |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#define logadd(x,y) logadd1(x,y) |
|
73
|
|
|
|
|
|
|
#define logdiff(x,y) logdiff1(x,y) |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
pdl_error pdl_run_logzero(pdl *a); |
|
76
|
|
|
|
|
|
|
pdl_error pdl_run_logadd(pdl *a,pdl *b,pdl *c); |
|
77
|
|
|
|
|
|
|
pdl_error pdl_run_logdiff(pdl *a,pdl *b,pdl *c); |
|
78
|
|
|
|
|
|
|
pdl_error pdl_run_logsumover(pdl *a,pdl *b); |
|
79
|
|
|
|
|
|
|
pdl_error pdl_run_hmmfw(pdl *a,pdl *b,pdl *pi,pdl *o,pdl *alpha); |
|
80
|
|
|
|
|
|
|
pdl_error pdl_run_hmmfwq(pdl *a,pdl *b,pdl *pi,pdl *o,pdl *oq,pdl *alphaq); |
|
81
|
|
|
|
|
|
|
pdl_error pdl_run_hmmbw(pdl *a,pdl *b,pdl *omega,pdl *o,pdl *beta); |
|
82
|
|
|
|
|
|
|
pdl_error pdl_run_hmmbwq(pdl *a,pdl *b,pdl *omega,pdl *o,pdl *oq,pdl *betaq); |
|
83
|
|
|
|
|
|
|
pdl_error pdl_run_hmmexpect(pdl *a,pdl *b,pdl *pi,pdl *omega,pdl *o,pdl *alpha,pdl *beta,pdl *ea,pdl *eb,pdl *epi,pdl *eomega); |
|
84
|
|
|
|
|
|
|
pdl_error pdl_run_hmmexpectq(pdl *a,pdl *b,pdl *pi,pdl *omega,pdl *o,pdl *oq,pdl *alphaq,pdl *betaq,pdl *ea,pdl *eb,pdl *epi,pdl *eomega); |
|
85
|
|
|
|
|
|
|
pdl_error pdl_run_hmmviterbi(pdl *a,pdl *b,pdl *pi,pdl *o,pdl *delta,pdl *psi); |
|
86
|
|
|
|
|
|
|
pdl_error pdl_run_hmmviterbiq(pdl *a,pdl *b,pdl *pi,pdl *o,pdl *oq,pdl *deltaq,pdl *psiq); |
|
87
|
|
|
|
|
|
|
pdl_error pdl_run_hmmpath(pdl *psi,pdl *qfinal,pdl *path); |
|
88
|
|
|
|
|
|
|
pdl_error pdl_run_hmmpathq(pdl *oq,pdl *psiq,pdl *qfinalq,pdl *path); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#line 449 "lib/PDL/PP.pm" |
|
91
|
|
|
|
|
|
|
#include "pdlperl.h" |
|
92
|
|
|
|
|
|
|
#line 93 "HMM.xs" |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Core* PDL = NULL; /* Structure hold core C functions */ |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
MODULE = PDL::HMM PACKAGE = PDL PREFIX=pdl_run_ |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
void |
|
102
|
|
|
|
|
|
|
pdl_run_logzero(a=PDL_XS_PERLINIT_initsv(a_SV)) |
|
103
|
|
|
|
|
|
|
SV *a_SV = items > 0 ? ST(0) : NULL; |
|
104
|
|
|
|
|
|
|
PREINIT: |
|
105
|
11
|
50
|
|
|
|
|
PDL_XS_PREAMBLE((items == 1) ? 0 : 1); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
INPUT: |
|
107
|
|
|
|
|
|
|
pdl *a |
|
108
|
|
|
|
|
|
|
PPCODE: |
|
109
|
11
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_logzero(a)); |
|
110
|
11
|
50
|
|
|
|
|
PDL_XS_RETURN(ST(0) = a_SV) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
void |
|
113
|
|
|
|
|
|
|
pdl_run_logadd(a, b, c=c) |
|
114
|
|
|
|
|
|
|
SV *c_SV = items > 2 ? ST(2) : NULL; |
|
115
|
|
|
|
|
|
|
PREINIT: |
|
116
|
15
|
50
|
|
|
|
|
PDL_XS_PREAMBLE((items == 3) ? 0 : 1); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
INPUT: |
|
118
|
|
|
|
|
|
|
pdl *a |
|
119
|
|
|
|
|
|
|
pdl *b |
|
120
|
|
|
|
|
|
|
pdl *c=NO_INIT |
|
121
|
|
|
|
|
|
|
PPCODE: |
|
122
|
15
|
100
|
|
|
|
|
PDL_XS_INPLACE(a, c) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
123
|
15
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_logadd(a,b,c)); |
|
124
|
15
|
50
|
|
|
|
|
PDL_XS_RETURN(ST(0) = c_SV) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
void |
|
127
|
|
|
|
|
|
|
pdl_run_logdiff(a, b, c=c) |
|
128
|
|
|
|
|
|
|
SV *c_SV = items > 2 ? ST(2) : NULL; |
|
129
|
|
|
|
|
|
|
PREINIT: |
|
130
|
7
|
50
|
|
|
|
|
PDL_XS_PREAMBLE((items == 3) ? 0 : 1); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
INPUT: |
|
132
|
|
|
|
|
|
|
pdl *a |
|
133
|
|
|
|
|
|
|
pdl *b |
|
134
|
|
|
|
|
|
|
pdl *c=NO_INIT |
|
135
|
|
|
|
|
|
|
PPCODE: |
|
136
|
7
|
50
|
|
|
|
|
PDL_XS_INPLACE(a, c) |
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
137
|
7
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_logdiff(a,b,c)); |
|
138
|
7
|
50
|
|
|
|
|
PDL_XS_RETURN(ST(0) = c_SV) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
void |
|
141
|
|
|
|
|
|
|
pdl_run_logsumover(a, b=PDL_XS_PERLINIT_initsv(b_SV)) |
|
142
|
|
|
|
|
|
|
SV *b_SV = items > 1 ? ST(1) : NULL; |
|
143
|
|
|
|
|
|
|
PREINIT: |
|
144
|
19
|
50
|
|
|
|
|
PDL_XS_PREAMBLE((items == 2) ? 0 : 1); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
INPUT: |
|
146
|
|
|
|
|
|
|
pdl *a |
|
147
|
|
|
|
|
|
|
pdl *b |
|
148
|
|
|
|
|
|
|
PPCODE: |
|
149
|
19
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_logsumover(a,b)); |
|
150
|
19
|
50
|
|
|
|
|
PDL_XS_RETURN(ST(0) = b_SV) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
void |
|
153
|
|
|
|
|
|
|
pdl_run_hmmfw(a, b, pi, o, alpha=PDL_XS_PERLINIT_initsv(alpha_SV)) |
|
154
|
|
|
|
|
|
|
SV *alpha_SV = items > 4 ? ST(4) : NULL; |
|
155
|
|
|
|
|
|
|
PREINIT: |
|
156
|
13
|
50
|
|
|
|
|
PDL_XS_PREAMBLE((items == 5) ? 0 : 1); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
INPUT: |
|
158
|
|
|
|
|
|
|
pdl *a |
|
159
|
|
|
|
|
|
|
pdl *b |
|
160
|
|
|
|
|
|
|
pdl *pi |
|
161
|
|
|
|
|
|
|
pdl *o |
|
162
|
|
|
|
|
|
|
pdl *alpha |
|
163
|
|
|
|
|
|
|
PPCODE: |
|
164
|
13
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmfw(a,b,pi,o,alpha)); |
|
165
|
13
|
50
|
|
|
|
|
PDL_XS_RETURN(ST(0) = alpha_SV) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
void |
|
168
|
|
|
|
|
|
|
pdl_run_hmmfwq(a, b, pi, o, oq, alphaq=PDL_XS_PERLINIT_initsv(alphaq_SV)) |
|
169
|
|
|
|
|
|
|
SV *alphaq_SV = items > 5 ? ST(5) : NULL; |
|
170
|
|
|
|
|
|
|
PREINIT: |
|
171
|
0
|
0
|
|
|
|
|
PDL_XS_PREAMBLE((items == 6) ? 0 : 1); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
INPUT: |
|
173
|
|
|
|
|
|
|
pdl *a |
|
174
|
|
|
|
|
|
|
pdl *b |
|
175
|
|
|
|
|
|
|
pdl *pi |
|
176
|
|
|
|
|
|
|
pdl *o |
|
177
|
|
|
|
|
|
|
pdl *oq |
|
178
|
|
|
|
|
|
|
pdl *alphaq |
|
179
|
|
|
|
|
|
|
PPCODE: |
|
180
|
0
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmfwq(a,b,pi,o,oq,alphaq)); |
|
181
|
0
|
0
|
|
|
|
|
PDL_XS_RETURN(ST(0) = alphaq_SV) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
void |
|
184
|
|
|
|
|
|
|
pdl_run_hmmbw(a, b, omega, o, beta=PDL_XS_PERLINIT_initsv(beta_SV)) |
|
185
|
|
|
|
|
|
|
SV *beta_SV = items > 4 ? ST(4) : NULL; |
|
186
|
|
|
|
|
|
|
PREINIT: |
|
187
|
7
|
50
|
|
|
|
|
PDL_XS_PREAMBLE((items == 5) ? 0 : 1); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
INPUT: |
|
189
|
|
|
|
|
|
|
pdl *a |
|
190
|
|
|
|
|
|
|
pdl *b |
|
191
|
|
|
|
|
|
|
pdl *omega |
|
192
|
|
|
|
|
|
|
pdl *o |
|
193
|
|
|
|
|
|
|
pdl *beta |
|
194
|
|
|
|
|
|
|
PPCODE: |
|
195
|
7
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmbw(a,b,omega,o,beta)); |
|
196
|
7
|
50
|
|
|
|
|
PDL_XS_RETURN(ST(0) = beta_SV) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
void |
|
199
|
|
|
|
|
|
|
pdl_run_hmmbwq(a, b, omega, o, oq, betaq=PDL_XS_PERLINIT_initsv(betaq_SV)) |
|
200
|
|
|
|
|
|
|
SV *betaq_SV = items > 5 ? ST(5) : NULL; |
|
201
|
|
|
|
|
|
|
PREINIT: |
|
202
|
0
|
0
|
|
|
|
|
PDL_XS_PREAMBLE((items == 6) ? 0 : 1); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
INPUT: |
|
204
|
|
|
|
|
|
|
pdl *a |
|
205
|
|
|
|
|
|
|
pdl *b |
|
206
|
|
|
|
|
|
|
pdl *omega |
|
207
|
|
|
|
|
|
|
pdl *o |
|
208
|
|
|
|
|
|
|
pdl *oq |
|
209
|
|
|
|
|
|
|
pdl *betaq |
|
210
|
|
|
|
|
|
|
PPCODE: |
|
211
|
0
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmbwq(a,b,omega,o,oq,betaq)); |
|
212
|
0
|
0
|
|
|
|
|
PDL_XS_RETURN(ST(0) = betaq_SV) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
void |
|
215
|
|
|
|
|
|
|
pdl_run_hmmexpect(a, b, pi, omega, o, alpha, beta, ea=PDL_XS_PERLINIT_initsv(ea_SV), eb=PDL_XS_PERLINIT_initsv(eb_SV), epi=PDL_XS_PERLINIT_initsv(epi_SV), eomega=PDL_XS_PERLINIT_initsv(eomega_SV)) |
|
216
|
|
|
|
|
|
|
SV *ea_SV = items > 7 ? ST(7) : NULL; |
|
217
|
|
|
|
|
|
|
SV *eb_SV = items > 8 ? ST(8) : NULL; |
|
218
|
|
|
|
|
|
|
SV *epi_SV = items > 9 ? ST(9) : NULL; |
|
219
|
|
|
|
|
|
|
SV *eomega_SV = items > 10 ? ST(10) : NULL; |
|
220
|
|
|
|
|
|
|
PREINIT: |
|
221
|
6
|
50
|
|
|
|
|
PDL_XS_PREAMBLE((items == 11) ? 0 : 4); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
INPUT: |
|
223
|
|
|
|
|
|
|
pdl *a |
|
224
|
|
|
|
|
|
|
pdl *b |
|
225
|
|
|
|
|
|
|
pdl *pi |
|
226
|
|
|
|
|
|
|
pdl *omega |
|
227
|
|
|
|
|
|
|
pdl *o |
|
228
|
|
|
|
|
|
|
pdl *alpha |
|
229
|
|
|
|
|
|
|
pdl *beta |
|
230
|
|
|
|
|
|
|
pdl *ea |
|
231
|
|
|
|
|
|
|
pdl *eb |
|
232
|
|
|
|
|
|
|
pdl *epi |
|
233
|
|
|
|
|
|
|
pdl *eomega |
|
234
|
|
|
|
|
|
|
PPCODE: |
|
235
|
6
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmexpect(a,b,pi,omega,o,alpha,beta,ea,eb,epi,eomega)); |
|
236
|
6
|
50
|
|
|
|
|
PDL_XS_RETURN(ST(0) = ea_SV;ST(1) = eb_SV;ST(2) = epi_SV;ST(3) = eomega_SV) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
void |
|
239
|
|
|
|
|
|
|
pdl_run_hmmexpectq(a, b, pi, omega, o, oq, alphaq, betaq, ea=PDL_XS_PERLINIT_initsv(ea_SV), eb=PDL_XS_PERLINIT_initsv(eb_SV), epi=PDL_XS_PERLINIT_initsv(epi_SV), eomega=PDL_XS_PERLINIT_initsv(eomega_SV)) |
|
240
|
|
|
|
|
|
|
SV *ea_SV = items > 8 ? ST(8) : NULL; |
|
241
|
|
|
|
|
|
|
SV *eb_SV = items > 9 ? ST(9) : NULL; |
|
242
|
|
|
|
|
|
|
SV *epi_SV = items > 10 ? ST(10) : NULL; |
|
243
|
|
|
|
|
|
|
SV *eomega_SV = items > 11 ? ST(11) : NULL; |
|
244
|
|
|
|
|
|
|
PREINIT: |
|
245
|
0
|
0
|
|
|
|
|
PDL_XS_PREAMBLE((items == 12) ? 0 : 4); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
INPUT: |
|
247
|
|
|
|
|
|
|
pdl *a |
|
248
|
|
|
|
|
|
|
pdl *b |
|
249
|
|
|
|
|
|
|
pdl *pi |
|
250
|
|
|
|
|
|
|
pdl *omega |
|
251
|
|
|
|
|
|
|
pdl *o |
|
252
|
|
|
|
|
|
|
pdl *oq |
|
253
|
|
|
|
|
|
|
pdl *alphaq |
|
254
|
|
|
|
|
|
|
pdl *betaq |
|
255
|
|
|
|
|
|
|
pdl *ea |
|
256
|
|
|
|
|
|
|
pdl *eb |
|
257
|
|
|
|
|
|
|
pdl *epi |
|
258
|
|
|
|
|
|
|
pdl *eomega |
|
259
|
|
|
|
|
|
|
PPCODE: |
|
260
|
0
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmexpectq(a,b,pi,omega,o,oq,alphaq,betaq,ea,eb,epi,eomega)); |
|
261
|
0
|
0
|
|
|
|
|
PDL_XS_RETURN(ST(0) = ea_SV;ST(1) = eb_SV;ST(2) = epi_SV;ST(3) = eomega_SV) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
void |
|
264
|
|
|
|
|
|
|
pdl_run_hmmviterbi(a, b, pi, o, delta=PDL_XS_PERLINIT_initsv(delta_SV), psi=PDL_XS_PERLINIT_initsv(psi_SV)) |
|
265
|
|
|
|
|
|
|
SV *delta_SV = items > 4 ? ST(4) : NULL; |
|
266
|
|
|
|
|
|
|
SV *psi_SV = items > 5 ? ST(5) : NULL; |
|
267
|
|
|
|
|
|
|
PREINIT: |
|
268
|
2
|
50
|
|
|
|
|
PDL_XS_PREAMBLE((items == 6) ? 0 : 2); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
INPUT: |
|
270
|
|
|
|
|
|
|
pdl *a |
|
271
|
|
|
|
|
|
|
pdl *b |
|
272
|
|
|
|
|
|
|
pdl *pi |
|
273
|
|
|
|
|
|
|
pdl *o |
|
274
|
|
|
|
|
|
|
pdl *delta |
|
275
|
|
|
|
|
|
|
pdl *psi |
|
276
|
|
|
|
|
|
|
PPCODE: |
|
277
|
2
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmviterbi(a,b,pi,o,delta,psi)); |
|
278
|
2
|
50
|
|
|
|
|
PDL_XS_RETURN(ST(0) = delta_SV;ST(1) = psi_SV) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
void |
|
281
|
|
|
|
|
|
|
pdl_run_hmmviterbiq(a, b, pi, o, oq, deltaq=PDL_XS_PERLINIT_initsv(deltaq_SV), psiq=PDL_XS_PERLINIT_initsv(psiq_SV)) |
|
282
|
|
|
|
|
|
|
SV *deltaq_SV = items > 5 ? ST(5) : NULL; |
|
283
|
|
|
|
|
|
|
SV *psiq_SV = items > 6 ? ST(6) : NULL; |
|
284
|
|
|
|
|
|
|
PREINIT: |
|
285
|
0
|
0
|
|
|
|
|
PDL_XS_PREAMBLE((items == 7) ? 0 : 2); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
INPUT: |
|
287
|
|
|
|
|
|
|
pdl *a |
|
288
|
|
|
|
|
|
|
pdl *b |
|
289
|
|
|
|
|
|
|
pdl *pi |
|
290
|
|
|
|
|
|
|
pdl *o |
|
291
|
|
|
|
|
|
|
pdl *oq |
|
292
|
|
|
|
|
|
|
pdl *deltaq |
|
293
|
|
|
|
|
|
|
pdl *psiq |
|
294
|
|
|
|
|
|
|
PPCODE: |
|
295
|
0
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmviterbiq(a,b,pi,o,oq,deltaq,psiq)); |
|
296
|
0
|
0
|
|
|
|
|
PDL_XS_RETURN(ST(0) = deltaq_SV;ST(1) = psiq_SV) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
void |
|
299
|
|
|
|
|
|
|
pdl_run_hmmpath(psi, qfinal, path=PDL_XS_PERLINIT_initsv(path_SV)) |
|
300
|
|
|
|
|
|
|
SV *path_SV = items > 2 ? ST(2) : NULL; |
|
301
|
|
|
|
|
|
|
PREINIT: |
|
302
|
2
|
50
|
|
|
|
|
PDL_XS_PREAMBLE((items == 3) ? 0 : 1); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
INPUT: |
|
304
|
|
|
|
|
|
|
pdl *psi |
|
305
|
|
|
|
|
|
|
pdl *qfinal |
|
306
|
|
|
|
|
|
|
pdl *path |
|
307
|
|
|
|
|
|
|
PPCODE: |
|
308
|
2
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmpath(psi,qfinal,path)); |
|
309
|
2
|
50
|
|
|
|
|
PDL_XS_RETURN(ST(0) = path_SV) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
void |
|
312
|
|
|
|
|
|
|
pdl_run_hmmpathq(oq, psiq, qfinalq, path=PDL_XS_PERLINIT_initsv(path_SV)) |
|
313
|
|
|
|
|
|
|
SV *path_SV = items > 3 ? ST(3) : NULL; |
|
314
|
|
|
|
|
|
|
PREINIT: |
|
315
|
0
|
0
|
|
|
|
|
PDL_XS_PREAMBLE((items == 4) ? 0 : 1); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
INPUT: |
|
317
|
|
|
|
|
|
|
pdl *oq |
|
318
|
|
|
|
|
|
|
pdl *psiq |
|
319
|
|
|
|
|
|
|
pdl *qfinalq |
|
320
|
|
|
|
|
|
|
pdl *path |
|
321
|
|
|
|
|
|
|
PPCODE: |
|
322
|
0
|
|
|
|
|
|
PDL->barf_if_error(pdl_run_hmmpathq(oq,psiq,qfinalq,path)); |
|
323
|
0
|
0
|
|
|
|
|
PDL_XS_RETURN(ST(0) = path_SV) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
#line 483 "lib/PDL/PP.pm" |
|
327
|
|
|
|
|
|
|
BOOT: |
|
328
|
|
|
|
|
|
|
/* Get pointer to structure of core shared C routines */ |
|
329
|
|
|
|
|
|
|
/* make sure PDL::Core is loaded */ |
|
330
|
|
|
|
|
|
|
#line 331 "HMM.xs" |
|
331
|
5
|
|
|
|
|
|
perl_require_pv ("PDL/Core.pm"); /* make sure PDL::Core is loaded */ |
|
332
|
|
|
|
|
|
|
#ifndef aTHX_ |
|
333
|
|
|
|
|
|
|
#define aTHX_ |
|
334
|
|
|
|
|
|
|
#endif |
|
335
|
5
|
50
|
|
|
|
|
if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV)); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
336
|
5
|
|
|
|
|
|
SV* CoreSV = perl_get_sv("PDL::SHARE",FALSE); /* var with core structure */ |
|
337
|
5
|
50
|
|
|
|
|
if (!CoreSV) |
|
338
|
0
|
|
|
|
|
|
Perl_croak(aTHX_ "We require the PDL::Core module, which was not found"); |
|
339
|
5
|
50
|
|
|
|
|
if (!(PDL = INT2PTR(Core*,SvIV( CoreSV )))) /* Core* value */ |
|
340
|
0
|
|
|
|
|
|
Perl_croak(aTHX_ "Got NULL pointer for PDL"); |
|
341
|
5
|
50
|
|
|
|
|
if (PDL->Version != PDL_CORE_VERSION) |
|
342
|
0
|
|
|
|
|
|
Perl_croak(aTHX_ "[PDL->Version: %ld PDL_CORE_VERSION: %ld XS_VERSION: %s] PDL::HMM needs to be recompiled against the newly installed PDL", (long int)PDL->Version, (long int)PDL_CORE_VERSION, XS_VERSION); |