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 pyrootRender.interactiveRender::draw(), and CovarianceParameterization::loadedVersion().

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

Definition at line 49 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().

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 
80 }
double unpack16log(int16_t i, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:55
static float float16to32(uint16_t h)
Definition: libminifloat.h:12
std::vector< float > params

Member Data Documentation

int CompressionElement::bits

Definition at line 17 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

Method CompressionElement::method

Definition at line 15 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

std::vector<float> CompressionElement::params

Definition at line 18 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().

Target CompressionElement::target

Definition at line 16 of file CovarianceParameterization.h.

Referenced by pack(), and unpack().