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
122 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);
Complex fixed-point data type.
Templated complex fixed-point data type.
Base class for fixed-point data types.
Class factory for fixed-point data types Fix and CFix.
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.
fixrep re
Data representation.
Fix(const Fix_Factory &f)
Constructor.
fixrep get_re() const
Get data representation (mainly for internal use since it reveals the representation type)
Fix(fixrep r, int s, int, int)
Constructor for internal use. No restrictions are applied. The dummies help to avoid ambiguities.
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.
void set_re(fixrep x)
Set data representation (mainly for internal use since it reveals the representation type)
virtual ~Fix()
Destructor.
Templated fixed-point data type.
void set(const std::string &str)
Set matrix equal to values in the string str.
A class for sampling a signal and calculating statistics.
Definitions of a base class for fixed-point data types.
Definitions of a class factory for fixed-point data types Fix and CFix.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
const int MAX_WORDLEN
Max word length.
o_mode
Overflow modes (aligned with SystemC)
const double DOUBLE_POW2[128]
Table for fast multiplication by 2^(n-64)
e_mode
Sign encoding modes (aligned with SystemC)
double unfix(const Fix &x)
Convert Fix to double by multiplying the bit representation with pow2(-shift)
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)
void set(const char *str)
Set the vector equal to the values in the str string.
q_mode
Quantization modes (aligned with SystemC)
Mat< Fix > fixmat
Typedef for fixed-point matrix type.
int64_t fixrep
Representation for fixed-point data types.
Vec< Fix > fixvec
Typedef for fixed-point vector type.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
Mat< Num_T > operator-(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Subtraction of two matrices.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.