245 std::cout <<
"re = " <<
re << std::endl;
246 std::cout <<
"im = " <<
im << std::endl;
255 else if (x.
re == 0 && x.
im == 0)
257 else if (y.
re == 0 && y.
im == 0)
260 it_error(
"assert_shifts: Different shifts not allowed!");
271 else if (x.
re == 0 && x.
im == 0)
276 it_error(
"assert_shifts: Different shifts not allowed!");
284 && (y != 0),
"assert_shifts: Different shifts not allowed!");
290 std::complex<double> value;
292 if (!
is.eof() && (
is.peek() ==
'<')) {
295 if (
is.peek() ==
'<') {
339 it_error(
"operator<<: Illegal output mode!");
348 std::istringstream buffer(values);
349 int default_shift = 0, pos = 0, maxpos = 10;
352 default_shift =
data[0].get_shift();
355 while (buffer.peek() != EOF) {
356 switch (buffer.peek()) {
358 it_error(
"set: expressions with ':' are not valid for cfixvec");
369 data[pos-1].set_shift(default_shift);
370 buffer >>
data[pos-1];
371 while (buffer.peek() ==
' ') { buffer.get(); }
382 std::istringstream buffer(values);
383 int default_shift = 0,
rows = 0, maxrows = 10,
cols = 0, nocols = 0, maxcols = 10;
386 default_shift =
data[0].get_shift();
388 alloc(maxrows, maxcols);
389 while (buffer.peek() != EOF) {
391 if (
rows > maxrows) {
392 maxrows = maxrows * 2;
396 while ((buffer.peek() !=
';') && (buffer.peek() != EOF)) {
397 if (buffer.peek() ==
',') {
404 if (
cols > maxcols) {
405 maxcols = maxcols * 2;
411 while (buffer.peek() ==
' ') { buffer.get(); }
Definitions of a complex fixed-point data type CFix.
Complex fixed-point data type.
CFix & operator/=(const CFix &x)
Division with CFix using quantization mode TRN. Temporary variables use the maximum word length (64 b...
CFix operator-() const
Unary negative of CFix.
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...
virtual void print() const
Print restrictions.
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)
CFix & operator*=(const CFix &x)
Multiplication with CFix. Temporary variables use the maximum word length (64 bits)
void lshift(int n)
Left shift n bits.
CFix & operator<<=(const int n)
Left shift n bits.
CFix & operator-=(const CFix &x)
Subtraction of CFix.
fixrep get_re() const
Get data representation for real part (mainly for internal use since it reveals the representation ty...
CFix & operator+=(const CFix &x)
Addition of CFix.
void set_im(fixrep x)
Set data representation for imaginary part (mainly for internal use since it reveals the representati...
void rshift(int n)
Right shift n bits using quantization mode qmode (constructor argument)
std::complex< double > unfix() const
Conversion to std::complex<double>
CFix & operator>>=(const int n)
Right shift n bits using quantization mode qmode (constructor argument)
CFix & operator=(const CFix &x)
Assignment from CFix.
fixrep im
Imaginary data part.
void set(double real, double imag, int n)
Set to (real + i*imag) * pow2(n) using quantization mode qmode (constructor argument)
virtual void print() const
Print restrictions.
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()
fixrep rshift_and_apply_q_mode(fixrep x, int n) const
Right shift n bits using quantization mode qmode and make call to statistics object (if any)
output_mode get_output_mode() const
Get output mode.
void set_shift(int s)
Set shift (without shifting)
int get_shift() const
Get shift.
int shift
Accumulated bitshift (positive means left-shifted, negative means right-shifted)
fixrep re
Data representation.
void set_size(int rows, int cols, bool copy=false)
Set size of matrix. If copy = true then keep the data before resizing.
void set(const std::string &str)
Set matrix equal to values in the string str.
int rows() const
The number of rows.
Num_T * data
Protected data pointer.
int cols() const
The number of columns.
const Num_T & operator()(int r, int c) const
Get element (r,c) from matrix.
void alloc(int rows, int cols)
Allocate memory for the matrix.
int datasize
The current number of elements in the vector.
Num_T * data
A pointer to the data area.
void set_size(int size, bool copy=false)
Set length of vector. if copy = true then keeping the old values.
void alloc(int size)
Allocate storage for a vector of length size.
#define it_error_if(t, s)
Abort if t is true.
#define it_error(s)
Abort unconditionally.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
const double DOUBLE_POW2[128]
Table for fast multiplication by 2^(n-64)
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)
int64_t fixrep
Representation for fixed-point data types.
@ OUTPUT_FIX
Output fixed-point representation only.
@ OUTPUT_FLOAT
Output floating-point value.
@ OUTPUT_FIX_SHIFT
Output fixed-point representation followed by <shift> (default)
@ OUTPUT_FLOAT_SHIFT
Output floating-point value followed by <<shift.
vec imag(const cvec &data)
Imaginary part of complex values.
vec real(const cvec &data)
Real part of complex values.
Error handling functions - header file.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.