166 std::cout <<
"re = " <<
re << std::endl;
180 it_error(
"assert_shifts: Different shifts not allowed!");
188 "assert_shifts: Different shifts not allowed!");
196 if (!is.eof() && (is.peek() ==
'<')) {
199 if (is.peek() ==
'<') {
231 os << double(x) <<
"<<" << x.
get_shift();
234 it_error(
"operator<<: Illegal output mode!");
243 std::istringstream buffer(values);
245 int default_shift = 0, pos = 0, maxpos = 10;
248 default_shift = data[0].get_shift();
251 while (buffer.peek() != EOF) {
252 switch (buffer.peek()) {
258 if (!buffer.eof() && buffer.peek() ==
':') {
262 while (
int(
double(data[pos-1])) + b - c <= 0) {
266 set_size(maxpos,
true);
268 data[pos-1] = data[pos-2];
274 while (
int(
double(data[pos-1])) < b) {
278 set_size(maxpos,
true);
280 data[pos-1] = data[pos-2];
292 set_size(maxpos,
true);
294 data[pos-1].set_shift(default_shift);
295 buffer >> data[pos-1];
296 while (buffer.peek() ==
' ') { buffer.get(); }
307 std::istringstream buffer(values);
308 int default_shift = 0, rows = 0, maxrows = 10, cols = 0, nocols = 0, maxcols = 10;
311 default_shift = data[0].get_shift();
313 alloc(maxrows, maxcols);
314 while (buffer.peek() != EOF) {
316 if (rows > maxrows) {
317 maxrows = maxrows * 2;
318 set_size(maxrows, maxcols,
true);
321 while ((buffer.peek() !=
';') && (buffer.peek() != EOF)) {
322 if (buffer.peek() ==
',') {
329 if (cols > maxcols) {
330 maxcols = maxcols * 2;
331 set_size(maxrows, maxcols,
true);
334 this->operator()(rows-1, cols - 1).set_shift(default_shift);
335 buffer >> this->operator()(rows-1, cols - 1);
336 while (buffer.peek() ==
' ') { buffer.get(); }
342 set_size(rows, nocols,
true);
#define it_error_if(t, s)
Abort if t is true.
output_mode get_output_mode() const
Get output mode.
virtual void print() const
Print restrictions.
Fix & operator>>=(const int n)
Right shift n bits using quantization mode qmode (constructor argument)
fixrep scale_and_apply_modes(double x) const
Convert from double to fixrep using shift and quantization mode qmode, then call limit() ...
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.
Output floating-point value.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
void set(double x, int n)
Set to x * pow2(n) using quantization mode qmode (constructor argument)
void set_shift(int s)
Set shift (without shifting)
fixrep apply_o_mode(fixrep x) const
Handle overflows using overflow mode omode and make call to statistics object (if any) ...
Fix & operator=(const Fix &x)
Assignment from Fix.
void set(const std::string &str)
Set matrix equal to values in the string str.
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) ...
fixrep re
Data representation.
double unfix() const
Conversion to double.
Fix & operator<<=(const int n)
Left shift n bits.
Fix & operator*=(const Fix &x)
Multiplication with Fix.
#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) ...
void lshift(int n)
Left shift n bits.
const double DOUBLE_POW2[128]
Table for fast multiplication by 2^(n-64)
Output fixed-point representation only.
void rshift(int n)
Right shift n bits using quantization mode qmode (constructor argument)
friend ITPP_EXPORT int assert_shifts(const CFix &x, const Fix &y)
Check that x.shift==y.shift OR x==0 OR y==0 and return the shift (for the non-zero argument) ...
Fix operator-() const
Unary negative of Fix.
int shift
Accumulated bitshift (positive means left-shifted, negative means right-shifted)
Error handling functions - header file.
Output floating-point value followed by <<shift.
Fix & operator-=(const Fix &x)
Subtraction of Fix.
Fix & operator/=(const Fix &x)
Division with Fix using quantization mode TRN.
Definitions of a fixed-point data type Fix.
#define it_error(s)
Abort unconditionally.
int64_t fixrep
Representation for fixed-point data types.
Fix & operator+=(const Fix &x)
Addition of Fix.
Output fixed-point representation followed by <shift> (default)
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
q_mode
Quantization modes (aligned with SystemC)
void set_re(fixrep x)
Set data representation (mainly for internal use since it reveals the representation type) ...
int get_shift() const
Get shift.
virtual void print() const
Print restrictions.