IT++ Logo
fix_functions.cpp
Go to the documentation of this file.
1 
31 
32 
33 namespace itpp
34 {
35 
36 vec to_vec(const fixvec &v)
37 {
38  vec temp(v.length());
39  for (int i = 0; i < v.length(); i++) {
40  temp(i) = v(i).unfix();
41  }
42  return temp;
43 }
44 
45 cvec to_cvec(const cfixvec &v)
46 {
47  cvec temp(v.length());
48  for (int i = 0; i < v.length(); i++) {
49  temp(i) = v(i).unfix();
50  }
51  return temp;
52 }
53 
54 mat to_mat(const fixmat &m)
55 {
56  mat temp(m.rows(), m.cols());
57  for (int i = 0; i < m.rows(); i++) {
58  for (int j = 0; j < m.cols(); j++) {
59  temp(i, j) = m(i, j).unfix();
60  }
61  }
62  return temp;
63 }
64 
65 cmat to_cmat(const cfixmat &m)
66 {
67  cmat temp(m.rows(), m.cols());
68  for (int i = 0; i < m.rows(); i++) {
69  for (int j = 0; j < m.cols(); j++) {
70  temp(i, j) = m(i, j).unfix();
71  }
72  }
73  return temp;
74 }
75 
76 Fix abs(const Fix &x)
77 {
78  fixrep tmp = x.get_re();
79  return Fix((tmp >= 0 ? tmp : -tmp), // Risk for overflow!
80  x.get_shift(),
81  0, 0);
82 }
83 
84 Fix real(const CFix &x)
85 {
86  return Fix(x.get_re(),
87  x.get_shift(),
88  0, 0);
89 }
90 
91 Fix imag(const CFix &x)
92 {
93  return Fix(x.get_im(),
94  x.get_shift(),
95  0, 0);
96 }
97 
98 CFix conj(const CFix &x)
99 {
100  return CFix(x.get_re(),
101  -x.get_im(),
102  x.get_shift(),
103  0, 0);
104 }
105 
106 } // namespace itpp
Definitions of a set of functions for Fix, Fixed, CFix and CFixed classes.
vec imag(const cvec &data)
Imaginary part of complex values.
Definition: elem_math.cpp:180
Matrix Class (Templated)
Definition: factory.h:41
cvec conj(const cvec &x)
Conjugate of complex value.
Definition: elem_math.h:226
cmat to_cmat(const Mat< T > &m)
Converts a Mat<T> to cmat.
Definition: converters.h:232
mat to_mat(const Mat< T > &m)
Converts a Mat<T> to mat.
Definition: converters.h:216
fixrep get_re() const
Get data representation (mainly for internal use since it reveals the representation type) ...
Definition: fix.h:116
int cols() const
The number of columns.
Definition: mat.h:235
Complex fixed-point data type.
Definition: cfix.h:51
vec to_vec(const Vec< T > &v)
Converts a Vec<T> to vec.
Definition: converters.h:93
itpp namespace
Definition: itmex.h:36
int length() const
The size of the vector.
Definition: vec.h:269
Fixed-point data type.
Definition: fix.h:51
fixrep get_im() const
Get data representation for imaginary part (mainly for internal use since it reveals the representati...
Definition: cfix.h:140
int rows() const
The number of rows.
Definition: mat.h:237
Vector Class (Templated)
Definition: factory.h:42
cvec to_cvec(const Vec< T > &v)
Converts a Vec<T> to cvec.
Definition: converters.h:107
fixrep get_re() const
Get data representation for real part (mainly for internal use since it reveals the representation ty...
Definition: cfix.h:138
bin abs(const bin &inbin)
absolute value of bin
Definition: binary.h:174
int64_t fixrep
Representation for fixed-point data types.
Definition: fix_base.h:884
vec real(const cvec &data)
Real part of complex values.
Definition: elem_math.cpp:157
int get_shift() const
Get shift.
Definition: fix_base.h:1001
SourceForge Logo

Generated on Sun Apr 10 2022 12:00:00 for IT++ by Doxygen 1.8.14