Skip to content

Commit 7381c18

Browse files
author
Alexandre Marquet
committed
Allow for bigger input alphabet in viterbi.
1 parent eca47d7 commit 7381c18

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

PyTurbo.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ cdef class PyViterbi:
6565

6666
self.cpp_viterbi.viterbi_algorithm(K, S0, SK, &_in[0], &_out[0])
6767

68-
return numpy.asarray(_out, dtype=numpy.uint8)
68+
return numpy.asarray(_out, dtype=numpy.uint16)
6969

7070
cdef class PyLogBCJR:
7171
cdef int I, S, O

viterbi.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ viterbi::generate_PS_PI()
6363

6464
void
6565
viterbi::viterbi_algorithm(int K, int S0, int SK, const float *in,
66-
unsigned char *out)
66+
unsigned int *out)
6767
{
6868
viterbi_algorithm(d_I, d_S, d_O, d_NS, d_OS, d_PS, d_PI, K, S0, SK, in, out);
6969
}
@@ -72,7 +72,7 @@ void
7272
viterbi::viterbi_algorithm(int I, int S, int O, const std::vector<int> &NS,
7373
const std::vector<int> &OS, const std::vector< std::vector<int> > &PS,
7474
const std::vector< std::vector<int> > &PI, int K, int S0, int SK,
75-
const float *in, unsigned char *out)
75+
const float *in, unsigned int *out)
7676
{
7777
int tb_state, pidx;
7878
float can_metric = std::numeric_limits<float>::max();
@@ -147,14 +147,14 @@ viterbi::viterbi_algorithm(int I, int S, int O, const std::vector<int> &NS,
147147
//Traceback
148148
trace_it = trace.end() - S; //place trace_it at the last time index
149149

150-
for(unsigned char* out_k = out+K-1 ; out_k >= out ; --out_k) {
150+
for(unsigned int* out_k = out+K-1 ; out_k >= out ; --out_k) {
151151
//Retrieve previous input index from trace
152152
pidx=*(trace_it + tb_state);
153153
//Update trace_it for next output symbol
154154
trace_it -= S;
155155

156156
//Output previous input
157-
*out_k = (unsigned char) PI[tb_state][pidx];
157+
*out_k = (unsigned int) PI[tb_state][pidx];
158158

159159
//Update tb_state with the previous state on the shortest path
160160
tb_state = PS[tb_state][pidx];

viterbi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class viterbi
9292
* \param out Output decoded sequence.
9393
*/
9494
void viterbi_algorithm(int K, int S0, int SK,
95-
const float *in, unsigned char *out);
95+
const float *in, unsigned int *out);
9696

9797
/*! Actual Viterbi algorithm implementation.
9898
*
@@ -119,7 +119,7 @@ class viterbi
119119
const std::vector< std::vector<int> > &PS,
120120
const std::vector< std::vector<int> > &PI,
121121
int K, int S0, int SK,
122-
const float *in, unsigned char *out);
122+
const float *in, unsigned int *out);
123123

124124
//! Getter for d_I.
125125
int get_I() { return d_I; }

0 commit comments

Comments
 (0)