Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
itpp
fixed
fix_functions.cpp
Go to the documentation of this file.
1
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
Generated on Sat Jul 6 2013 10:54:24 for IT++ by
Doxygen
1.8.2