My Project  debian-1:4.1.1-p2+ds-4build2
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

◆ iv2array()

short* iv2array ( intvec iv,
const ring  R 
)

Definition at line 206 of file weight.cc.

207 {
208  short *s=(short *)omAlloc0((rVar(R)+1)*sizeof(short));
209  int len=0;
210  if(iv!=NULL)
211  len=si_min(iv->length(),rVar(R)); // usually: rVar(R)==length()
212  int i;
213  //for(i=pVariables;i>len;i--) s[i]=1;
214  for(i=len;i>0;i--) s[i]=(*iv)[i-1];
215  return s;
216 }

◆ kEcartWeights()

void kEcartWeights ( poly *  s,
int  sl,
short *  eweight,
const ring  R 
)

Definition at line 188 of file weight.cc.

189 {
190  int n, i;
191  int *x;
192 
193  *eweight = 0;
194  n = rVar(R);
197  else
199  x = (int * )omAlloc(2 * (n + 1) * sizeof(int));
200  wCall(s, sl, x, (double)2.0 / (double)n, R);
201  for (i = n; i!=0; i--)
202  eweight[i] = x[i + n + 1];
203  omFreeSize((ADDRESS)x, 2 * (n + 1) * sizeof(int));
204 }

◆ maxdegreeWecart()

long maxdegreeWecart ( poly  p,
int *  l,
ring  r 
)

Definition at line 253 of file weight.cc.

254 {
255  short k=p_GetComp(p, r);
256  int ll=1;
257  long t,max;
258 
259  max=totaldegreeWecart(p, r);
260  pIter(p);
261  while ((p!=NULL) && (p_GetComp(p, r)==k))
262  {
263  t=totaldegreeWecart(p, r);
264  if (t>max) max=t;
265  ll++;
266  pIter(p);
267  }
268  *l=ll;
269  return max;
270 }

◆ totaldegreeWecart()

long totaldegreeWecart ( poly  p,
ring  r 
)

Definition at line 223 of file weight.cc.

224 {
225  int i;
226  long j =0;
227 
228  for (i=rVar(r); i>0; i--)
229  j += (int)(p_GetExp(p,i,r) * ecartWeights[i]);
230  return j;
231 }

◆ totaldegreeWecart_IV()

long totaldegreeWecart_IV ( poly  p,
ring  r,
const short *  w 
)

Definition at line 237 of file weight.cc.

238 {
239  int i;
240  long j =0;
241 
242  for (i=rVar(r); i>0; i--)
243  j += (long)((int)(p_GetExp(p,i,r) * w[i]));
244  return j;
245 }

◆ wCall()

void wCall ( poly *  s,
int  sl,
int *  x,
double  wNsqr,
const ring  R 
)

Definition at line 114 of file weight.cc.

115 {
116  int n, q, npol, mons, i;
117  int *A, *xopt, *lpol, *degw;
118  double f1, fx, eps, *rel;
119  void *adr;
120 
121  n = rVar(R);
122  lpol = (int * )omAlloc((sl + 1) * sizeof(int));
123  wDimensions(s, sl, lpol, &npol, &mons);
124  xopt = x + (n + 1);
125  for (i = n; i!=0; i--)
126  xopt[i] = 1;
127  if (mons==0)
128  {
129  omFreeSize((ADDRESS)lpol, (sl + 1) * sizeof(int));
130  return;
131  }
132  adr = (void * )omAllocAligned(npol * sizeof(double));
133  rel = (double*)adr;
134  q = (n + 1) * mons * sizeof(int);
135  A = (int * )omAlloc(q);
136  wInit(s, sl, mons, A, R);
137  degw = A + (n * mons);
138  memset(degw, 0, mons * sizeof(int));
139  for (i = n; i!=0; i--)
140  wAdd(A, mons, i, 1, rVar(R));
141  wNorm(degw, lpol, npol, rel);
142  f1 = (*wFunctional)(degw, lpol, npol, rel, (double)1.0, wNsqr);
143  if (TEST_OPT_PROT) Print("// %e\n",f1);
144  eps = f1;
145  fx = (double)2.0 * eps;
146  memset(x, 0, (n + 1) * sizeof(int));
147  wFirstSearch(A, x, mons, lpol, npol, rel, &fx, wNsqr, rVar(R));
148  if (TEST_OPT_PROT) Print("// %e\n",fx);
149  memcpy(x + 1, xopt + 1, n * sizeof(int));
150  memset(degw, 0, mons * sizeof(int));
151  for (i = n; i!=0; i--)
152  {
153  x[i] *= 16;
154  wAdd(A, mons, i, x[i], rVar(R));
155  }
156  wSecondSearch(A, x, lpol, npol, mons, rel, &fx, wNsqr, rVar(R));
157  if (TEST_OPT_PROT) Print("// %e\n",fx);
158  if (fx >= eps)
159  {
160  for (i = n; i!=0; i--)
161  xopt[i] = 1;
162  }
163  else
164  {
165  wGcd(xopt, n);
166 // if (BTEST1(22))
167 // {
168 // f1 = fx + (double)0.1 * (f1 - fx);
169 // wSimple(x, n);
170 // memset(degw, 0, mons * sizeof(int));
171 // for (i = n; i!=0; i--)
172 // wAdd(A, mons, i, x[i], rVar(R));
173 // eps = wPrWeight(x, n);
174 // fx = (*wFunctional)(degw, lpol, npol, rel, eps);
175 // if (fx < f1)
176 // {
177 // if (TEST_OPT_PROT) Print("// %e\n",fx);
178 // memcpy(xopt + 1, x + 1, n * sizeof(int));
179 // }
180 // }
181  }
182  omFreeSize((ADDRESS)A, q);
183  omFreeSize((ADDRESS)lpol, (sl + 1) * sizeof(int));
184  omFreeSize((ADDRESS)adr, npol * sizeof(double));
185 }

