// // Programmer: Craig Stuart Sapp // Creation Date: Sun Jan 19 20:25:24 PST 1997 // Last Modified: Sun Apr 12 22:18:04 PDT 1998 // Last Modified: Tue Jan 26 12:15:04 PST 2010 (added (De)QuantizeFloat2) // Last Modified: Tue Jan 26 12:15:04 PST 2010 (added printCodeQuartet) // Filename: ...sig/maint/code/utilities/quantization.h // Web Address: http://sig.sapp.org/include/sig/quantization.h // Syntax: C++ // #ifndef _QUANTIZATION_H_INCLUDED #define _QUANTIZATION_H_INCLUDED #ifndef OLDCPP #include using namespace std; #else #include #endif struct linearcode { int bits; // number of bits used to quantize number int sign; // sign represents the highest bit of code long code; // code without the sign bit (max 32 bits) }; typedef struct linearcode LinearCode; struct floatcode { int Rs; // number of scale (exponent) bits int Rm; // number of mantissa bits long scale; // storage space for the scale bits (max 32 bits) int sign; // sign represents the highest bit of the mantissa long mantissa; // mantissa without the sign bit (max 32 bits) }; typedef struct floatcode FloatCode; ////////////////////////////// // // printCode -- prints a quantized number code in base-2 form. // The sign is the first digit. // void printCode(LinearCode x, int dec = 0); ////////////////////////////// // // printCodeQuartet -- prints a quantized number code in base-2 form. // The sign is the first digit. Place a space after every 4 bits. // void printCodeQuartet(LinearCode x, int dec = 0); ////////////////////////////// // // printFloatCode -- prints a quantized number code in base-2 form // with the scale shown at the beginning in parenthesis. // the sign bit is the first digit of the mantissa. // void printFloatCode(FloatCode x, int dec = 0); void printFloatCodeQuartet(FloatCode x, int dec = 0); ////////////////////////////// // // QuantizeMidtread // LinearCode QuantizeMidtread(int bits, double input); ////////////////////////////// // // DequantizeMidtread // double DequantizeMidtread(LinearCode x); ////////////////////////////// // // QuantizeMidrise // LinearCode QuantizeMidrise(int bits, double input); ////////////////////////////// // // DequantizeMidrise // double DequantizeMidrise(LinearCode x); ////////////////////////////// // // FindLeadingZeros -- counts the number of most significant // zeros in a code. // int FindLeadingZeros(LinearCode x); ////////////////////////////// // // QuantizeFloatMidtread // FloatCode QuantizeFloatMidtread(int Rs, int Rm, double input); ////////////////////////////// // // DequantizeFloatMidtread // double DequantizeFloatMidtread(FloatCode x); ////////////////////////////// // // QuantizeFloatMidtread2 -- // FloatCode QuantizeFloatMidtread2(int Rs, int Rm, double input); FloatCode QuantizeBlockFloatMidtread2(int Rs, int Rm, double input); FloatCode QuantizeBlockFloatMidtread2Max(int Rs, int Rm, double input, double maxx); ////////////////////////////// // // DequantizeFloatMidtread2 -- // double DequantizeFloatMidtread2(FloatCode x, int debug = 0); double DequantizeBlockFloatMidtread2(FloatCode x, int debug = 0); #endif /* _QUANTIZATION_H_INCLUDED */ // md5sum: fa7d40299c7ae85aba2005ffe5aff1e6 quantization.h [20050403]