Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

GammaCompress.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2001 Carnegie Mellon University.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.cs.cmu.edu/~lemur/license.html
00008  *
00009  *==========================================================================
00010 */
00011 
00012 
00013 #ifndef _GAMMACOMPRESSH_
00014 #define _GAMMACOMPRESSH_
00015 
00017 
00027 //---------------------------------------------------------------
00028 
00029 //  J. Lafferty, 10/29/00
00030 //
00031 //---------------------------------------------------------------
00032 
00033 #include "common_headers.hpp"
00034 #include "Compress.hpp"
00035 
00036 class GammaCompress : public Compress 
00037 {
00038 public:
00039   GammaCompress();
00040 
00041 public:
00042   void compress (ostream &os, int n, int * a);
00043   int decompress (istream &is, int * a);
00044   int read(istream &is);
00045   const char * type() { return "gamma"; }
00046 
00047 private:
00048   void initBitMasks ();
00049   int floorlog2 (double x);
00050   int gamma_size(int x);
00051   int gamma_encode(int x, int offset, vector<int> &bv);
00052   int gamma_decode(int * y, int offset, vector<int> &bv);
00053   int read_bits(istream & is, vector<int> &bv, int size);
00054   void write_bits(ostream & os, vector<int> &bv);
00055 
00056 private:
00057   vector<int> bv;  
00058   static char bits[8];
00059 };
00060 
00061 #endif

Generated at Fri Jul 26 18:22:26 2002 for LEMUR by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000