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

Function wCall

libpolys/polys/weight.cc:108–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108void wCall(poly* s, int sl, int *x, double wNsqr, const ring R)
109{
110 int n, q, npol, mons, i;
111 int *A, *xopt, *lpol, *degw;
112 double f1, fx, eps, *rel;
113 void *adr;
114
115 n = rVar(R);
116 lpol = (int * )omAlloc((sl + 1) * sizeof(int));
117 wDimensions(s, sl, lpol, &npol, &mons);
118 xopt = x + (n + 1);
119 for (i = n; i!=0; i--)
120 xopt[i] = 1;
121 if (mons==0)
122 {
123 omFreeSize((ADDRESS)lpol, (sl + 1) * sizeof(int));
124 return;
125 }
126 adr = (void * )omAllocAligned(npol * sizeof(double));
127 rel = (double*)adr;
128 q = (n + 1) * mons * sizeof(int);
129 A = (int * )omAlloc(q);
130 wInit(s, sl, mons, A, R);
131 degw = A + (n * mons);
132 memset(degw, 0, mons * sizeof(int));
133 for (i = n; i!=0; i--)
134 wAdd(A, mons, i, 1, rVar(R));
135 wNorm(degw, lpol, npol, rel);
136 f1 = (*wFunctional)(degw, lpol, npol, rel, (double)1.0, wNsqr);
137 if (TEST_OPT_PROT) Print("// %e\n",f1);
138 eps = f1;
139 fx = (double)2.0 * eps;
140 memset(x, 0, (n + 1) * sizeof(int));
141 wFirstSearch(A, x, mons, lpol, npol, rel, &fx, wNsqr, rVar(R));
142 if (TEST_OPT_PROT) Print("// %e\n",fx);
143 memcpy(x + 1, xopt + 1, n * sizeof(int));
144 memset(degw, 0, mons * sizeof(int));
145 for (i = n; i!=0; i--)
146 {
147 x[i] *= 16;
148 wAdd(A, mons, i, x[i], rVar(R));
149 }
150 wSecondSearch(A, x, lpol, npol, mons, rel, &fx, wNsqr, rVar(R));
151 if (TEST_OPT_PROT) Print("// %e\n",fx);
152 if (fx >= eps)
153 {
154 for (i = n; i!=0; i--)
155 xopt[i] = 1;
156 }
157 else
158 {
159 wGcd(xopt, n);
160// if (BTEST1(22))
161// {
162// f1 = fx + (double)0.1 * (f1 - fx);
163// wSimple(x, n);
164// memset(degw, 0, mons * sizeof(int));
165// for (i = n; i!=0; i--)

Callers 3

kEcartWeightsFunction · 0.85
kWeightFunction · 0.85
idEliminationFunction · 0.85

Calls 9

rVarFunction · 0.85
wDimensionsFunction · 0.85
wInitFunction · 0.85
wAddFunction · 0.85
wNormFunction · 0.85
wFirstSearchFunction · 0.85
wSecondSearchFunction · 0.85
wGcdFunction · 0.85
PrintFunction · 0.50

Tested by

no test coverage detected