IT++ Logo
cfixed.h
Go to the documentation of this file.
1
29#ifndef CFIXED_H
30#define CFIXED_H
31
32#include <itpp/fixed/cfix.h>
33#include <itpp/itexports.h>
34
35
36namespace itpp
37{
38
49template < int w, e_mode e = TC, o_mode o = WRAP, q_mode q = TRN >
50class CFixed : public CFix
51{
52public:
54 CFixed(double r = 0.0, double i = 0.0, int s = 0, Stat *ptr = 0)
55 : CFix(r, i, s, w, e, o, q, ptr) {}
57 CFixed(std::complex<double> x, double, int s = 0, Stat *ptr = 0)
58 : CFix(x, 0.0, s, w, e, o, q, ptr) {}
60 explicit CFixed(Stat *ptr)
61 : CFix(0.0, 0.0, 0, w, e, o, q, ptr) {}
63 CFixed(const Fix &r, const Fix &i = 0.0, Stat *ptr = 0)
64 : CFix(r, i, w, e, o, q, ptr) {}
66 CFixed(const CFix &x, double, Stat *ptr = 0)
67 : CFix(x, 0.0, w, e, o, q, ptr) {}
69 virtual ~CFixed() {}
70
72 CFixed& operator=(const CFix &x) {
73 shift = x.shift;
74 re = apply_o_mode(x.re);
75 im = apply_o_mode(x.im);
76 return *this;
77 }
79 CFixed& operator=(const Fix &x) {
80 shift = x.shift;
81 re = apply_o_mode(x.re);
82 im = 0;
83 return *this;
84 }
86 CFixed& operator=(const std::complex<double> &x) {
87 shift = 0;
90 return *this;
91 }
93 CFixed& operator=(int x) {
94 shift = 0;
95 re = apply_o_mode(x);
96 im = 0;
97 return *this;
98 }
99protected:
100};
101
107typedef CFixed<2, TC, WRAP> cfixed2;
108typedef CFixed<3, TC, WRAP> cfixed3;
109typedef CFixed<4, TC, WRAP> cfixed4;
110typedef CFixed<5, TC, WRAP> cfixed5;
111typedef CFixed<6, TC, WRAP> cfixed6;
112typedef CFixed<7, TC, WRAP> cfixed7;
113typedef CFixed<8, TC, WRAP> cfixed8;
114typedef CFixed<9, TC, WRAP> cfixed9;
115typedef CFixed<10, TC, WRAP> cfixed10;
116typedef CFixed<11, TC, WRAP> cfixed11;
117typedef CFixed<12, TC, WRAP> cfixed12;
118typedef CFixed<13, TC, WRAP> cfixed13;
119typedef CFixed<14, TC, WRAP> cfixed14;
120typedef CFixed<15, TC, WRAP> cfixed15;
121typedef CFixed<16, TC, WRAP> cfixed16;
122typedef CFixed<17, TC, WRAP> cfixed17;
123typedef CFixed<18, TC, WRAP> cfixed18;
124typedef CFixed<19, TC, WRAP> cfixed19;
125typedef CFixed<20, TC, WRAP> cfixed20;
126typedef CFixed<21, TC, WRAP> cfixed21;
127typedef CFixed<22, TC, WRAP> cfixed22;
128typedef CFixed<23, TC, WRAP> cfixed23;
129typedef CFixed<24, TC, WRAP> cfixed24;
130typedef CFixed<25, TC, WRAP> cfixed25;
131typedef CFixed<26, TC, WRAP> cfixed26;
132typedef CFixed<27, TC, WRAP> cfixed27;
133typedef CFixed<28, TC, WRAP> cfixed28;
134typedef CFixed<29, TC, WRAP> cfixed29;
135typedef CFixed<30, TC, WRAP> cfixed30;
136typedef CFixed<31, TC, WRAP> cfixed31;
137typedef CFixed<32, TC, WRAP> cfixed32;
138typedef CFixed<33, TC, WRAP> cfixed33;
139typedef CFixed<34, TC, WRAP> cfixed34;
140typedef CFixed<35, TC, WRAP> cfixed35;
141typedef CFixed<36, TC, WRAP> cfixed36;
142typedef CFixed<37, TC, WRAP> cfixed37;
143typedef CFixed<38, TC, WRAP> cfixed38;
144typedef CFixed<39, TC, WRAP> cfixed39;
145typedef CFixed<40, TC, WRAP> cfixed40;
146typedef CFixed<41, TC, WRAP> cfixed41;
147typedef CFixed<42, TC, WRAP> cfixed42;
148typedef CFixed<43, TC, WRAP> cfixed43;
149typedef CFixed<44, TC, WRAP> cfixed44;
150typedef CFixed<45, TC, WRAP> cfixed45;
151typedef CFixed<46, TC, WRAP> cfixed46;
152typedef CFixed<47, TC, WRAP> cfixed47;
153typedef CFixed<48, TC, WRAP> cfixed48;
154typedef CFixed<49, TC, WRAP> cfixed49;
155typedef CFixed<50, TC, WRAP> cfixed50;
156typedef CFixed<51, TC, WRAP> cfixed51;
157typedef CFixed<52, TC, WRAP> cfixed52;
158typedef CFixed<53, TC, WRAP> cfixed53;
159typedef CFixed<54, TC, WRAP> cfixed54;
160typedef CFixed<55, TC, WRAP> cfixed55;
161typedef CFixed<56, TC, WRAP> cfixed56;
162typedef CFixed<57, TC, WRAP> cfixed57;
163typedef CFixed<58, TC, WRAP> cfixed58;
164typedef CFixed<59, TC, WRAP> cfixed59;
165typedef CFixed<60, TC, WRAP> cfixed60;
166typedef CFixed<61, TC, WRAP> cfixed61;
167typedef CFixed<62, TC, WRAP> cfixed62;
168typedef CFixed<63, TC, WRAP> cfixed63;
169typedef CFixed<64, TC, WRAP> cfixed64;
171
175typedef CFixed<1, TC, SAT> scfixed1;
176typedef CFixed<2, TC, SAT> scfixed2;
177typedef CFixed<3, TC, SAT> scfixed3;
178typedef CFixed<4, TC, SAT> scfixed4;
179typedef CFixed<5, TC, SAT> scfixed5;
180typedef CFixed<6, TC, SAT> scfixed6;
181typedef CFixed<7, TC, SAT> scfixed7;
182typedef CFixed<8, TC, SAT> scfixed8;
183typedef CFixed<9, TC, SAT> scfixed9;
184typedef CFixed<10, TC, SAT> scfixed10;
185typedef CFixed<11, TC, SAT> scfixed11;
186typedef CFixed<12, TC, SAT> scfixed12;
187typedef CFixed<13, TC, SAT> scfixed13;
188typedef CFixed<14, TC, SAT> scfixed14;
189typedef CFixed<15, TC, SAT> scfixed15;
190typedef CFixed<16, TC, SAT> scfixed16;
191typedef CFixed<17, TC, SAT> scfixed17;
192typedef CFixed<18, TC, SAT> scfixed18;
193typedef CFixed<19, TC, SAT> scfixed19;
194typedef CFixed<20, TC, SAT> scfixed20;
195typedef CFixed<21, TC, SAT> scfixed21;
196typedef CFixed<22, TC, SAT> scfixed22;
197typedef CFixed<23, TC, SAT> scfixed23;
198typedef CFixed<24, TC, SAT> scfixed24;
199typedef CFixed<25, TC, SAT> scfixed25;
200typedef CFixed<26, TC, SAT> scfixed26;
201typedef CFixed<27, TC, SAT> scfixed27;
202typedef CFixed<28, TC, SAT> scfixed28;
203typedef CFixed<29, TC, SAT> scfixed29;
204typedef CFixed<30, TC, SAT> scfixed30;
205typedef CFixed<31, TC, SAT> scfixed31;
206typedef CFixed<32, TC, SAT> scfixed32;
207typedef CFixed<33, TC, SAT> scfixed33;
208typedef CFixed<34, TC, SAT> scfixed34;
209typedef CFixed<35, TC, SAT> scfixed35;
210typedef CFixed<36, TC, SAT> scfixed36;
211typedef CFixed<37, TC, SAT> scfixed37;
212typedef CFixed<38, TC, SAT> scfixed38;
213typedef CFixed<39, TC, SAT> scfixed39;
214typedef CFixed<40, TC, SAT> scfixed40;
215typedef CFixed<41, TC, SAT> scfixed41;
216typedef CFixed<42, TC, SAT> scfixed42;
217typedef CFixed<43, TC, SAT> scfixed43;
218typedef CFixed<44, TC, SAT> scfixed44;
219typedef CFixed<45, TC, SAT> scfixed45;
220typedef CFixed<46, TC, SAT> scfixed46;
221typedef CFixed<47, TC, SAT> scfixed47;
222typedef CFixed<48, TC, SAT> scfixed48;
223typedef CFixed<49, TC, SAT> scfixed49;
224typedef CFixed<50, TC, SAT> scfixed50;
225typedef CFixed<51, TC, SAT> scfixed51;
226typedef CFixed<52, TC, SAT> scfixed52;
227typedef CFixed<53, TC, SAT> scfixed53;
228typedef CFixed<54, TC, SAT> scfixed54;
229typedef CFixed<55, TC, SAT> scfixed55;
230typedef CFixed<56, TC, SAT> scfixed56;
231typedef CFixed<57, TC, SAT> scfixed57;
232typedef CFixed<58, TC, SAT> scfixed58;
233typedef CFixed<59, TC, SAT> scfixed59;
234typedef CFixed<60, TC, SAT> scfixed60;
235typedef CFixed<61, TC, SAT> scfixed61;
236typedef CFixed<62, TC, SAT> scfixed62;
237typedef CFixed<63, TC, SAT> scfixed63;
238typedef CFixed<64, TC, SAT> scfixed64;
239
240// ----------------------------------------------------------------------
241// Instantiations
242// ----------------------------------------------------------------------
243ITPP_EXPORT_TEMPLATE template class ITPP_EXPORT CFixed<64, TC, WRAP>;
244
246
247} // namespace itpp
248
249#endif // #ifndef CFIXED_H
Definitions of a complex fixed-point data type CFix.
Complex fixed-point data type.
Definition cfix.h:52
fixrep im
Imaginary data part.
Definition cfix.h:162
fixrep re
Real data part.
Definition cfix.h:161
Templated complex fixed-point data type.
Definition cfixed.h:51
CFixed(std::complex< double > x, double, int s=0, Stat *ptr=0)
Constructor.
Definition cfixed.h:57
virtual ~CFixed()
Destructor.
Definition cfixed.h:69
CFixed(const CFix &x, double, Stat *ptr=0)
Constructor.
Definition cfixed.h:66
CFixed(const Fix &r, const Fix &i=0.0, Stat *ptr=0)
Constructor.
Definition cfixed.h:63
CFixed(Stat *ptr)
Constructor.
Definition cfixed.h:60
CFixed & operator=(const CFix &x)
Assignment from CFix.
Definition cfixed.h:72
CFixed & operator=(const Fix &x)
Assignment from Fix.
Definition cfixed.h:79
CFixed(double r=0.0, double i=0.0, int s=0, Stat *ptr=0)
Default constructor.
Definition cfixed.h:54
CFixed & operator=(const std::complex< double > &x)
Assignment from complex<double>. Fractional part is truncated.
Definition cfixed.h:86
CFixed & operator=(int x)
Assignment from int.
Definition cfixed.h:93
fixrep apply_o_mode(fixrep x) const
Handle overflows using overflow mode omode and make call to statistics object (if any)
Definition fix_base.cpp:88
int shift
Accumulated bitshift (positive means left-shifted, negative means right-shifted)
Definition fix_base.h:1021
Fixed-point data type.
Definition fix.h:52
fixrep re
Data representation.
Definition fix.h:137
A class for sampling a signal and calculating statistics.
Definition misc_stat.h:49
int64_t fixrep
Representation for fixed-point data types.
Definition fix_base.h:884
vec imag(const cvec &data)
Imaginary part of complex values.
vec real(const cvec &data)
Real part of complex values.
itpp namespace
Definition itmex.h:37
CFixed< 1, TC, WRAP > cfixed1
Typedefs for CFixed (cfixed1, cfixed2, ..., cfixed64)
Definition cfixed.h:105
SourceForge Logo

Generated on Tue Dec 10 2024 04:49:37 for IT++ by Doxygen 1.12.0