MCPcopy Create free account
hub / github.com/LAStools/LAStools / dorescale

Method dorescale

LASzip/unused/rangemodel.cpp:95–150  ·  view source on GitHub ↗

rescale frequency counts */

Source from the content-addressed store, hash-verified

93
94/* rescale frequency counts */
95void RangeModel::dorescale()
96{
97 I32 i, c, missing;
98 if (nextleft) /* we have some more before actual rescaling */
99 {
100 incr++;
101 left = nextleft;
102 nextleft = 0;
103 return;
104 }
105 if (rescale != targetrescale) /* double rescale interval if needed */
106 {
107 rescale <<= 1;
108 if (rescale > targetrescale)
109 {
110 rescale = targetrescale;
111 }
112 }
113 c = missing = cf[n]; /* do actual rescaling */
114 for(i=n-1; i; i--)
115 {
116 I32 tmp = newf[i];
117 c -= tmp;
118 cf[i] = c;
119 tmp = tmp>>1 | 1;
120 missing -= tmp;
121 newf[i] = tmp;
122 }
123 if (c!=newf[0])
124 {
125// fprintf(stderr,"BUG: rescaling left %d total frequency\n",c);
126// exit(1);
127 throw std::runtime_error("internal error: RangeModel::dorescale()");
128 }
129 newf[0] = newf[0]>>1 | 1;
130 missing -= newf[0];
131 incr = missing / rescale;
132 nextleft = missing % rescale;
133 left = rescale - nextleft;
134 if (search != NULL)
135 {
136 i=n;
137 while (i)
138 {
139 I32 start, end;
140 end = (cf[i]-1) >> searchshift;
141 i--;
142 start = cf[i] >> searchshift;
143 while (start<=end)
144 {
145 search[start] = i;
146 start++;
147 }
148 }
149 }
150}
151
152/* reinitialisation of qsmodel */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected