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

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 }

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

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 }

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
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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:72
logintpack::unpack16log
double unpack16log(int16_t i, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:62
OrderedSet.t
t
Definition: OrderedSet.py:90
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
MiniFloatConverter::float32to16
static uint16_t float32to16(float x)
Definition: libminifloat.h:20