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

Function wSecondSearch

libpolys/polys/weight0.cc:295–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293
294
295void wSecondSearch(int *A, int *x, int *lpol,
296int npol, int mons, double *rel, double *fk, double wNsqr, int rvar)
297{
298 int n, s0, s1, s2, *xopt;
299 double fx, fopt, wx;
300
301 n = rvar;
302 xopt = x + (n + 2);
303 fopt = *fk * (double)0.999999999999;
304 wx = wPrWeight(x, n);
305 loop
306 {
307 wEstimate(A, x, lpol, npol, mons, wx, rel, &fx, &s0, &s1, &s2, wNsqr, rvar);
308 if (fx > fopt)
309 {
310 if (s0!=0)
311 x[s0]--;
312 else if (s1!=0)
313 {
314 x[s1]--;
315 x[s2]--;
316 }
317 else
318 break;
319 }
320 else
321 {
322 fopt = fx;
323 if (s0!=0)
324 {
325 x[s0]--;
326 memcpy(xopt, x + 1, n * sizeof(int));
327 if (s1==0)
328 break;
329 }
330 else if (s1!=0)
331 {
332 x[s1]--;
333 x[s2]--;
334 memcpy(xopt, x + 1, n * sizeof(int));
335 }
336 else
337 break;
338 }
339 if (s0!=0)
340 wSub(A, mons, s0, 1, rvar);
341 else
342 {
343 wSub(A, mons, s1, 1, rvar);
344 wSub(A, mons, s2, 1, rvar);
345 }
346 wx = wPrWeight(x, n);
347 }
348 *fk = fopt;
349}
350

Callers 1

wCallFunction · 0.85

Calls 3

wPrWeightFunction · 0.85
wEstimateFunction · 0.85
wSubFunction · 0.85

Tested by

no test coverage detected