Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::VecCompressor Class Reference

#include <VecCompressor.h>

List of all members.

Static Public Member Functions

signed char * compressVec (const Vec &v, signed char *data)
void uncompressVec (signed char *data, const Vec &v)
 uncompresses the data of a vector compressed with compressVec v must have the correct size.

void writeCompressedVec (ostream &out, const Vec &v)
 writes v in compressed format to the given stream The written data does not contain size info.

void readCompressedVec (istream &in, const Vec &v)
 reads data of a compressed vector from the given stream v must have the right size already (this is not checked!)

size_t worstCaseSize (int n)
 Returns the number of bytes that will be used to encode a vector of length n in the worst case.


Static Protected Member Functions

bool issmallint (real x)
bool is0 (real x)
bool isI (real x)
bool isF (real x)


Detailed Description

It encodes only non zero values, using one byte for small integers, and 4-byte floating points for all other values. This representation should be reasonably good for both sparse matrices, and matrices containing categorical data (represented by small integers) possibly with one hot representations.

Definition at line 58 of file VecCompressor.h.


Member Function Documentation

signed char * PLearn::VecCompressor::compressVec const Vec v,
signed char *  data
[static]
 

writes v in a compressed form in the data buffer passed as argument. (make sure enough memory is allocated in the data buffer) returns a pointer to the one-after-last element written in the data block

Definition at line 48 of file VecCompressor.cc.

References count, PLearn::TVec< T >::data(), is0(), isF(), isI(), issmallint(), PLearn::TVec< T >::length(), mode, val, and PLearn::Vec.

bool PLearn::VecCompressor::is0 real  x  )  [inline, static, protected]
 

Definition at line 65 of file VecCompressor.h.

References is0(), and x.

Referenced by compressVec(), is0(), and writeCompressedVec().

bool PLearn::VecCompressor::isF real  x  )  [inline, static, protected]
 

Definition at line 71 of file VecCompressor.h.

References isF(), and x.

Referenced by compressVec(), isF(), and writeCompressedVec().

bool PLearn::VecCompressor::isI real  x  )  [inline, static, protected]
 

Definition at line 68 of file VecCompressor.h.

References isI(), and x.

Referenced by compressVec(), isI(), and writeCompressedVec().

bool PLearn::VecCompressor::issmallint real  x  )  [inline, static, protected]
 

Definition at line 62 of file VecCompressor.h.

References issmallint(), and x.

Referenced by compressVec(), issmallint(), and writeCompressedVec().

void PLearn::VecCompressor::readCompressedVec istream &  in,
const Vec v
[static]
 

reads data of a compressed vector from the given stream v must have the right size already (this is not checked!)

Definition at line 391 of file VecCompressor.cc.

References count, PLearn::TVec< T >::data(), PLearn::TVec< T >::length(), mode, PLERROR, and PLearn::read_sbyte().

void PLearn::VecCompressor::uncompressVec signed char *  data,
const Vec v
[static]
 

uncompresses the data of a vector compressed with compressVec v must have the correct size.

Definition at line 182 of file VecCompressor.cc.

References count, PLearn::TVec< T >::data(), PLearn::TVec< T >::length(), mode, and PLERROR.

size_t PLearn::VecCompressor::worstCaseSize int  n  )  [inline, static]
 

Returns the number of bytes that will be used to encode a vector of length n in the worst case.

Definition at line 95 of file VecCompressor.h.

References worstCaseSize().

Referenced by worstCaseSize().

void PLearn::VecCompressor::writeCompressedVec ostream &  out,
const Vec v
[static]
 

writes v in compressed format to the given stream The written data does not contain size info.

Definition at line 267 of file VecCompressor.cc.

References count, PLearn::TVec< T >::data(), is0(), isF(), isI(), issmallint(), PLearn::TVec< T >::length(), mode, val, and PLearn::write_sbyte().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:24:06 2004 for PLearn by doxygen 1.3.7