33#include <itpp/itexports.h>
40template<
class Num_T>
class Vec;
41template<
class Num_T>
class Mat;
53 template<
int, e_mode, o_mode, q_mode>
friend class CFixed;
81 CFix& operator=(
const std::complex<double> &x);
83 CFix& operator=(
const int x);
89 CFix& operator+=(
const int x);
95 CFix& operator-=(
const int x);
101 CFix& operator*=(
const int x);
105 CFix& operator/=(
const Fix &x);
107 CFix& operator/=(
const int x);
111 CFix& operator<<=(
const int n);
113 CFix& operator>>=(
const int n);
116 void set(
double real,
double imag,
int n);
120 void set(
const std::complex<double> &x,
int n);
122 void set(
const std::complex<double> &x,
int n,
q_mode q);
133 void rshift(
int n,
q_mode q);
136 virtual void print()
const;
142 std::complex<double>
unfix()
const;
144#ifndef NO_IMPLICIT_FIX_CONVERSION
146 operator std::complex<double>()
const {
175ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const CFix &x);
Complex fixed-point data type.
fixrep get_im() const
Get data representation for imaginary part (mainly for internal use since it reveals the representati...
void set_re(fixrep x)
Set data representation for real part (mainly for internal use since it reveals the representation ty...
CFix(const Fix &r, const Fix &i=0.0, int w=MAX_WORDLEN, e_mode e=TC, o_mode o=WRAP, q_mode q=TRN, Stat *ptr=0)
Constructor.
friend ITPP_EXPORT 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)
virtual ~CFix()
Destructor.
fixrep get_re() const
Get data representation for real part (mainly for internal use since it reveals the representation ty...
CFix(double r=0.0, double i=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_im(fixrep x)
Set data representation for imaginary part (mainly for internal use since it reveals the representati...
CFix(const Fix_Factory &f)
Constructor.
CFix(const CFix &x, double, int w=MAX_WORDLEN, e_mode e=TC, o_mode o=WRAP, q_mode q=TRN, Stat *ptr=0)
Copy constructor.
CFix(std::complex< double > x, double, int s=0, int w=MAX_WORDLEN, e_mode e=TC, o_mode o=WRAP, q_mode q=TRN, Stat *ptr=0)
Constructor.
fixrep im
Imaginary data part.
CFix(fixrep r, fixrep i, int s, int, int)
Constructor for internal use. No restrictions are applied. The dummies help to avoid ambiguities.
Fix_Base(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 apply_o_mode(fixrep x) const
Handle overflows using overflow mode omode and make call to statistics object (if any)
fixrep scale_and_apply_modes(double x) const
Convert from double to fixrep using shift and quantization mode qmode, then call limit()
e_mode emode
Sign encoding mode.
Stat * stat_ptr
Pointer to statistics object.
int shift
Accumulated bitshift (positive means left-shifted, negative means right-shifted)
q_mode qmode
Quantization mode.
o_mode omode
Overflow mode.
Class factory for fixed-point data types Fix and CFix.
void set(const std::string &str)
A class for sampling a signal and calculating statistics.
void set(const char *str)
Definitions of a fixed-point data type Fix.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
Vec< CFix > cfixvec
Typedef for complex fixed-point vector type.
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)
Mat< CFix > cfixmat
Typedef for complex fixed-point matrix type.
q_mode
Quantization modes (aligned with SystemC)
int64_t fixrep
Representation for fixed-point data types.
vec imag(const cvec &data)
Imaginary part of complex values.
vec real(const cvec &data)
Real part of complex values.
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.