IT++ Logo
stc.h
Go to the documentation of this file.
1 
29 #ifndef STC_H
30 #define STC_H
31 
32 #include <itpp/itbase.h> //IT++ base module
33 #include <itpp/itexports.h>
34 
35 namespace itpp
36 {
37 
80 class ITPP_EXPORT STC
81 {
82 public:
84  inline STC(const std::string &in_code_name,
85  int in_const_size,
86  int in_em_antenna = 0,
87  int in_channel_uses = 0
88  )
89  {
90  setup(in_code_name, in_const_size, in_em_antenna, in_channel_uses);
91  }
93  inline void setup(const std::string &in_code_name,
94  int in_const_size,
95  int in_em_antenna = 0,
96  int in_channel_uses = 0
97  )
98  {
99  code_name = code_name_from_string(in_code_name);
100  it_assert(in_const_size >= 2, "Constellation size should be at least two");
101  const_size = in_const_size;
102  em_antenna = in_em_antenna;
103  channel_uses = in_channel_uses;
104  Hassibi_block_code();
105  }
107  inline int get_nb_emission_antenna(void) const
108  {
109  return em_antenna;
110  }
112  inline int get_channel_uses(void) const
113  {
114  return channel_uses;
115  }
117  inline int get_nb_symbols_per_block(void) const
118  {
119  return symb_block;
120  }
122  inline itpp::cmat get_1st_gen_matrix(void) const
123  {
124  return A;
125  }
127  inline itpp::cmat get_2nd_gen_matrix(void) const
128  {
129  return B;
130  }
132  itpp::cmat encode(const itpp::cvec &symb);
133 private:
134  STC(const STC&);//not used
135  STC& operator=(const STC&);//not used
136  void Hassibi_block_code(void);
137  itpp::cmat diag_pow(const itpp::cmat &in_mat, double in_exp);
138  itpp::mat mat_pow(const itpp::mat &in_mat, int in_exp);
139 
140  struct ITPP_EXPORT Code_Names
141  {
142  enum Type {Unknown, V_BLAST_MxN, imp_V_BLAST_MxN,
143  Alamouti_2xN, Switched_Alamouti_4xN, Double_Alamouti_4xN,
144  Jafarkhani_4xN, Golden_2x2, Damen_2x2, ortho34_3xN,
145  LD36_3xN, LD37_3xN, LD39_3xN};
146  Code_Names() : _t(Unknown) {}
147  Code_Names(Type t) : _t(t) {}
148  operator Type () const {return _t;}
149  private:
150  Type _t;
151  template<typename T> operator T () const;
152  };
153  Code_Names code_name;
154 
155  int const_size;
156  int em_antenna;
157  int channel_uses;
158  int symb_block;
159  itpp::cmat A;
160  itpp::cmat B;
161 
162  static Code_Names code_name_from_string(const std::string &name);
163  static std::string string_from_code_name(const Code_Names& cn);
164 };
165 
166 inline STC::Code_Names STC::code_name_from_string(const std::string &name)
167 {
168  if (name=="V-BLAST_MxN")
169  {
170  return Code_Names::V_BLAST_MxN;
171  } else if (name =="imp_V-BLAST_MxN")
172  {
173  return Code_Names::imp_V_BLAST_MxN;
174  } else if (name =="Alamouti_2xN")
175  {
176  return Code_Names::Alamouti_2xN;
177  } else if (name =="Switched_Alamouti_4xN")
178  {
179  return Code_Names::Switched_Alamouti_4xN;
180  } else if (name =="Double_Alamouti_4xN")
181  {
182  return Code_Names::Double_Alamouti_4xN;
183  } else if (name =="Jafarkhani_4xN")
184  {
185  return Code_Names::Jafarkhani_4xN;
186  } else if (name =="Golden_2x2")
187  {
188  return Code_Names::Golden_2x2;
189  } else if (name =="Damen_2x2")
190  {
191  return Code_Names::Damen_2x2;
192  } else if (name =="34ortho_3xN")
193  {
194  return Code_Names::ortho34_3xN;
195  } else if (name =="36LD_3xN")
196  {
197  return Code_Names::LD36_3xN;
198  } else if (name =="37LD_3xN")
199  {
200  return Code_Names::LD37_3xN;
201  } else if (name =="39LD_3xN")
202  {
203  return Code_Names::LD39_3xN;
204  } else
205  {
206  return Code_Names::Unknown;
207  }
208 }
209 
210 inline std::string STC::string_from_code_name(const STC::Code_Names& cn)
211 {
212  if (cn==Code_Names::V_BLAST_MxN)
213  {
214  return std::string("V-BLAST_MxN");
215  } else if (cn==Code_Names::imp_V_BLAST_MxN)
216  {
217  return std::string("imp_V-BLAST_MxN");
218  } else if (cn==Code_Names::Alamouti_2xN)
219  {
220  return std::string("Alamouti_2xN");
221  } else if (cn==Code_Names::Switched_Alamouti_4xN)
222  {
223  return std::string("Switched_Alamouti_4xN");
224  } else if (cn==Code_Names::Double_Alamouti_4xN)
225  {
226  return std::string("Double_Alamouti_4xN");
227  } else if (cn==Code_Names::Jafarkhani_4xN)
228  {
229  return std::string("Jafarkhani_4xN");
230  } else if (cn==Code_Names::Golden_2x2)
231  {
232  return std::string("Golden_2x2");
233  } else if (cn==Code_Names::Damen_2x2)
234  {
235  return std::string("Damen_2x2");
236  } else if (cn==Code_Names::ortho34_3xN)
237  {
238  return std::string("34ortho_3xN");
239  } else if (cn==Code_Names::LD36_3xN)
240  {
241  return std::string("36LD_3xN");
242  } else if (cn==Code_Names::LD37_3xN)
243  {
244  return std::string("37LD_3xN");
245  } else if (cn==Code_Names::LD39_3xN)
246  {
247  return std::string("39LD_3xN");
248  } else
249  {
250  return std::string("Unknown");
251  }
252 }
253 }
254 #endif /* STC_H_ */
SourceForge Logo

Generated on Sat May 25 2013 16:32:22 for IT++ by Doxygen 1.8.2