CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Public Attributes
CompressionElement Class Reference

#include <CovarianceParameterization.h>

Public Types

enum  Method {
  float16 = 0, reduceMantissa = 1, logPack = 2, tanLogPack = 3,
  zero = 4, one = 5
}
 
enum  Target { realValue = 0, ratioToRef = 1, differenceToRef = 2 }
 

Public Member Functions

 CompressionElement ()
 
 CompressionElement (Method m, Target t, int bitsUsed, std::vector< float > p)
 
uint16_t pack (float value, float ref=0.) const
 
float unpack (uint16_t packed, float ref=0.) const
 

Public Attributes

int bits
 
Method method
 
std::vector< float > params
 
Target target
 

Detailed Description

Definition at line 9 of file CovarianceParameterization.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

CompressionElement::CompressionElement ( )
inline
CompressionElement::CompressionElement ( Method  m,
Target  t,
int  bitsUsed,
std::vector< float >  p 
)
inline

Member Function Documentation

uint16_t CompressionElement::pack ( float  value,
float  ref = 0. 
) const

Definition at line 14 of file CovarianceParameterization.cc.

References bits, differenceToRef, float16, MiniFloatConverter::float32to16(), logPack, method, one, logintpack::pack16log(), params, alignCSCRings::r, ratioToRef, realValue, reduceMantissa, MiniFloatConverter::reduceMantissaToNbits(), tanLogPack, target, relativeConstraints::value, and zero.

14  {
15  float toCompress = 0;
16  switch (target) {
17  case (realValue):
18  toCompress = value;
19  break;
20  case (ratioToRef):
21  toCompress = value / ref;
22  break;
23  case (differenceToRef):
24  toCompress = value - ref;
25  break;
26  }
27  switch (method) {
28  case (float16):
29  return MiniFloatConverter::float32to16(toCompress * params[0]);
30  break;
31  case (reduceMantissa):
33  break;
34  case (zero):
35  return 0;
36  break;
37  case (one):
38  return 1.0;
39  break;
40  case (tanLogPack):
41  return 0; //FIXME: should be implemented
42  break;
43  case (logPack):
44  int16_t r = logintpack::pack16log(toCompress, params[0], params[1], bits);
45  return *reinterpret_cast<uint16_t *>(&r);
46  break;
47  }
48  return 0;
49 }
std::vector< float > params
static uint16_t float32to16(float x)
Definition: libminifloat.h:17
int16_t pack16log(double x, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:27
static float reduceMantissaToNbits(const float &f)
Definition: libminifloat.h:38
float CompressionElement::unpack ( uint16_t  packed,
float  ref = 0. 
) const

Definition at line 50 of file CovarianceParameterization.cc.

References bits, differenceToRef, float16, MiniFloatConverter::float16to32(), logPack, method, one, params, ratioToRef, realValue, reduceMantissa, tanLogPack, target, logintpack::unpack16log(), and zero.

50  {
51  float unpacked = 0;
52  switch (method) {
53  case (float16):
54  unpacked = MiniFloatConverter::float16to32(packed) / params[0];
55  break;
56  case (reduceMantissa):
57  unpacked = packed;
58  break;
59  case (logPack):
60  unpacked = logintpack::unpack16log(*reinterpret_cast<int16_t *>(&packed), params[0], params[1], bits);
61  break;
62  case (zero):
63  unpacked = 0;
64  break;
65  case (one):
66  case (tanLogPack):
67  unpacked = 1; //FIXME: should be implemented
68  }
69  switch (target) {
70  case (realValue):
71  return unpacked;
72  case (ratioToRef):
73  return unpacked * ref;
74  case (differenceToRef):
75  return unpacked + ref;
76  }
77 
78  return ref;
79 }
double unpack16log(int16_t i, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:62
static float float16to32(uint16_t h)
Definition: libminifloat.h:13
std::vector< float > params

Member Data Documentation

int CompressionElement::bits

Definition at line 18 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

Method CompressionElement::method

Definition at line 16 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

std::vector<float> CompressionElement::params

Definition at line 19 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

Target CompressionElement::target

Definition at line 17 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().