IT++ Logo
fix_functions.cpp
Go to the documentation of this file.
00001 
00030 #include <itpp/fixed/fix_functions.h>
00031 
00032 
00033 namespace itpp
00034 {
00035 
00036 vec to_vec(const fixvec &v)
00037 {
00038   vec temp(v.length());
00039   for (int i = 0; i < v.length(); i++) {
00040     temp(i) = v(i).unfix();
00041   }
00042   return temp;
00043 }
00044 
00045 cvec to_cvec(const cfixvec &v)
00046 {
00047   cvec temp(v.length());
00048   for (int i = 0; i < v.length(); i++) {
00049     temp(i) = v(i).unfix();
00050   }
00051   return temp;
00052 }
00053 
00054 mat to_mat(const fixmat &m)
00055 {
00056   mat temp(m.rows(), m.cols());
00057   for (int i = 0; i < m.rows(); i++) {
00058     for (int j = 0; j < m.cols(); j++) {
00059       temp(i, j) = m(i, j).unfix();
00060     }
00061   }
00062   return temp;
00063 }
00064 
00065 cmat to_cmat(const cfixmat &m)
00066 {
00067   cmat temp(m.rows(), m.cols());
00068   for (int i = 0; i < m.rows(); i++) {
00069     for (int j = 0; j < m.cols(); j++) {
00070       temp(i, j) = m(i, j).unfix();
00071     }
00072   }
00073   return temp;
00074 }
00075 
00076 Fix abs(const Fix &x)
00077 {
00078   fixrep tmp = x.get_re();
00079   return Fix((tmp >= 0 ? tmp : -tmp),  // Risk for overflow!
00080              x.get_shift(),
00081              0, 0);
00082 }
00083 
00084 Fix real(const CFix &x)
00085 {
00086   return Fix(x.get_re(),
00087              x.get_shift(),
00088              0, 0);
00089 }
00090 
00091 Fix imag(const CFix &x)
00092 {
00093   return Fix(x.get_im(),
00094              x.get_shift(),
00095              0, 0);
00096 }
00097 
00098 CFix conj(const CFix &x)
00099 {
00100   return CFix(x.get_re(),
00101               -x.get_im(),
00102               x.get_shift(),
00103               0, 0);
00104 }
00105 
00106 } // namespace itpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SourceForge Logo

Generated on Wed Jul 27 2011 16:27:05 for IT++ by Doxygen 1.7.4