Changeset 1135a61 in git
- Timestamp:
- Apr 19, 2011, 12:00:52 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- 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
- Location:
- libpolys/polys
- Files:
-
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/Makefile.am
rf27003 r1135a61 36 36 pDebug.cc pInline0.cc polys0.cc prCopy.cc \ 37 37 kbuckets.cc sbuckets.cc ${USE_P_PROCS_STATIC_CC} ${USE_P_PROCS_DYNAMIC_CC} weight.cc \ 38 simpleideals.cc matpol.cc38 weight0.c simpleideals.cc matpol.cc 39 39 40 40 BUILT_SOURCES = templates/p_Procs.inc -
libpolys/polys/weight.cc
rf27003 r1135a61 26 26 extern "C" double wFunctionalBuch(int *degw, int *lpol, int npol, 27 27 double *rel, double wx, double wNsqr); 28 extern "C" void wAdd(int *A, int mons, int kn, int xx );28 extern "C" void wAdd(int *A, int mons, int kn, int xx, int rvar); 29 29 extern "C" void wNorm(int *degw, int *lpol, int npol, double *rel); 30 30 extern "C" void wFirstSearch(int *A, int *x, int mons, 31 int *lpol, int npol, double *rel, double *fopt, double wNsqr );31 int *lpol, int npol, double *rel, double *fopt, double wNsqr, int rvar); 32 32 extern "C" void wSecondSearch(int *A, int *x, int *lpol, 33 int npol, int mons, double *rel, double *fk, double wNsqr );33 int npol, int mons, double *rel, double *fk, double wNsqr, int rvar); 34 34 extern "C" void wGcd(int *x, int n); 35 35 … … 134 134 memset(degw, 0, mons * sizeof(int)); 135 135 for (i = n; i!=0; i--) 136 wAdd(A, mons, i, 1 );136 wAdd(A, mons, i, 1, rVar(R)); 137 137 wNorm(degw, lpol, npol, rel); 138 138 f1 = (*wFunctional)(degw, lpol, npol, rel, (double)1.0, wNsqr); … … 141 141 fx = (double)2.0 * eps; 142 142 memset(x, 0, (n + 1) * sizeof(int)); 143 wFirstSearch(A, x, mons, lpol, npol, rel, &fx, wNsqr );143 wFirstSearch(A, x, mons, lpol, npol, rel, &fx, wNsqr, rVar(R)); 144 144 if (TEST_OPT_PROT) Print("// %e\n",fx); 145 145 memcpy(x + 1, xopt + 1, n * sizeof(int)); … … 148 148 { 149 149 x[i] *= 16; 150 wAdd(A, mons, i, x[i] );151 } 152 wSecondSearch(A, x, lpol, npol, mons, rel, &fx, wNsqr );150 wAdd(A, mons, i, x[i], rVar(R)); 151 } 152 wSecondSearch(A, x, lpol, npol, mons, rel, &fx, wNsqr, rVar(R)); 153 153 if (TEST_OPT_PROT) Print("// %e\n",fx); 154 154 if (fx >= eps) … … 166 166 // memset(degw, 0, mons * sizeof(int)); 167 167 // for (i = n; i!=0; i--) 168 // wAdd(A, mons, i, x[i] );168 // wAdd(A, mons, i, x[i], rVar(R)); 169 169 // eps = wPrWeight(x, n); 170 170 // fx = (*wFunctional)(degw, lpol, npol, rel, eps); -
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.