itpp::Fix_Factory Class Reference
Fixed-point Module

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

`#include <itpp/fixed/fix_factory.h>`

Inheritance diagram for itpp::Fix_Factory:

## 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

## 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 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);
itpp::Array
General array class.
Definition array.h:105
itpp::Fix_Factory
Class factory for fixed-point data types Fix and CFix.
Definition fix_factory.h:121
itpp::WRAP
@ WRAP
Wrap-around.
Definition fix_base.h:952
itpp::US
@ US
Unsigned.
Definition fix_base.h:944

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
itpp::SAT
@ SAT
Saturation.
Definition fix_base.h:949
itpp::TC
@ TC
Two's complement.
Definition fix_base.h:943
itpp::FIX1
const Fix_Factory FIX1(1, TC, WRAP)
Fix_Factories for signed Fix/CFix with wrap-around (FIX1, FIX2, ..., FIX64)
itpp::SFIX1
const Fix_Factory SFIX1(1, TC, SAT)
Fix_Factories for unsigned Fix/CFix with wrap-around (SFIX1, SFIX2, ..., SFIX64)
itpp::SUFIX1
const Fix_Factory SUFIX1(1, US, SAT)
Fix_Factories for unsigned Fix/CFix with saturation (SUFIX1, SUFIX2, ..., SUFIX64)
itpp::UFIX1
const Fix_Factory UFIX1(1, US, WRAP)
Fix_Factories for unsigned Fix/CFix with wrap-around (UFIX1, UFIX2, ..., UFIX64)

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);
itpp::Fix
Fixed-point data type.
Definition fix.h:52

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 120 of file fix_factory.h.

## Constructor & Destructor Documentation

## Fix_Factory()

itpp::Fix_Factory::Fix_Factory | ( | int | w = `MAX_WORDLEN`,
|  | e_mode | e = `TC`,
|  | o_mode | o = `WRAP`,
|  | q_mode | q = `TRN`,
|  | Stat * | ptr = `0`
| ) |  |

inlineexplicit

Constructor.

Definition at line 126 of file fix_factory.h.

## ~Fix_Factory()

virtual itpp::Fix_Factory::~Fix_Factory | ( |  | ) |

inlinevirtual

Destructor.

Definition at line 129 of file fix_factory.h.

## Member Function Documentation

## operator double()

itpp::Fix_Factory::operator double | ( |  | ) | const

inline

Conversion operator. Useful in templated code.

Definition at line 131 of file fix_factory.h.

## create() [1/2]

void itpp::Fix_Factory::create | ( | Fix *& | ptr,
|  | const int | n
| ) |  | const

virtual

Create an n-length array of Fix.

Definition at line 37 of file fix_factory.cpp.

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

## create() [2/2]

void itpp::Fix_Factory::create | ( | CFix *& | ptr,
|  | const int | n
| ) |  | const

virtual

Create an n-length array of CFix.

Definition at line 47 of file fix_factory.cpp.

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

## Friends And Related Symbol Documentation

## Fix

friend class Fix

friend

Definition at line 122 of file fix_factory.h.

## CFix

friend class CFix

friend

Definition at line 123 of file fix_factory.h.

## Member Data Documentation

## wordlen

int itpp::Fix_Factory::wordlen

protected

Word length.

Definition at line 138 of file fix_factory.h.

Referenced by create(), and create().

## emode

e_mode itpp::Fix_Factory::emode

protected

Sign encoding mode.

Definition at line 140 of file fix_factory.h.

Referenced by create(), and create().

## omode

o_mode itpp::Fix_Factory::omode

protected

Overflow mode.

Definition at line 142 of file fix_factory.h.

Referenced by create(), and create().

## qmode

q_mode itpp::Fix_Factory::qmode

protected

Quantization mode.

Definition at line 144 of file fix_factory.h.

Referenced by create(), and create().

## stat_ptr

Stat* itpp::Fix_Factory::stat_ptr

protected

Pointer to statistics object.

Definition at line 146 of file fix_factory.h.

Referenced by create(), and create().

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

- itpp/fixed/fix_factory.h
- itpp/fixed/fix_factory.cpp

Generated on Mon Jun 10 2024 11:49:35 for IT++ by Doxygen 1.9.8