ATLAS Offline Software
Loading...
Searching...
No Matches
ErrorMatrixCompressor.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 * ErrorMatrixCompressor.h
7 *
8 * Created by Dmitry Emeliyanov on 12/11/2008.
9 * <Dmitry.Emeliyanov@cern.ch>
10 *
11 */
12
13#ifndef EVENTCOMMONTPCNV_ERROR_MATRIX_COMPRESSOR_H
14#define EVENTCOMMONTPCNV_ERROR_MATRIX_COMPRESSOR_H
15
16#include <vector>
17#include <bit>
18#include <cstdint>
19
20
22{
23
24 public:
25
26 void setF(float f)
27 {
28 m_data=std::bit_cast<std::uint32_t>(f);
29 }
30 float getF()
31 {
32 auto myUint = m_data;
33 if(myUint==0x80000000u)
34 return 0.0;
35 else
36 return std::bit_cast<float>(m_data);
37 }
38 void setL( int l)
39 {
40 m_data=l;
41 }
42 unsigned int getL()
43 {
44 return m_data;
45 }
46 void print();
47 short int getExponent();
48 unsigned int getMantissa();
49 void setExponent(short int);
50 void setSign(int);
51
52 std::uint32_t m_data{};
53};
54
56{
57public:
58 FloatRep(char s, unsigned short e, unsigned int m) :
59 m_sign(s), m_exp(e), m_mant(m)
60 {
61
62 }
64 float restore()
65 {
66
67
68 if((m_mant==0)&&(m_sign!=0))
69 return 0.0;
70
71 std::uint32_t buf=0x00000000u;
72
73 buf = m_mant;
74 buf = buf | (m_exp << 23);
75 if (m_sign!=0)
76 buf = buf | 0x80000000u;
77 return std::bit_cast<float>(buf);
78 }
79 char sign() const
80 {
81 return m_sign;
82 }
83 unsigned short exponent() const
84 {
85 return m_exp;
86 }
87 unsigned int mantissa() const
88 {
89 return m_mant;
90 }
91 void sign(char s)
92 {
93 m_sign=(s==0)?0:1;
94 }
95 void exponent(unsigned short int e)
96 {
97 m_exp=e;
98 }
99 void mantissa(unsigned int m)
100 {
101 m_mant=m;
102 }
103
104private:
105 char m_sign{};
106 std::uint32_t m_exp{};
107 std::uint32_t m_mant{};
108};
109
110
111
113
114class Triplet {
115
116 public :
117 Triplet(int d, int nd1, int nd2) : m_d(d), m_nd1(nd1), m_nd2(nd2)
118 {
119
120 }
123};
124
125 public:
126
129
130 bool compress(const std::vector<double>&, std::vector<unsigned int>&);
131 bool restore(const std::vector<unsigned int>&, std::vector<double>&);
132 void setBiases(const int b[6]);
133 void setUpperLimits(const int l[2]);
134
135 protected:
136
137 bool CholeskyDecomposition(double a[5][5], double L[5][5]);
138 bool compressFR(const std::vector<FloatRep>&,std::vector<unsigned short>&);
139 bool restoreFR(const std::vector<unsigned short>&,std::vector<FloatRep>&);
140
141 short int m_biases[6]{};
142 short int m_limits[2]{};
143 double m_scales[5]{};
144
146
147 private:
149 unsigned int m_srcMasks[16]{};
150 std::vector<Triplet> m_tripVec;
151};
152
153#endif
static Double_t a
bool compressFR(const std::vector< FloatRep > &, std::vector< unsigned short > &)
void setUpperLimits(const int l[2])
bool restore(const std::vector< unsigned int > &, std::vector< double > &)
std::vector< Triplet > m_tripVec
bool compress(const std::vector< double > &, std::vector< unsigned int > &)
DecoderFloat_IEEE754 m_decoder
bool CholeskyDecomposition(double a[5][5], double L[5][5])
bool restoreFR(const std::vector< unsigned short > &, std::vector< FloatRep > &)
void setBiases(const int b[6])
void exponent(unsigned short int e)
unsigned short exponent() const
char sign() const
void sign(char s)
void mantissa(unsigned int m)
std::uint32_t m_mant
std::uint32_t m_exp
FloatRep(char s, unsigned short e, unsigned int m)
unsigned int mantissa() const