34 #include <itpp/itexports.h> 40 template<
class Num_T>
class Vec;
41 template<
class Num_T>
class Mat;
54 template<
int, e_mode, o_mode, q_mode>
friend class Fixed;
55 template<
int, e_mode, o_mode, q_mode>
friend class CFixed;
59 :
Fix_Base(s, w, e, o, q, ptr), re(scale_and_apply_modes(x)) {}
62 :
Fix_Base(0, f.wordlen, f.emode, f.omode, f.qmode, f.stat_ptr), re(0) {}
68 :
Fix_Base(x.shift, w, e, o, q, ptr), re(x.re) {}
73 Fix& operator=(
const Fix &x);
75 Fix& operator=(
const int x);
77 Fix& operator+=(
const Fix &x);
79 Fix& operator+=(
const int x);
81 Fix& operator-=(
const Fix &x);
83 Fix& operator-=(
const int x);
85 Fix& operator*=(
const Fix &x);
87 Fix& operator*=(
const int x);
89 Fix& operator/=(
const Fix &x);
91 Fix& operator/=(
const int x);
95 Fix& operator<<=(
const int n);
97 Fix& operator>>=(
const int n);
100 void set(
double x,
int n);
102 void set(
double x,
int n,
q_mode q);
111 void rshift(
int n,
q_mode q);
114 virtual void print()
const;
118 double unfix()
const;
120 #ifndef NO_IMPLICIT_FIX_CONVERSION 121 operator double()
const {
123 it_assert_debug(shift>=-63 && shift <= 64,
"Fix::operator double: Illegal shift!");
146 ITPP_EXPORT std::istream &
operator>>(std::istream &is,
Fix &x);
148 ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const Fix &x);
164 #endif // #ifndef FIX_H Templated fixed-point data type.
Templated complex fixed-point data type.
Definitions of a base class for fixed-point data types.
Fix(double x=0.0, int s=0, int w=MAX_WORDLEN, e_mode e=TC, o_mode o=WRAP, q_mode q=TRN, Stat *ptr=0)
Default constructor.
void set(const char *str)
Set the vector equal to the values in the str string.
Definitions of a class factory for fixed-point data types Fix and CFix.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
void set(const std::string &str)
Set matrix equal to values in the string str.
Class factory for fixed-point data types Fix and CFix.
fixrep re
Data representation.
double unfix(const Fix &x)
Convert Fix to double by multiplying the bit representation with pow2(-shift)
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
fixrep get_re() const
Get data representation (mainly for internal use since it reveals the representation type) ...
virtual ~Fix()
Destructor.
const double DOUBLE_POW2[128]
Table for fast multiplication by 2^(n-64)
Complex fixed-point data type.
Mat< Num_T > operator-(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Subtraction of two matrices.
e_mode
Sign encoding modes (aligned with SystemC)
o_mode
Overflow modes (aligned with SystemC)
const int MAX_WORDLEN
Max word length.
Fix(const Fix &x, int w=MAX_WORDLEN, e_mode e=TC, o_mode o=WRAP, q_mode q=TRN, Stat *ptr=0)
Copy constructor.
Base class for fixed-point data types.
int assert_shifts(const CFix &x, const CFix &y)
Check that x.shift==y.shift OR x==0 OR y==0 and return the shift (for the non-zero argument) ...
Fix(const Fix_Factory &f)
Constructor.
int64_t fixrep
Representation for fixed-point data types.
Mat< Fix > fixmat
Typedef for fixed-point matrix type.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
A class for sampling a signal and calculating statistics.
Fix(fixrep r, int s, int, int)
Constructor for internal use. No restrictions are applied. The dummies help to avoid ambiguities...
q_mode
Quantization modes (aligned with SystemC)
Vec< Fix > fixvec
Typedef for fixed-point vector type.
void set_re(fixrep x)
Set data representation (mainly for internal use since it reveals the representation type) ...