MCPcopy Create free account
hub / github.com/GPUOpen-Tools/compressonator / quant_AnD_Shell

Function quant_AnD_Shell

cmp_compressonatorlib/bc7/3dquant_vpc.cpp:1331–1422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1329}
1330
1331void quant_AnD_Shell(double* v_, int k, int n, int* idx)
1332{
1333 // input:
1334 //
1335 // v_ points, might be uncentered
1336 // k - number of points in the ramp
1337 // n - number of points in v_
1338 //
1339 // output:
1340 //
1341 // index, uncentered, in the range 0..k-1
1342 //
1343#define MAX_BLOCK MAX_ENTRIES
1344 int i, j;
1345 double v[MAX_BLOCK];
1346 double z[MAX_BLOCK];
1347 a d[MAX_BLOCK];
1348 double l;
1349 double mm;
1350 double r = 0;
1351 int mi;
1352
1353 assert((v_ != NULL) && (n > 1) && (k > 1));
1354
1355 double m, M, s, dm = 0.;
1356 m = M = v_[0];
1357
1358 for (i = 1; i < n; i++)
1359 {
1360 m = m < v_[i] ? m : v_[i];
1361 M = M > v_[i] ? M : v_[i];
1362 }
1363 if (M == m)
1364 {
1365 for (i = 0; i < n; i++)
1366 idx[i] = 0;
1367 return;
1368 }
1369
1370 assert(M - m > 0);
1371 s = (k - 1) / (M - m);
1372 for (i = 0; i < n; i++)
1373 {
1374 v[i] = v_[i] * s;
1375
1376 idx[i] = (int)(z[i] = floor(v[i] + 0.5 /* stabilizer*/ - m * s));
1377
1378 d[i].d = v[i] - z[i] - m * s;
1379 d[i].i = i;
1380 dm += d[i].d;
1381 r += d[i].d * d[i].d;
1382 }
1383 if (n * r - dm * dm >= (double)(n - 1) / 4 /*slack*/ / 2)
1384 {
1385 dm /= (double)n;
1386
1387 for (i = 0; i < n; i++)
1388 d[i].d -= dm;

Callers 2

optQuantAnDFunction · 0.70
optQuantAnD_dFunction · 0.70

Calls 1

floorFunction · 0.85

Tested by

no test coverage detected