IT++ Logo Newcom Logo

itpp::Fix_Factory Class Reference
[Fixed-Point Data Types]

Class factory for fixed-point data types Fix and CFix. More...

#include <itpp/fixedpoint/fix_factory.h>

Inheritance diagram for itpp::Fix_Factory:

itpp::Factory List of all members.

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.
Statstat_ptr
 Pointer to statistics object.

Friends

class Fix
class CFix

Detailed Description

Class factory for fixed-point data types Fix and 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 Data Types 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
This means that it is only necessary for the user to declare a Fix_Factory if it is desired to have some other overflow mode than WRAP or SAT, or some other quantization mode than TRN, or a non-zero statistics object pointer.

Note:
U stands for Unsigned but S stands for Saturated, NOT for Signed.
The Array/Vec/Mat constructors can take a Fix_Factory as an argument:
    // 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);                     
which can be useful in templated code, e.g. when the same code should support both floating- and fixed-point data types.

Definition at line 122 of file fix_factory.h.


Constructor & Destructor Documentation

itpp::Fix_Factory::Fix_Factory ( int  w = MAX_WORDLEN,
e_mode  e = TC,
o_mode  o = WRAP,
q_mode  q = TRN,
Stat ptr = 0 
) [inline, explicit]

Constructor.

Definition at line 127 of file fix_factory.h.

virtual itpp::Fix_Factory::~Fix_Factory (  )  [inline, virtual]

Destructor.

Definition at line 130 of file fix_factory.h.


Member Function Documentation

itpp::Fix_Factory::operator double (  )  const [inline]

Conversion operator. Useful in templated code.

Definition at line 132 of file fix_factory.h.

void itpp::Fix_Factory::create ( Fix *&  ptr,
const int  n 
) const [virtual]

Create an n-length array of Fix.

Definition at line 40 of file fix_factory.cpp.

References emode, Fix, omode, qmode, stat_ptr, and wordlen.

void itpp::Fix_Factory::create ( CFix *&  ptr,
const int  n 
) const [virtual]

Create an n-length array of CFix.

Definition at line 52 of file fix_factory.cpp.

References CFix, emode, omode, qmode, stat_ptr, and wordlen.


Member Data Documentation

int itpp::Fix_Factory::wordlen [protected]

Word length.

Definition at line 139 of file fix_factory.h.

Referenced by create().

e_mode itpp::Fix_Factory::emode [protected]

Sign encoding mode.

Definition at line 141 of file fix_factory.h.

Referenced by create().

o_mode itpp::Fix_Factory::omode [protected]

Overflow mode.

Definition at line 143 of file fix_factory.h.

Referenced by create().

q_mode itpp::Fix_Factory::qmode [protected]

Quantization mode.

Definition at line 145 of file fix_factory.h.

Referenced by create().

Stat* itpp::Fix_Factory::stat_ptr [protected]

Pointer to statistics object.

Definition at line 147 of file fix_factory.h.

Referenced by create().


The documentation for this class was generated from the following files:
SourceForge Logo

Generated on Fri Jun 8 02:09:06 2007 for IT++ by Doxygen 1.5.2