MCPcopy Create free account
hub / github.com/dotabuff/manta / assignMultipliers

Method assignMultipliers

quantizedfloat.go:68–107  ·  view source on GitHub ↗

Assign multipliers

(steps uint32)

Source from the content-addressed store, hash-verified

66
67// Assign multipliers
68func (qfd *quantizedFloatDecoder) assignMultipliers(steps uint32) {
69 qfd.HighLowMul = 0.0
70 Range := qfd.High - qfd.Low
71
72 High := uint32(0)
73 if qfd.Bitcount == 32 {
74 High = 0xFFFFFFFE
75 } else {
76 High = (1 << qfd.Bitcount) - 1
77 }
78
79 HighMul := float32(0.0)
80 if math.Abs(float64(Range)) <= 0.0 {
81 HighMul = float32(High)
82 } else {
83 HighMul = float32(High) / Range
84 }
85
86 // Adjust precision
87 if (HighMul*Range > float32(High)) || (float64(HighMul*Range) > float64(High)) {
88 multipliers := []float32{0.9999, 0.99, 0.9, 0.8, 0.7}
89
90 for _, mult := range multipliers {
91 HighMul = float32(High) / Range * mult
92
93 if (HighMul*Range > float32(High)) || (float64(HighMul*Range) > float64(High)) {
94 continue
95 }
96
97 break
98 }
99 }
100
101 qfd.HighLowMul = HighMul
102 qfd.DecMul = 1.0 / float32(steps-1)
103
104 if qfd.HighLowMul == 0.0 {
105 _panicf("Error computing high / low multiplier")
106 }
107}
108
109// Quantize a float
110func (qfd *quantizedFloatDecoder) quantize(val float32) float32 {

Callers 1

newQuantizedFloatDecoderFunction · 0.95

Calls 1

_panicfFunction · 0.85

Tested by

no test coverage detected