◆ wFunctionalBuch()

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

Definition at line 78 of file weight0.c.

80 {
81  int i, j, ecl, ecu, ec;
82  int *ex;
83  double gfmax, ghom, pfmax;
84  double *r;
85 
86  ex = degw;
87  r = rel;
88  gfmax = (double)0.0;
89  ghom = (double)1.0;
90  for (i = 0; i < npol; i++)
91  {
92  ecu = ecl = *ex++;
93  for (j = lpol[i] - 1; j!=0 ; j--)
94  {
95  ec = *ex++;
96  if (ec < ecl)
97  ecl = ec;
98  else if (ec > ecu)
99  ecu = ec;
100  }
101  pfmax = (double)ecl / (double)ecu;
102  if (pfmax < ghom)
103  ghom = pfmax;
104  gfmax += (double)(ecu * ecu) * (*r++);
105  }
106  if (ghom > (double)0.5)
107  gfmax *= ((double)1.0 - (ghom * ghom)) / (double)0.75;
108  return gfmax / pow(wx, wNsqr);
109 }

Variable Documentation

◆ ecartWeights

short* ecartWeights

Definition at line 28 of file weight0.c.

◆ wFunctional

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

Definition at line 26 of file weight.h.

si_min
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
wFunctionalBuch
double wFunctionalBuch(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight0.c:78
p_GetComp
#define p_GetComp(p, r)
Definition: monomials.h:71
p_GetExp
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:469
j
int j
Definition: facHensel.cc:105
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition: options.h:102
k
int k
Definition: cfEzgcd.cc:92
ecartWeights
short * ecartWeights
Definition: weight0.c:28
x
Variable x
Definition: cfModGcd.cc:4023
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
wAdd
void wAdd(int *A, int mons, int kn, int xx, int rvar)
Definition: weight0.c:132
omAllocAligned
#define omAllocAligned
Definition: omAllocDecl.h:273
totaldegreeWecart
long totaldegreeWecart(poly p, ring r)
Definition: weight.cc:223
w
const CanonicalForm & w
Definition: facAbsFact.cc:55
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
i
int i
Definition: cfEzgcd.cc:125
rHasLocalOrMixedOrdering
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:752
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
wSecondSearch
void wSecondSearch(int *A, int *x, int *lpol, int npol, int mons, double *rel, double *fk, double wNsqr, int rvar)
Definition: weight0.c:295
wFunctionalMora
double wFunctionalMora(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight0.c:34
max
static int max(int a, int b)
Definition: fast_mult.cc:264
pIter
#define pIter(p)
Definition: monomials.h:44
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
wFunctional
double(* wFunctional)(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight.cc:26
wCall
void wCall(poly *s, int sl, int *x, double wNsqr, const ring R)
Definition: weight.cc:114
wDimensions
static void wDimensions(poly *s, int sl, int *lpol, int *npol, int *mons)
Definition: weight.cc:40
Print
#define Print
Definition: emacs.cc:80
wFirstSearch
void wFirstSearch(int *A, int *x, int mons, int *lpol, int npol, double *rel, double *fopt, double wNsqr, int rvar)
Definition: weight0.c:152
pow
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:414
wNorm
void wNorm(int *degw, int *lpol, int npol, double *rel)
Definition: weight0.c:463
wInit
static void wInit(poly *s, int sl, int mons, int *A, const ring R)
Definition: weight.cc:70
NULL
#define NULL
Definition: omList.c:10
l
int l
Definition: cfEzgcd.cc:93
R
#define R
Definition: sirandom.c:26
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
intvec::length
int length() const
Definition: intvec.h:94
wGcd
void wGcd(int *x, int n)
Definition: weight0.c:352
A
#define A
Definition: sirandom.c:23
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211