Changeset 1135a61 in git for libpolys/polys/weight0.c
- Timestamp:
- Apr 19, 2011, 12:00:52 PM (12 years ago)
- Branches:
- (u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
- Children:
- ec0d9b416a53586bd0d5b780545cea184cf3d824
- Parents:
- f27003fd89ac86ed0bd7cc93a1342d129926c00c
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-04-19 12:00:52+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:31:18+01:00
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/weight0.c
rf27003 r1135a61 10 10 #include <math.h> 11 11 #include <string.h> 12 #include < kernel/mod2.h>12 #include <misc/auxiliary.h> 13 13 #include <omalloc/omalloc.h> 14 #include <kernel/structs.h>15 14 16 15 double wFunctionalMora(int *degw, int *lpol, int npol, … … 18 17 double wFunctionalBuch(int *degw, int *lpol, int npol, 19 18 double *rel, double wx, double wwNsqr); 20 void wAdd(int *A, int mons, int kn, int xx );19 void wAdd(int *A, int mons, int kn, int xx, int rvar); 21 20 void wNorm(int *degw, int *lpol, int npol, double *rel); 22 21 void wFirstSearch(int *A, int *x, int mons, 23 int *lpol, int npol, double *rel, double *fopt, double wNsqr );22 int *lpol, int npol, double *rel, double *fopt, double wNsqr, int rvar); 24 23 void wSecondSearch(int *A, int *x, int *lpol, 25 int npol, int mons, double *rel, double *fk, double wNsqr );24 int npol, int mons, double *rel, double *fk, double wNsqr, int rvar); 26 25 void wGcd(int *x, int n); 27 26 /*0 implementation*/ 28 27 29 28 short * ecartWeights=NULL; 30 extern int pVariables;31 29 32 30 double (*wFunctional)(int *degw, int *lpol, int npol, … … 112 110 113 111 114 static void wSub(int *A, int mons, int kn, int xx )112 static void wSub(int *A, int mons, int kn, int xx,int rvar) 115 113 { 116 114 int i, *B, *ex; 117 115 118 116 B = A + ((kn - 1) * mons); 119 ex = A + ( pVariables* mons);117 ex = A + (rvar * mons); 120 118 i = mons; 121 119 if (xx == 1) … … 132 130 133 131 134 void wAdd(int *A, int mons, int kn, int xx )132 void wAdd(int *A, int mons, int kn, int xx, int rvar) 135 133 { 136 134 int i, *B, *ex; 137 135 138 136 B = A + ((kn - 1) * mons); 139 ex = A + ( pVariables* mons);137 ex = A + (rvar * mons); 140 138 i = mons; 141 139 if (xx == 1) … … 153 151 154 152 void wFirstSearch(int *A, int *x, int mons, 155 int *lpol, int npol, double *rel, double *fopt, double wNsqr )153 int *lpol, int npol, double *rel, double *fopt, double wNsqr, int rvar) 156 154 { 157 155 int a0, a, n, xn, t, xx, y1; … … 162 160 163 161 fy = *fopt; 164 n = pVariables;162 n = rvar; 165 163 xn = n + 6 + (21 / n); 166 164 a0 = n * sizeof(double); … … 187 185 x[t] = xx; 188 186 if (xx > 1) 189 wAdd(A, mons, t, 1 );187 wAdd(A, mons, t, 1, rvar); 190 188 t++; 191 189 } … … 195 193 x[t] = 0; 196 194 if (xx!=0) 197 wSub(A, mons, t, xx );195 wSub(A, mons, t, xx, rvar); 198 196 t--; 199 197 if (t==0) … … 211 209 xx--; 212 210 if (xx!=0) 213 wAdd(A, mons, t, xx );211 wAdd(A, mons, t, xx, rvar); 214 212 fmax = (*wFunctional)(degw, lpol, npol, rel, wx,wNsqr); 215 213 if (xx!=0) 216 wSub(A, mons, t, xx );214 wSub(A, mons, t, xx, rvar); 217 215 if (fmax < fy) 218 216 { … … 238 236 239 237 static void wEstimate(int *A, int *x, int *lpol, int npol, int mons, 240 double wx, double *rel, double *fopt, int *s0, int *s1, int *s2, double wNsqr )238 double wx, double *rel, double *fopt, int *s0, int *s1, int *s2, double wNsqr, int rvar) 241 239 { 242 240 int n, i1, i2, k0 = 0, k1 = 0, k2 = 0; … … 244 242 double fo1, fo2, fmax, wx1, wx2; 245 243 246 n = pVariables;244 n = rvar; 247 245 degw = A + (n * mons); 248 246 fo2 = fo1 = (double)1.0e10; … … 251 249 if (x[i1] > 1) 252 250 { 253 wSub(A, mons, i1, 1 );251 wSub(A, mons, i1, 1, rvar); 254 252 wx1 = wx - wx / (double)x[i1]; 255 253 x[i1]--; … … 264 262 if (x[i2] > 1) 265 263 { 266 wSub(A, mons, i2, 1 );264 wSub(A, mons, i2, 1, rvar); 267 265 wx2 = wx1 - wx1 / (double)x[i2]; 268 266 fmax = (*wFunctional)(degw, lpol, npol, rel, wx2, wNsqr); … … 273 271 k2 = i2; 274 272 } 275 wAdd(A, mons, i2, 1 );273 wAdd(A, mons, i2, 1, rvar); 276 274 } 277 275 } 278 wAdd(A, mons, i1, 1 );276 wAdd(A, mons, i1, 1, rvar); 279 277 x[i1]++; 280 278 } … … 296 294 297 295 void wSecondSearch(int *A, int *x, int *lpol, 298 int npol, int mons, double *rel, double *fk, double wNsqr )296 int npol, int mons, double *rel, double *fk, double wNsqr, int rvar) 299 297 { 300 298 int n, s0, s1, s2, *xopt; 301 299 double one, fx, fopt, wx; 302 300 303 n = pVariables;301 n = rvar; 304 302 xopt = x + (n + 2); 305 303 fopt = *fk * (double)0.999999999999; … … 308 306 loop 309 307 { 310 wEstimate(A, x, lpol, npol, mons, wx, rel, &fx, &s0, &s1, &s2, wNsqr );308 wEstimate(A, x, lpol, npol, mons, wx, rel, &fx, &s0, &s1, &s2, wNsqr, rvar); 311 309 if (fx > fopt) 312 310 { … … 341 339 } 342 340 if (s0!=0) 343 wSub(A, mons, s0, 1 );341 wSub(A, mons, s0, 1, rvar); 344 342 else 345 343 { 346 wSub(A, mons, s1, 1 );347 wSub(A, mons, s2, 1 );344 wSub(A, mons, s1, 1, rvar); 345 wSub(A, mons, s2, 1, rvar); 348 346 } 349 347 wx = wPrWeight(x, n);
Note: See TracChangeset
for help on using the changeset viewer.