IT++ 4.3.1
fix_functions.cpp
Go to the documentation of this file.
1
29
31
32
33namespace itpp
34{
35
36vec 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
45cvec 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
54mat 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
65cmat 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
76Fix 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
84Fix real(const CFix &x)
85{
86 return Fix(x.get_re(),
87 x.get_shift(),
88 0, 0);
89}
90
91Fix imag(const CFix &x)
92{
93 return Fix(x.get_im(),
94 x.get_shift(),
95 0, 0);
96}
97
98CFix 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
Complex fixed-point data type.
Definition cfix.h:52
fixrep get_im() const
Get data representation for imaginary part (mainly for internal use since it reveals the representati...
Definition cfix.h:140
fixrep get_re() const
Get data representation for real part (mainly for internal use since it reveals the representation ty...
Definition cfix.h:138
int get_shift() const
Get shift.
Definition fix_base.h:1001
Fixed-point data type.
Definition fix.h:52
fixrep get_re() const
Get data representation (mainly for internal use since it reveals the representation type)
Definition fix.h:116
int rows() const
The number of rows.
Definition mat.h:237
int cols() const
The number of columns.
Definition mat.h:235
int length() const
The size of the vector.
Definition vec.h:269
Definitions of a set of functions for Fix, Fixed, CFix and CFixed classes.
Vec< CFix > cfixvec
Typedef for complex fixed-point vector type.
Definition cfix.h:178
Mat< CFix > cfixmat
Typedef for complex fixed-point matrix type.
Definition cfix.h:180
Mat< Fix > fixmat
Typedef for fixed-point matrix type.
Definition fix.h:153
int64_t fixrep
Representation for fixed-point data types.
Definition fix_base.h:884
Vec< Fix > fixvec
Typedef for fixed-point vector type.
Definition fix.h:151
vec imag(const cvec &data)
Imaginary part of complex values.
vec real(const cvec &data)
Real part of complex values.
cvec conj(const cvec &x)
Conjugate of complex value.
Definition elem_math.h:226
itpp namespace
Definition itmex.h:37
cvec to_cvec(const Vec< T > &v)
Converts a Vec<T> to cvec.
Definition converters.h:107
cmat to_cmat(const Mat< T > &m)
Converts a Mat<T> to cmat.
Definition converters.h:232
vec to_vec(const Vec< T > &v)
Converts a Vec<T> to vec.
Definition converters.h:93
mat to_mat(const Mat< T > &m)
Converts a Mat<T> to mat.
Definition converters.h:216
bin abs(const bin &inbin)
absolute value of bin
Definition binary.h:174