00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __it_convcode_h
00026 #define __it_convcode_h
00027
00028 #include <it/types.h>
00029 #include <it/mat.h>
00030 #include <it/vec.h>
00031
00032
00033
00034
00035
00036
00037
00038
00039 typedef struct _convolutional_code_ {
00040 it_extends (it_object_t);
00041
00042
00043 void (*it_overloaded (destructor)) (it_object_t * it_this);
00044
00045
00046
00047
00048
00049 bvec (*encode) (struct _convolutional_code_ * convolutional_code,
00050 bvec v);
00051
00052
00053
00054 ivec (*encode_symbolic) (struct _convolutional_code_ * cc, ivec b);
00055
00056 int k;
00057 int n;
00058 int memory;
00059 int n_labels;
00060 int n_states;
00061 int n_symbols;
00062
00063 vec logalpha_0;
00064 vec logbeta_end;
00065 mat next_state_logpt;
00066 imat automaton;
00067 imat output;
00068 imat input;
00069
00070 int Q;
00071 imat generators;
00072
00073 } it_convolutional_code_t;
00074
00075 #define IT_CONVOLUTIONAL_CODE(q) IT_CAST(it_convolutional_code_t, q)
00076
00077 it_instanciate (it_convolutional_code_t);
00078
00079
00080
00081 static inline it_convolutional_code_t *it_convolutional_code_new (imat
00082 generators,
00083 int
00084 feedback) {
00085 return (it_new_va (it_convolutional_code_t)
00086 (it_va, generators, feedback));
00087 }
00088 #define it_convolutional_code_encode(it_this, b) __it_convolutional_code_encode(IT_CONVOLUTIONAL_CODE(it_this), b)
00089 static inline bvec __it_convolutional_code_encode (it_convolutional_code_t
00090 * it_this, bvec b) {
00091 return (it_this->encode (it_this, b));
00092 }
00093
00094 #define it_convolutional_code_encode_symbolic(it_this, b) __it_convolutional_code_encode_symbolic(IT_CONVOLUTIONAL_CODE(it_this), b)
00095 static inline ivec
00096 __it_convolutional_code_encode_symbolic (it_convolutional_code_t *
00097 it_this, ivec b) {
00098 return (it_this->encode_symbolic (it_this, b));
00099 }
00100
00101 static inline int
00102 it_convolutional_code_trellis_label (it_convolutional_code_t * cc,
00103 int state, int symbol) {
00104 return (cc->output[symbol][state]);
00105 }
00106
00107 static inline int
00108 it_convolutional_code_trellis_next (it_convolutional_code_t * cc,
00109 int state, int symbol) {
00110 return (cc->
00111 automaton[it_convolutional_code_trellis_label (cc, state, symbol)]
00112 [state]);
00113 }
00114
00115
00116 #define it_cc_encode(cc, b) it_convolutional_code_encode(cc, b)
00117 #define it_cc_encode_symbolic(cc, b) it_convolutional_code_encode_symbolic(cc, b)
00118 #define it_cc_decode(cc, v) it_convolutional_code_decode(cc, v)
00119 #define it_cc_next(cc, s, b) it_convolutional_code_trellis_next(cc, s, b)
00120 #define it_cc_label(cc, s, b) it_convolutional_code_trellis_label(cc, s, b)
00121
00122
00123 ivec it_viterbi_decode_symbolic (it_convolutional_code_t * cc, mat metrics);
00124 bvec it_viterbi_decode (it_convolutional_code_t * cc, mat metrics);
00125
00126
00127
00128 #endif