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

◆ Method

Enumerator
float16 
reduceMantissa 
logPack 
tanLogPack 
zero 
one 

Definition at line 11 of file CovarianceParameterization.h.

11 { float16 = 0, reduceMantissa = 1, logPack = 2, tanLogPack = 3, zero = 4, one = 5 };

◆ Target

Enumerator
realValue 
ratioToRef 
differenceToRef 

Definition at line 12 of file CovarianceParameterization.h.

12 { realValue = 0, ratioToRef = 1, differenceToRef = 2 };

Constructor & Destructor Documentation

◆ CompressionElement() [1/2]

CompressionElement::CompressionElement ( )
inline

Definition at line 13 of file CovarianceParameterization.h.

◆ CompressionElement() [2/2]

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

Definition at line 14 of file CovarianceParameterization.h.

15  : method(m), target(t), bits(bitsUsed), params(p) {}

Member Function Documentation

◆ pack()

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

Definition at line 14 of file CovarianceParameterization.cc.

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 }

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.

◆ unpack()

float CompressionElement::unpack ( uint16_t  packed,
float  ref = 0. 
) const

Definition at line 50 of file CovarianceParameterization.cc.

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 }

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

Member Data Documentation

◆ bits

int CompressionElement::bits

Definition at line 18 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

◆ method

Method CompressionElement::method

Definition at line 16 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

◆ params

std::vector<float> CompressionElement::params

Definition at line 19 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

◆ target

Target CompressionElement::target

Definition at line 17 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

logintpack::pack16log
int16_t pack16log(double x, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:27
CompressionElement::target
Target target
Definition: CovarianceParameterization.h:17
CompressionElement::params
std::vector< float > params
Definition: CovarianceParameterization.h:19
CompressionElement::method
Method method
Definition: CovarianceParameterization.h:16
CompressionElement::realValue
Definition: CovarianceParameterization.h:12
MiniFloatConverter::reduceMantissaToNbits
static float reduceMantissaToNbits(const float &f)
Definition: libminifloat.h:49
CompressionElement::ratioToRef
Definition: CovarianceParameterization.h:12
CompressionElement::tanLogPack
Definition: CovarianceParameterization.h:11
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:79
logintpack::unpack16log
double unpack16log(int16_t i, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:62
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CompressionElement::reduceMantissa
Definition: CovarianceParameterization.h:11
MiniFloatConverter::float16to32
static float float16to32(uint16_t h)
Definition: libminifloat.h:12
value
Definition: value.py:1
CompressionElement::bits
int bits
Definition: CovarianceParameterization.h:18
alignCSCRings.r
r
Definition: alignCSCRings.py:93
CompressionElement::zero
Definition: CovarianceParameterization.h:11
CompressionElement::one
Definition: CovarianceParameterization.h:11
CompressionElement::float16
Definition: CovarianceParameterization.h:11
relativeConstraints.value
value
Definition: relativeConstraints.py:53
CompressionElement::logPack
Definition: CovarianceParameterization.h:11
CompressionElement::differenceToRef
Definition: CovarianceParameterization.h:12
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
MiniFloatConverter::float32to16
static uint16_t float32to16(float x)
Definition: libminifloat.h:20