IT++ Logo
fix_operators.h
Go to the documentation of this file.
1
30#ifndef FIX_OPERATORS_H
31#define FIX_OPERATORS_H
32
33#include <itpp/fixed/cfix.h>
35#include <itpp/itexports.h>
36
37
38namespace itpp
39{
40
43
45// Operators for Fix and Fixed //
47
49ITPP_EXPORT Fix operator+(const Fix &x, const Fix &y);
51ITPP_EXPORT Fix operator-(const Fix &x, const Fix &y);
53ITPP_EXPORT Fix operator*(const Fix &x, const Fix &y);
55ITPP_EXPORT Fix operator/(const Fix &x, const Fix &y);
56
58ITPP_EXPORT Fix operator+(const Fix &x, const int y);
60ITPP_EXPORT Fix operator-(const Fix &x, const int y);
62ITPP_EXPORT Fix operator*(const Fix &x, const int y);
64ITPP_EXPORT Fix operator/(const Fix &x, const int y);
66ITPP_EXPORT Fix operator+(const int x, const Fix &y);
68ITPP_EXPORT Fix operator-(const int x, const Fix &y);
70ITPP_EXPORT Fix operator*(const int x, const Fix &y);
72ITPP_EXPORT Fix operator/(const int x, const Fix &y);
73
75inline fixvec operator+(const fixvec &v, const int s) {return v + Fix(s);}
77inline fixvec operator+(const int s, const fixvec &v) {return Fix(s) + v;}
79inline fixvec operator-(const fixvec &v, const int s) {return v - Fix(s);}
81inline fixvec operator-(const int s, const fixvec &v) {return Fix(s) - v;}
83inline fixvec operator*(const fixvec &v, const int s) {return v * Fix(s);}
85inline fixvec operator*(const int s, const fixvec &v) {return Fix(s) * v;}
87inline fixvec operator/(const fixvec &v, const int s) {return v / Fix(s);}
88
90inline fixmat operator+(const fixmat &v, const int s) {return v + Fix(s);}
92inline fixmat operator+(const int s, const fixmat &v) {return Fix(s) + v;}
94inline fixmat operator-(const fixmat &v, const int s) {return v - Fix(s);}
96inline fixmat operator-(const int s, const fixmat &v) {return Fix(s) - v;}
98inline fixmat operator*(const fixmat &v, const int s) {return v * Fix(s);}
100inline fixmat operator*(const int s, const fixmat &v) {return Fix(s) * v;}
102inline fixmat operator/(const fixmat &v, const int s) {return v / Fix(s);}
103
105ITPP_EXPORT fixvec operator+(const fixvec &a, const ivec &b);
107inline fixvec operator+(const ivec &a, const fixvec &b) {return b + a;}
109inline fixvec operator-(const fixvec &a, const ivec &b) {return a + (-b);}
111inline fixvec operator-(const ivec &a, const fixvec &b) {return (-b) + a;}
113ITPP_EXPORT Fix operator*(const fixvec &a, const ivec &b);
115inline Fix operator*(const ivec &a, const fixvec &b) {return b*a;}
116
118ITPP_EXPORT fixmat operator+(const fixmat &a, const imat &b);
120inline fixmat operator+(const imat &a, const fixmat &b) {return b + a;}
122inline fixmat operator-(const fixmat &a, const imat &b) {return a + (-b);}
124inline fixmat operator-(const imat &a, const fixmat &b) {return (-b) + a;}
126ITPP_EXPORT fixmat operator*(const fixmat &a, const imat &b);
128inline fixmat operator*(const imat &a, const fixmat &b) {return b*a;}
129
131// Operators for CFix and CFixed //
133
135ITPP_EXPORT CFix operator+(const CFix &x, const CFix &y);
137ITPP_EXPORT CFix operator-(const CFix &x, const CFix &y);
139ITPP_EXPORT CFix operator*(const CFix &x, const CFix &y);
141ITPP_EXPORT CFix operator/(const CFix &x, const CFix &y);
142
144ITPP_EXPORT CFix operator+(const CFix &x, const Fix &y);
146ITPP_EXPORT CFix operator-(const CFix &x, const Fix &y);
148ITPP_EXPORT CFix operator*(const CFix &x, const Fix &y);
150ITPP_EXPORT CFix operator/(const CFix &x, const Fix &y);
152ITPP_EXPORT CFix operator+(const Fix &x, const CFix &y);
154ITPP_EXPORT CFix operator-(const Fix &x, const CFix &y);
156ITPP_EXPORT CFix operator*(const Fix &x, const CFix &y);
158ITPP_EXPORT CFix operator/(const Fix &x, const CFix &y);
159
161ITPP_EXPORT CFix operator+(const CFix &x, const int y);
163ITPP_EXPORT CFix operator-(const CFix &x, const int y);
165ITPP_EXPORT CFix operator*(const CFix &x, const int y);
167ITPP_EXPORT CFix operator/(const CFix &x, const int y);
169ITPP_EXPORT CFix operator+(const int x, const CFix &y);
171ITPP_EXPORT CFix operator-(const int x, const CFix &y);
173ITPP_EXPORT CFix operator*(const int x, const CFix &y);
175ITPP_EXPORT CFix operator/(const int x, const CFix &y);
176
178inline cfixvec operator+(const fixvec &v, const CFix &s) {return to<CFix>(v) + s;}
180inline cfixvec operator+(const CFix &s, const fixvec &v) {return s + to<CFix>(v);}
182inline cfixvec operator-(const fixvec &v, const CFix &s) {return to<CFix>(v) - s;}
184inline cfixvec operator-(const CFix &s, const fixvec &v) {return s - to<CFix>(v);}
186inline cfixvec operator*(const fixvec &v, const CFix &s) {return to<CFix>(v) * s;}
188inline cfixvec operator*(const CFix &s, const fixvec &v) {return s * to<CFix>(v);}
190inline cfixvec operator/(const fixvec &v, const CFix &s) {return to<CFix>(v) / s;}
191
193inline cfixmat operator+(const fixmat &m, const CFix &s) {return to<CFix>(m) + s;}
195inline cfixmat operator+(const CFix &s, const fixmat &m) {return s + to<CFix>(m);}
197inline cfixmat operator-(const fixmat &m, const CFix &s) {return to<CFix>(m) - s;}
199inline cfixmat operator-(const CFix &s, const fixmat &m) {return s - to<CFix>(m);}
201inline cfixmat operator*(const fixmat &m, const CFix &s) {return to<CFix>(m) * s;}
203inline cfixmat operator*(const CFix &s, const fixmat &m) {return s * to<CFix>(m);}
205inline cfixmat operator/(const fixmat &m, const CFix &s) {return to<CFix>(m) / s;}
206
208inline cfixvec operator+(const ivec &v, const CFix &s) {return to<CFix>(to_vec(v)) + s;}
210inline cfixvec operator+(const CFix &s, const ivec &v) {return s + to<CFix>(to_vec(v));}
212inline cfixvec operator-(const ivec &v, const CFix &s) {return to<CFix>(to_vec(v)) - s;}
214inline cfixvec operator-(const CFix &s, const ivec &v) {return s - to<CFix>(to_vec(v));}
216inline cfixvec operator*(const ivec &v, const CFix &s) {return to<CFix>(to_vec(v)) * s;}
218inline cfixvec operator*(const CFix &s, const ivec &v) {return s * to<CFix>(to_vec(v));}
220inline cfixvec operator/(const ivec &v, const CFix &s) {return to<CFix>(to_vec(v)) / s;}
221
223inline cfixmat operator+(const imat &m, const CFix &s) {return to<CFix>(to_mat(m)) + s;}
225inline cfixmat operator+(const CFix &s, const imat &m) {return s + to<CFix>(to_mat(m));}
227inline cfixmat operator-(const imat &m, const CFix &s) {return to<CFix>(to_mat(m)) - s;}
229inline cfixmat operator-(const CFix &s, const imat &m) {return s - to<CFix>(to_mat(m));}
231inline cfixmat operator*(const imat &m, const CFix &s) {return to<CFix>(to_mat(m)) * s;}
233inline cfixmat operator*(const CFix &s, const imat &m) {return s * to<CFix>(to_mat(m));}
235inline cfixmat operator/(const imat &m, const CFix &s) {return to<CFix>(to_mat(m)) / s;}
236
238inline cfixvec operator+(const cfixvec &v, const Fix &s) {return v + CFix(s);}
240inline cfixvec operator+(const Fix &s, const cfixvec &v) {return CFix(s) + v;}
242inline cfixvec operator-(const cfixvec &v, const Fix &s) {return v - CFix(s);}
244inline cfixvec operator-(const Fix &s, const cfixvec &v) {return CFix(s) - v;}
246inline cfixvec operator*(const cfixvec &v, const Fix &s) {return v * CFix(s);}
248inline cfixvec operator*(const Fix &s, const cfixvec &v) {return CFix(s) * v;}
250inline cfixvec operator/(const cfixvec &v, const Fix &s) {return v / CFix(s);}
251
253inline cfixmat operator+(const cfixmat &m, const Fix &s) {return m + CFix(s);}
255inline cfixmat operator+(const Fix &s, const cfixmat &m) {return CFix(s) + m;}
257inline cfixmat operator-(const cfixmat &m, const Fix &s) {return m - CFix(s);}
259inline cfixmat operator-(const Fix &s, const cfixmat &m) {return CFix(s) - m;}
261inline cfixmat operator*(const cfixmat &m, const Fix &s) {return m * CFix(s);}
263inline cfixmat operator*(const Fix &s, const cfixmat &m) {return CFix(s) * m;}
265inline cfixmat operator/(const cfixmat &m, const Fix &s) {return m / CFix(s);}
266
268inline cfixvec operator+(const cfixvec &v, const int s) {return v + CFix(s);}
270inline cfixvec operator+(const int s, const cfixvec &v) {return CFix(s) + v;}
272inline cfixvec operator-(const cfixvec &v, const int s) {return v - CFix(s);}
274inline cfixvec operator-(const int s, const cfixvec &v) {return CFix(s) - v;}
276inline cfixvec operator*(const cfixvec &v, const int s) {return v * CFix(s);}
278inline cfixvec operator*(const int s, const cfixvec &v) {return CFix(s) * v;}
280inline cfixvec operator/(const cfixvec &v, const int s) {return v / CFix(s);}
281
283inline cfixmat operator+(const cfixmat &m, const int s) {return m + CFix(s);}
285inline cfixmat operator+(const int s, const cfixmat &m) {return CFix(s) + m;}
287inline cfixmat operator-(const cfixmat &m, const int s) {return m - CFix(s);}
289inline cfixmat operator-(const int s, const cfixmat &m) {return CFix(s) - m;}
291inline cfixmat operator*(const cfixmat &m, const int s) {return m * CFix(s);}
293inline cfixmat operator*(const int s, const cfixmat &m) {return CFix(s) * m;}
295inline cfixmat operator/(const cfixmat &m, const int s) {return m / CFix(s);}
296
298ITPP_EXPORT cfixvec operator+(const cfixvec &a, const fixvec &b);
300inline cfixvec operator+(const fixvec &a, const cfixvec &b) {return b + a;}
302inline cfixvec operator-(const cfixvec &a, const fixvec &b) {return a + (-b);}
304inline cfixvec operator-(const fixvec &a, const cfixvec &b) {return (-b) + a;}
306ITPP_EXPORT CFix operator*(const cfixvec &a, const fixvec &b);
308inline CFix operator*(const fixvec &a, const cfixvec &b) {return b*a;}
309
311ITPP_EXPORT cfixmat operator+(const cfixmat &a, const fixmat &b);
313inline cfixmat operator+(const fixmat &a, const cfixmat &b) {return b + a;}
315inline cfixmat operator-(const cfixmat &a, const fixmat &b) {return a + (-b);}
317inline cfixmat operator-(const fixmat &a, const cfixmat &b) {return (-b) + a;}
319ITPP_EXPORT cfixmat operator*(const cfixmat &a, const fixmat &b);
321inline cfixmat operator*(const fixmat &a, const cfixmat &b) {return b*a;}
322
324ITPP_EXPORT cfixvec operator+(const cfixvec &a, const ivec &b);
326inline cfixvec operator+(const ivec &a, const cfixvec &b) {return b + a;}
328inline cfixvec operator-(const cfixvec &a, const ivec &b) {return a + (-b);}
330inline cfixvec operator-(const ivec &a, const cfixvec &b) {return (-b) + a;}
332ITPP_EXPORT CFix operator*(const cfixvec &a, const ivec &b);
334inline CFix operator*(const ivec &a, const cfixvec &b) {return b*a;}
335
337ITPP_EXPORT cfixmat operator+(const cfixmat &a, const imat &b);
339inline cfixmat operator+(const imat &a, const cfixmat &b) {return b + a;}
341inline cfixmat operator-(const cfixmat &a, const imat &b) {return a + (-b);}
343inline cfixmat operator-(const imat &a, const cfixmat &b) {return (-b) + a;}
345ITPP_EXPORT cfixmat operator*(const cfixmat &a, const imat &b);
347inline cfixmat operator*(const imat &a, const cfixmat &b) {return b*a;}
348
350
351} // namespace itpp
352
353#endif // #ifndef FIX_OPERATORS_H
Definitions of a complex fixed-point data type CFix.
General array class.
Definition array.h:105
Complex fixed-point data type.
Definition cfix.h:52
Fixed-point data type.
Definition fix.h:52
Matrix Class (Templated)
Definition mat.h:202
Vector Class (Templated)
Definition vec.h:245
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
cfixvec to< CFix >(const cfixvec &x)
Convert cfixvec to cfixvec.
Mat< Fix > fixmat
Typedef for fixed-point matrix type.
Definition fix.h:153
Vec< Fix > fixvec
Typedef for fixed-point vector type.
Definition fix.h:151
itpp namespace
Definition itmex.h:37
Mat< Num_T > operator-(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Subtraction of two matrices.
Definition mat.h:1382
GF2mat operator*(const GF2mat &X, const GF2mat &Y)
GF(2) matrix multiplication.
Definition gf2mat.cpp:847
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
Mat< Num_T > operator/(const Mat< Num_T > &m, Num_T t)
Element-wise division by a scalar.
Definition mat.h:1670
GF2mat operator+(const GF2mat &X, const GF2mat &Y)
GF(2) matrix addition.
Definition gf2mat.cpp:948

Generated on Tue Aug 17 2021 10:59:15 for IT++ by Doxygen 1.9.8