MCPcopy Create free account
hub / github.com/Singular/Singular / wSimple

Function wSimple

libpolys/polys/weight0.cc:387–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385
386#if 0 /*currently unused*/
387static void wSimple(int *x, int n)
388{
389 int g, min, c, d, f, kopt, k, i;
390 int *xopt;
391 double sopt, s1, s2;
392
393 xopt = x + (n + 1);
394 kopt = k = g = 0;
395 min = 1000000;
396 for (i = n; i!=0 ; i--)
397 {
398 c = xopt[i];
399 if (c > 1)
400 {
401 if (c < min)
402 min = c;
403 if (c > k)
404 k = c;
405 }
406 else
407 g = 1;
408 }
409 k -= min;
410 if ((g==0) && (k < 4))
411 return;
412 if (k < min)
413 min = k+1;
414 sopt = (double)1.0e10;
415 for (k = min; k > 1; k--)
416 {
417 s2 = s1 = (double)0.0;
418 for(i = n; i!=0 ; i--)
419 {
420 c = xopt[i];
421 if (c > 1)
422 {
423 d = c / k;
424 d *= k;
425 f = d = c - d;
426 if (f!=0)
427 {
428 f = k - f;
429 if (f < d)
430 s2 += (double)f / (double)c;
431 else
432 s1 += (double)d / (double)c;
433 }
434 }
435 }
436 s1 += s2 + sqrt(s1 * s2);
437 s1 -= (double)0.01 * sqrt((double)k);
438 if (s1 < sopt)
439 {
440 sopt = s1;
441 kopt = k;
442 }
443 }
444 for(i = n; i!=0 ; i--)

Callers

nothing calls this directly

Calls 2

wGcdFunction · 0.85
sqrtFunction · 0.50

Tested by

no test coverage detected