#include <fix_factory.h>
Public Member Functions | |
Fix_Factory (int w=MAX_WORDLEN, e_mode e=TC, o_mode o=WRAP, q_mode q=TRN, Stat *ptr=0) | |
Constructor. | |
virtual | ~Fix_Factory () |
Destructor. | |
operator double () const | |
Conversion operator. Useful in templated code. | |
virtual void | create (Fix *&ptr, const int n) const |
Create an n-length array of Fix. | |
virtual void | create (CFix *&ptr, const int n) const |
Create an n-length array of CFix. | |
Protected Attributes | |
int | wordlen |
Word length. | |
e_mode | emode |
Sign encoding mode. | |
o_mode | omode |
Overflow mode. | |
q_mode | qmode |
Quantization mode. | |
Stat * | stat_ptr |
Pointer to statistics object. | |
Friends | |
class | Fix |
class | CFix |
For an introduction to factories, see the Detailed Description for Factory. For more information on the fixed-point data types, see the Detailed Description in the Fixed-point Module module.
This example shows how to declare a Fix_Factory:
// Declare UFIX32, a factory for 32-bit unsigned Fix/CFix with wrap-around // i.e. a factory for Fix(0.0, 0, 32, US, WRAP) and CFix(0.0, 0, 32, US, WRAP) Fix_Factory UFIX32(32, US, WRAP);
However, the user does not need to declare UFIX32
since it is one of the already declared factories in fix_factory.h (which is included by itbase.h):
Fix_Factory FIX1(1, TC, WRAP); // for Fix/CFix with 1 bit ... Fix_Factory FIX64(64, TC, WRAP); // for Fix/CFix with 64 bits Fix_Factory UFIX1(1, US, WRAP); // for Unsigned Fix/CFix with 1 bit ... Fix_Factory UFIX64(64, US, WRAP); // for Unsigned Fix/CFix with 64 bits Fix_Factory SFIX1(1, TC, SAT); // for Saturated Fix/CFix with 1 bit ... Fix_Factory SFIX64(64, TC, SAT); // for Saturated Fix/CFix with 64 bits Fix_Factory SUFIX1(1, US, SAT); // for Saturated Unsigned Fix/CFix with 1 bit ... Fix_Factory SUFIX64(64, US, SAT); // for Saturated Unsigned Fix/CFix with 64 bits
WRAP
or SAT
, or some other quantization mode than TRN
, or a non-zero statistics object pointer.
// Declare a Vec<Fix> with size 10 that will use // Fix(0.0, 0, 32, US, WRAP) for element creation Vec<Fix> vf(10, UFIX32); // Declare an Array<Array<Mat<CFix> > > with size 10 that will use // CFix(0.0, 0, 32, US, WRAP) for element creation Array<Array<Mat<CFix> > > aamcf(10, UFIX32);
Even a Fix/CFix declaration can take a Fix_Factory as a constructor argument:
// Equivalent to // Fix f(0.0, 0, 32, US, WRAP); Fix f(UFIX32);
This syntax is also legal if Fix is replaced with double
and CFix is replaced with complex<double>
, i.e.
// The factory will be ignored Vec<double> vd(10, UFIX32); // The factory will be ignored Array<Array<Mat<complex<double> > > > aamcd(10, UFIX32); // The factory will be converted to double(0.0) i.e. innocent initialization double d(UFIX32);