Functions | Variables
weight.h File Reference
#include <polys/monomials/ring.h>

Go to the source code of this file.

Functions

void kEcartWeights (poly *s, int sl, short *eweight, const ring R)
 
long maxdegreeWecart (poly p, int *l, ring r)
 
long totaldegreeWecart (poly p, ring r)
 
long totaldegreeWecart_IV (poly p, ring r, const short *w)
 
short * iv2array (intvec *iv, const ring R)
 
double wFunctionalBuch (int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
 
void wCall (poly *s, int sl, int *x, double wNsqr, const ring R)
 

Variables

short * ecartWeights
 
double(* wFunctional )(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
 

Function Documentation

short* iv2array ( intvec iv,
const ring  R 
)

Definition at line 208 of file weight.cc.

209 {
210  short *s=(short *)omAlloc0((rVar(R)+1)*sizeof(short));
211  int len=0;
212  if(iv!=NULL)
213  len=si_min(iv->length(),rVar(R)); // usually: rVar(R)==length()
214  int i;
215  //for(i=pVariables;i>len;i--) s[i]=1;
216  for(i=len;i>0;i--) s[i]=(*iv)[i-1];
217  return s;
218 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:537
int length() const
Definition: intvec.h:86
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211
void kEcartWeights ( poly s,
int  sl,
short *  eweight,
const ring  R 
)

Definition at line 190 of file weight.cc.

191 {
192  int n, i;
193  int *x;
194 
195  *eweight = 0;
196  n = rVar(R);
199  else
201  x = (int * )omAlloc(2 * (n + 1) * sizeof(int));
202  wCall(s, sl, x, (double)2.0 / (double)n, R);
203  for (i = n; i!=0; i--)
204  eweight[i] = x[i + n + 1];
205  omFreeSize((ADDRESS)x, 2 * (n + 1) * sizeof(int));
206 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:750
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:537
void * ADDRESS
Definition: auxiliary.h:161
#define omAlloc(size)
Definition: omAllocDecl.h:210
double(* wFunctional)(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight.cc:28
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
double wFunctionalMora(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight0.c:38
void wCall(poly *s, int sl, int *x, double wNsqr, const ring R)
Definition: weight.cc:116
Variable x
Definition: cfModGcd.cc:4023
double wFunctionalBuch(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight0.c:82
long maxdegreeWecart ( poly  p,
int *  l,
ring  r 
)

Definition at line 255 of file weight.cc.

256 {
257  short k=p_GetComp(p, r);
258  int ll=1;
259  long t,max;
260 
261  max=totaldegreeWecart(p, r);
262  pIter(p);
263  while ((p!=NULL) && (p_GetComp(p, r)==k))
264  {
265  t=totaldegreeWecart(p, r);
266  if (t>max) max=t;
267  ll++;
268  pIter(p);
269  }
270  *l=ll;
271  return max;
272 }
long totaldegreeWecart(poly p, ring r)
Definition: weight.cc:225
return P p
Definition: myNF.cc:203
#define p_GetComp(p, r)
Definition: monomials.h:72
int k
Definition: cfEzgcd.cc:93
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
static int max(int a, int b)
Definition: fast_mult.cc:264
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
long totaldegreeWecart ( poly  p,
ring  r 
)

Definition at line 225 of file weight.cc.

226 {
227  int i;
228  long j =0;
229 
230  for (i=rVar(r); i>0; i--)
231  j += (int)(p_GetExp(p,i,r) * ecartWeights[i]);
232  return j;
233 }
return P p
Definition: myNF.cc:203
short * ecartWeights
Definition: weight0.c:32
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:537
const ring r
Definition: syzextra.cc:208
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:464
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
long totaldegreeWecart_IV ( poly  p,
ring  r,
const short *  w 
)

Definition at line 239 of file weight.cc.

240 {
241  int i;
242  long j =0;
243 
244  for (i=rVar(r); i>0; i--)
245  j += (long)((int)(p_GetExp(p,i,r) * w[i]));
246  return j;
247 }
return P p
Definition: myNF.cc:203
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:537
const ring r
Definition: syzextra.cc:208
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:464
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
const CanonicalForm & w
Definition: facAbsFact.cc:55
void wCall ( poly s,
int  sl,
int *  x,
double  wNsqr,
const ring  R 
)

Definition at line 116 of file weight.cc.

117 {
118  int n, q, npol, mons, i;
119  int *A, *xopt, *lpol, *degw;
120  double f1, fx, eps, *rel;
121  void *adr;
122 
123  n = rVar(R);
124  lpol = (int * )omAlloc((sl + 1) * sizeof(int));
125  wDimensions(s, sl, lpol, &npol, &mons);
126  xopt = x + (n + 1);
127  for (i = n; i!=0; i--)
128  xopt[i] = 1;
129  if (mons==0)
130  {
131  omFreeSize((ADDRESS)lpol, (sl + 1) * sizeof(int));
132  return;
133  }
134  adr = (void * )omAllocAligned(npol * sizeof(double));
135  rel = (double*)adr;
136  q = (n + 1) * mons * sizeof(int);
137  A = (int * )omAlloc(q);
138  wInit(s, sl, mons, A, R);
139  degw = A + (n * mons);
140  memset(degw, 0, mons * sizeof(int));
141  for (i = n; i!=0; i--)
142  wAdd(A, mons, i, 1, rVar(R));
143  wNorm(degw, lpol, npol, rel);
144  f1 = (*wFunctional)(degw, lpol, npol, rel, (double)1.0, wNsqr);
145  if (TEST_OPT_PROT) Print("// %e\n",f1);
146  eps = f1;
147  fx = (double)2.0 * eps;
148  memset(x, 0, (n + 1) * sizeof(int));
149  wFirstSearch(A, x, mons, lpol, npol, rel, &fx, wNsqr, rVar(R));
150  if (TEST_OPT_PROT) Print("// %e\n",fx);
151  memcpy(x + 1, xopt + 1, n * sizeof(int));
152  memset(degw, 0, mons * sizeof(int));
153  for (i = n; i!=0; i--)
154  {
155  x[i] *= 16;
156  wAdd(A, mons, i, x[i], rVar(R));
157  }
158  wSecondSearch(A, x, lpol, npol, mons, rel, &fx, wNsqr, rVar(R));
159  if (TEST_OPT_PROT) Print("// %e\n",fx);
160  if (fx >= eps)
161  {
162  for (i = n; i!=0; i--)
163  xopt[i] = 1;
164  }
165  else
166  {
167  wGcd(xopt, n);
168 // if (BTEST1(22))
169 // {
170 // f1 = fx + (double)0.1 * (f1 - fx);
171 // wSimple(x, n);
172 // memset(degw, 0, mons * sizeof(int));
173 // for (i = n; i!=0; i--)
174 // wAdd(A, mons, i, x[i], rVar(R));
175 // eps = wPrWeight(x, n);
176 // fx = (*wFunctional)(degw, lpol, npol, rel, eps);
177 // if (fx < f1)
178 // {
179 // if (TEST_OPT_PROT) Print("// %e\n",fx);
180 // memcpy(xopt + 1, x + 1, n * sizeof(int));
181 // }
182 // }
183  }
184  omFreeSize((ADDRESS)A, q);
185  omFreeSize((ADDRESS)lpol, (sl + 1) * sizeof(int));
186  omFreeSize((ADDRESS)adr, npol * sizeof(double));
187 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define Print
Definition: emacs.cc:83
#define TEST_OPT_PROT
Definition: options.h:98
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAllocAligned
Definition: omAllocDecl.h:273
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:537
void wAdd(int *A, int mons, int kn, int xx, int rvar)
Definition: weight0.c:136
void * ADDRESS
Definition: auxiliary.h:161
#define omAlloc(size)
Definition: omAllocDecl.h:210
void wSecondSearch(int *A, int *x, int *lpol, int npol, int mons, double *rel, double *fk, double wNsqr, int rvar)
Definition: weight0.c:299
#define A
Definition: sirandom.c:23
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
static void wDimensions(poly *s, int sl, int *lpol, int *npol, int *mons)
Definition: weight.cc:42
static void wInit(poly *s, int sl, int mons, int *A, const ring R)
Definition: weight.cc:72
Variable x
Definition: cfModGcd.cc:4023
void wFirstSearch(int *A, int *x, int mons, int *lpol, int npol, double *rel, double *fopt, double wNsqr, int rvar)
Definition: weight0.c:156
void wNorm(int *degw, int *lpol, int npol, double *rel)
Definition: weight0.c:467
void wGcd(int *x, int n)
Definition: weight0.c:356
double wFunctionalBuch ( int *  degw,
int *  lpol,
int  npol,
double *  rel,
double  wx,
double  wNsqr 
)

Definition at line 82 of file weight0.c.

84 {
85  int i, j, ecl, ecu, ec;
86  int *ex;
87  double gfmax, ghom, pfmax;
88  double *r;
89 
90  ex = degw;
91  r = rel;
92  gfmax = (double)0.0;
93  ghom = (double)1.0;
94  for (i = 0; i < npol; i++)
95  {
96  ecu = ecl = *ex++;
97  for (j = lpol[i] - 1; j!=0 ; j--)
98  {
99  ec = *ex++;
100  if (ec < ecl)
101  ecl = ec;
102  else if (ec > ecu)
103  ecu = ec;
104  }
105  pfmax = (double)ecl / (double)ecu;
106  if (pfmax < ghom)
107  ghom = pfmax;
108  gfmax += (double)(ecu * ecu) * (*r++);
109  }
110  if (ghom > (double)0.5)
111  gfmax *= ((double)1.0 - (ghom * ghom)) / (double)0.75;
112  return gfmax / pow(wx, wNsqr);
113 }
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:418

Variable Documentation

short* ecartWeights

Definition at line 32 of file weight0.c.

double(* wFunctional) (int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)

Definition at line 26 of file weight.h.