CMS 3D CMS Logo

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 11 of file CovarianceParameterization.cc.

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

Referenced by CovarianceParameterization::loadedVersion().

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

Definition at line 47 of file CovarianceParameterization.cc.

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

Referenced by CovarianceParameterization::loadedVersion().

47  {
48  float unpacked = 0;
49  switch (method) {
50  case (float16):
51  unpacked = MiniFloatConverter::float16to32(packed) / params[0];
52  break;
53  case (reduceMantissa):
54  unpacked = packed;
55  break;
56  case (logPack):
57  unpacked = logintpack::unpack16log(*reinterpret_cast<int16_t *>(&packed), params[0], params[1], bits);
58  break;
59  case (zero):
60  unpacked = 0;
61  break;
62  case (one):
63  case (tanLogPack):
64  unpacked = 1; //FIXME: should be implemented
65  }
66  switch (target) {
67  case (realValue):
68  return unpacked;
69  case (ratioToRef):
70  return unpacked * ref;
71  case (differenceToRef):
72  return unpacked + ref;
73  }
74 
75  return ref;
76 }
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:12
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().