IT++ 4.3.1
sequence.h
Go to the documentation of this file.
1
28
29#ifndef SEQUENCE_H
30#define SEQUENCE_H
31
32#include <itpp/base/vec.h>
33#include <itpp/base/mat.h>
34#include <itpp/itexports.h>
35
36namespace itpp
37{
38
53class ITPP_EXPORT LFSR
54{
55public:
57 LFSR(void) {};
59 LFSR(const bvec &connections);
61 LFSR(const ivec &connections);
63 void set_connections(const bvec &connections);
65 void set_connections(const ivec &connections);
67 void set_state(const bvec &state);
69 void set_state(const ivec &state);
71 bin shift(void);
73 bvec shift(int no_shifts);
75 int get_length(void);
77 bvec get_state(void);
78private:
79 bvec memory, Connections;
80};
81
86class ITPP_EXPORT Gold
87{
88public:
96 Gold(int degree);
98 Gold(const bvec &mseq1_connections, const bvec &mseq2_connections);
100 Gold(const ivec &mseq1_connections, const ivec &mseq2_connections);
102 void set_state(const bvec &state1, const bvec &state2);
104 void set_state(const ivec &state1, const ivec &state2);
106 bin shift(void);
108 bvec shift(int no_shifts);
110 int get_sequence_length(void);
118 bmat get_family(void);
119private:
120 int N;
121 LFSR mseq1, mseq2;
122};
123
124// --------------- Inlines ---------------------
125inline bin LFSR::shift(void) {bin temp = memory * Connections;memory.shift_right(temp);return temp;}
126inline int LFSR::get_length(void) {return memory.size();}
127inline bvec LFSR::get_state(void) {return memory;}
128
129inline bin Gold::shift(void) {return (mseq1.shift() + mseq2.shift());}
130inline int Gold::get_sequence_length(void) {return N;}
131
132
133// --------------- Functions ---------------------
134
142ITPP_EXPORT smat wcdma_spreading_codes(int SF);
143
144} // namespace itpp
145
146#endif // #ifndef SEQUENCE_H
int get_sequence_length(void)
Returns the length (period) of a Gold-sequence.
Definition sequence.h:130
Gold(int degree)
Class constructor.
Definition sequence.cpp:86
void set_state(const bvec &state1, const bvec &state2)
Set state (contents in the shift registers) in bvec format.
Definition sequence.cpp:130
bin shift(void)
Shift one step and output binary symbol.
Definition sequence.h:129
bmat get_family(void)
Returns the code family.
Definition sequence.cpp:152
Binary Linear Feedback Shift Register (LFSR)
Definition sequence.h:54
LFSR(void)
Constructor.
Definition sequence.h:57
int get_length(void)
Return length of shift register.
Definition sequence.h:126
bvec get_state(void)
Returns the state of the shift register.
Definition sequence.h:127
bin shift(void)
Shift one step and output binary symbol.
Definition sequence.h:125
Binary arithmetic (boolean) class.
Definition binary.h:57
smat wcdma_spreading_codes(int SF)
Generates the OVSF (orthogonal variable spreading factor) spreading codes used in WCDMA.
Definition sequence.cpp:168
Matrix Class Definitions.
Mat< bin > bmat
bin matrix
Definition mat.h:508
itpp namespace
Definition itmex.h:37
Templated Vector Class Definitions.