00001 00033 #ifndef CONVERTERS_H 00034 #define CONVERTERS_H 00035 00036 #include <itpp/base/vec.h> 00037 #include <itpp/base/mat.h> 00038 00039 00040 namespace itpp { 00041 00044 00045 00050 template <class T> 00051 bvec to_bvec(const Vec<T> &v); 00052 00057 template <class T> 00058 svec to_svec(const Vec<T> &v); 00059 00064 template <class T> 00065 ivec to_ivec(const Vec<T> &v); 00066 00071 template <class T> 00072 vec to_vec(const Vec<T> &v); 00073 00078 template <class T> 00079 cvec to_cvec(const Vec<T> &v); 00080 00085 template <class T> 00086 cvec to_cvec(const Vec<T> &real, const Vec<T> &imag); 00087 00092 ivec to_ivec(int s); 00093 00098 vec to_vec(double s); 00099 00104 cvec to_cvec(double real, double imag); 00105 00110 template <class T> 00111 bmat to_bmat(const Mat<T> &m); 00112 00117 template <class T> 00118 smat to_smat(const Mat<T> &m); 00119 00124 template <class T> 00125 imat to_imat(const Mat<T> &m); 00126 00131 template <class T> 00132 mat to_mat(const Mat<T> &m); 00133 00138 template <class T> 00139 cmat to_cmat(const Mat<T> &m); 00140 00145 template <class T> 00146 cmat to_cmat(const Mat<T> &real, const Mat<T> &imag); 00147 00151 bvec dec2bin(int length, int index); 00152 00156 void dec2bin(int index, bvec &v); 00157 00161 bvec dec2bin(int index, bool msb_first = true); 00162 00166 int bin2dec(const bvec &inbvec, bool msb_first = true); 00167 00175 bvec oct2bin(const ivec &octalindex, short keepzeros = 0); 00176 00184 ivec bin2oct(const bvec &inbits); 00185 00187 ivec bin2pol(const bvec &inbvec); 00188 00190 bvec pol2bin(const ivec &inpol); 00191 00197 template <typename T> 00198 std::string to_str(const T &i); 00199 00206 std::string to_str(const double &i, const int precision); 00207 00209 00210 template <typename T> 00211 std::string to_str(const T &i) 00212 { 00213 std::ostringstream ss; 00214 ss.precision(8); 00215 ss.setf(std::ostringstream::scientific,std::ostringstream::floatfield); 00216 ss << i; 00217 return ss.str(); 00218 } 00219 00220 // ---------------------- Instantiations ----------------------------------------- 00221 #ifndef _MSC_VER 00222 00224 extern template bvec to_bvec(const svec &v); 00226 extern template bvec to_bvec(const Vec<int> &v); 00228 extern template svec to_svec(const bvec &v); 00230 extern template svec to_svec(const ivec &v); 00232 extern template svec to_svec(const svec &v); 00233 00235 extern template ivec to_ivec(const bvec &v); 00237 extern template ivec to_ivec(const svec &v); 00239 extern template ivec to_ivec(const ivec &v); 00241 extern template ivec to_ivec(const vec &v); 00242 00244 extern template vec to_vec(const bvec &v); 00246 extern template vec to_vec(const svec &v); 00248 extern template vec to_vec(const ivec &v); 00250 extern template vec to_vec(const vec &v); 00251 00252 // Template instantiation of to_cvec 00253 //template cvec to_cvec(const bvec &v); //Specialization created above 00254 00256 extern template cvec to_cvec(const svec &v); 00258 extern template cvec to_cvec(const ivec &v); 00260 extern template cvec to_cvec(const vec &v); 00262 extern template cvec to_cvec(const cvec &v); 00264 extern template cvec to_cvec(const bvec &real, const bvec &imag); 00266 extern template cvec to_cvec(const svec &real, const svec &imag); 00268 extern template cvec to_cvec(const ivec &real, const ivec &imag); 00270 extern template cvec to_cvec(const vec &real, const vec &imag); 00271 00273 extern template bmat to_bmat(const smat &m); 00275 extern template bmat to_bmat(const imat &m); 00277 extern template smat to_smat(const bmat &m); 00279 extern template smat to_smat(const imat &m); 00280 00282 extern template imat to_imat(const bmat &m); 00284 extern template imat to_imat(const smat &m); 00286 extern template imat to_imat(const imat &m); 00287 // Template instantiation of to_imat 00288 extern template imat to_imat(const mat &m); 00289 00291 extern template mat to_mat(const bmat &m); 00293 extern template mat to_mat(const smat &m); 00295 extern template mat to_mat(const imat &m); 00297 extern template mat to_mat(const mat &m); 00298 00299 // Template instantiation of to_cmat 00300 //template cmat to_cmat(const bmat &m); //Specialization created above 00301 00303 extern template cmat to_cmat(const smat &m); 00305 extern template cmat to_cmat(const imat &m); 00307 extern template cmat to_cmat(const mat &m); 00309 extern template cmat to_cmat(const cmat &m); 00311 extern template cmat to_cmat(const bmat &real, const bmat &imag); 00313 extern template cmat to_cmat(const smat &real, const smat &imag); 00315 extern template cmat to_cmat(const imat &real, const imat &imag); 00317 extern template cmat to_cmat(const mat &real, const mat &imag); 00318 00319 #endif 00320 00321 } //namespace itpp 00322 00323 #endif // #ifndef CONVERTERS_H
Generated on Sat Aug 25 23:37:26 2007 for IT++ by Doxygen 1.5.2