IT++
4.3.1
Toggle main menu visibility
itpp
fixed
fix_functions.cpp
Go to the documentation of this file.
1
29
30
#include <
itpp/fixed/fix_functions.h
>
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
itpp::CFix
Complex fixed-point data type.
Definition
cfix.h:52
itpp::CFix::get_im
fixrep get_im() const
Get data representation for imaginary part (mainly for internal use since it reveals the representati...
Definition
cfix.h:140
itpp::CFix::get_re
fixrep get_re() const
Get data representation for real part (mainly for internal use since it reveals the representation ty...
Definition
cfix.h:138
itpp::Fix_Base::get_shift
int get_shift() const
Get shift.
Definition
fix_base.h:1001
itpp::Fix
Fixed-point data type.
Definition
fix.h:52
itpp::Fix::get_re
fixrep get_re() const
Get data representation (mainly for internal use since it reveals the representation type).
Definition
fix.h:116
itpp::Mat::rows
int rows() const
The number of rows.
Definition
mat.h:237
itpp::Mat::cols
int cols() const
The number of columns.
Definition
mat.h:235
itpp::Vec::length
int length() const
The size of the vector.
Definition
vec.h:269
fix_functions.h
Definitions of a set of functions for Fix, Fixed, CFix and CFixed classes.
itpp::cfixvec
Vec< CFix > cfixvec
Typedef for complex fixed-point vector type.
Definition
cfix.h:178
itpp::cfixmat
Mat< CFix > cfixmat
Typedef for complex fixed-point matrix type.
Definition
cfix.h:180
itpp::fixmat
Mat< Fix > fixmat
Typedef for fixed-point matrix type.
Definition
fix.h:153
itpp::fixrep
int64_t fixrep
Representation for fixed-point data types.
Definition
fix_base.h:884
itpp::fixvec
Vec< Fix > fixvec
Typedef for fixed-point vector type.
Definition
fix.h:151
itpp::imag
vec imag(const cvec &data)
Imaginary part of complex values.
Definition
elem_math.cpp:180
itpp::real
vec real(const cvec &data)
Real part of complex values.
Definition
elem_math.cpp:157
itpp::conj
cvec conj(const cvec &x)
Conjugate of complex value.
Definition
elem_math.h:226
itpp
itpp namespace
Definition
itmex.h:37
itpp::to_cvec
cvec to_cvec(const Vec< T > &v)
Converts a Vec<T> to cvec.
Definition
converters.h:107
itpp::to_cmat
cmat to_cmat(const Mat< T > &m)
Converts a Mat<T> to cmat.
Definition
converters.h:232
itpp::to_vec
vec to_vec(const Vec< T > &v)
Converts a Vec<T> to vec.
Definition
converters.h:93
itpp::to_mat
mat to_mat(const Mat< T > &m)
Converts a Mat<T> to mat.
Definition
converters.h:216
itpp::abs
bin abs(const bin &inbin)
absolute value of bin
Definition
binary.h:174
Generated by
1.17.0