My Project  debian-1:4.1.1-p2+ds-4build4
Macros | Functions
maps.cc File Reference
#include "omalloc/omalloc.h"
#include "misc/auxiliary.h"
#include "misc/options.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "polys/monomials/p_polys.h"
#include "polys/monomials/ring.h"
#include "polys/simpleideals.h"
#include "polys/prCopy.h"
#include "polys/monomials/maps.h"
#include "polys/nc/nc.h"

Go to the source code of this file.

Macros

#define MAX_MAP_DEG   128
 

Functions

map maCopy (map theMap, const ring r)
 
poly maEvalVariable (poly p, int v, int pExp, ideal s, const ring dst_r)
 
static poly maEvalMonom (map theMap, poly p, ring preimage_r, ideal s, nMapFunc nMap, const ring dst_r)
 
poly maEval (map theMap, poly p, ring preimage_r, nMapFunc nMap, ideal s, const ring dst_r)
 
void maFindPerm (char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
 
poly maIMap (ring r, poly p, const ring dst_r)
 
int maMaxDeg_Ma (ideal a, ring preimage_r)
 
int maMaxDeg_P (poly p, ring preimage_r)
 
poly p_MinPolyNormalize (poly p, const ring r)
 

Macro Definition Documentation

◆ MAX_MAP_DEG

#define MAX_MAP_DEG   128

Definition at line 29 of file maps.cc.

Function Documentation

◆ maCopy()

map maCopy ( map  theMap,
const ring  r 
)

Definition at line 34 of file maps.cc.

35 {
36  int i;
37  map m=(map)idInit(IDELEMS(theMap),0);
38  for (i=IDELEMS(theMap)-1; i>=0; i--)
39  m->m[i] = p_Copy(theMap->m[i],r);
40  m->preimage=omStrDup(theMap->preimage);
41  return m;
42 }
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
Definition: cf_map_ext.cc:400
#define omStrDup(s)
Definition: omAllocDecl.h:263
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
#define IDELEMS(i)
Definition: simpleideals.h:24

◆ maEval()

poly maEval ( map  theMap,
poly  p,
ring  preimage_r,
nMapFunc  nMap,
ideal  s,
const ring  dst_r 
)

Definition at line 117 of file maps.cc.

118 {
119  poly result = NULL;
120  int i;
121 
122 // for(i=1; i<=preimage_r->N; i++)
123 // {
124 // pTest(theMap->m[i-1]);
125 // }
126 // while (p!=NULL)
127 // {
128 // poly q=maEvalMonom(theMap,p,preimage_r,s);
129 // result = pAdd(result,q);
130 // pIter(p);
131 // }
132  if (p!=NULL)
133  {
134  int l = pLength(p)-1;
135  poly* monoms;
136  if (l>0)
137  {
138  monoms = (poly*) omAlloc(l*sizeof(poly));
139 
140  for (i=0; i<l; i++)
141  {
142  monoms[i]=maEvalMonom(theMap,p,preimage_r,s, nMap, dst_r);
143  pIter(p);
144  }
145  }
146  result=maEvalMonom(theMap,p,preimage_r,s, nMap, dst_r);
147  if (l>0)
148  {
149  for(i = l-1; i>=0; i--)
150  {
151  result=p_Add_q(result, monoms[i], dst_r);
152  }
153  omFreeSize((ADDRESS)monoms,l*sizeof(poly));
154  }
155 
156  assume(dst_r != NULL);
157  assume(dst_r->cf != NULL);
158 
159  if (nCoeff_is_algExt(dst_r->cf))
160  result = p_MinPolyNormalize(result, dst_r);
161  }
162  return result;
163 }
void * ADDRESS
Definition: auxiliary.h:133
int l
Definition: cfEzgcd.cc:93
int p
Definition: cfModGcd.cc:4019
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:924
return result
Definition: facAbsBiFact.cc:76
const CanonicalForm int s
Definition: facAbsFact.cc:55
static poly maEvalMonom(map theMap, poly p, ring preimage_r, ideal s, nMapFunc nMap, const ring dst_r)
Definition: maps.cc:87
poly p_MinPolyNormalize(poly p, const ring r)
Definition: maps.cc:324
#define assume(x)
Definition: mod2.h:390
#define pIter(p)
Definition: monomials.h:44
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define NULL
Definition: omList.c:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
static unsigned pLength(poly a)
Definition: p_polys.h:192

◆ maEvalMonom()

static poly maEvalMonom ( map  theMap,
poly  p,
ring  preimage_r,
ideal  s,
nMapFunc  nMap,
const ring  dst_r 
)
static

Definition at line 87 of file maps.cc.

89 {
90  p_Test(p,preimage_r);
91  poly q=p_NSet(nMap(pGetCoeff(p),preimage_r->cf,dst_r->cf),dst_r);
92 
93  int i;
94  for(i=1;i<=preimage_r->N; i++)
95  {
96  int pExp=p_GetExp( p,i,preimage_r);
97  if (pExp != 0)
98  {
99  if (theMap->m[i-1]!=NULL)
100  {
101  poly p1=theMap->m[i-1];
102  poly pp=maEvalVariable(p1,i,pExp,s,dst_r);
103  q = p_Mult_q(q,pp,dst_r);
104  }
105  else
106  {
107  p_Delete(&q,dst_r);
108  break;
109  }
110  }
111  }
112  int modulComp = p_GetComp( p,preimage_r);
113  if (q!=NULL) p_SetCompP(q,modulComp,dst_r);
114  return q;
115 }
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
poly maEvalVariable(poly p, int v, int pExp, ideal s, const ring dst_r)
Definition: maps.cc:48
#define p_GetComp(p, r)
Definition: monomials.h:71
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:51
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:254
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
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define p_Test(p, r)
Definition: p_polys.h:163

◆ maEvalVariable()

poly maEvalVariable ( poly  p,
int  v,
int  pExp,
ideal  s,
const ring  dst_r 
)

Definition at line 48 of file maps.cc.

49 {
50  if (pExp==1)
51  return p_Copy(p,dst_r);
52 
53  poly res;
54 
55  if((s!=NULL)&&(pExp<MAX_MAP_DEG))
56  {
57  int j=2;
58  poly p0=p;
59  // find starting point
60  if(MATELEM(s,v,1)==NULL)
61  {
62  MATELEM(s,v,1)=p_Copy(p/*theMap->m[v-1]*/,dst_r);
63  }
64  else
65  {
66  while((j<=pExp)&&(MATELEM(s,v,j)!=NULL))
67  {
68  j++;
69  }
70  p0=MATELEM(s,v,j-1);
71  }
72  // multiply
73  for(;j<=pExp;j++)
74  {
75  p0=MATELEM(s,v,j)=pp_Mult_qq(p0, p,dst_r);
76  p_Normalize(p0, dst_r);
77  }
78  res=p_Copy(p0/*MATELEM(s,v,pExp)*/,dst_r);
79  }
80  else //if ((p->next!=NULL)&&(p->next->next==NULL))
81  {
82  res=p_Power(p_Copy(p,dst_r),pExp,dst_r);
83  }
84  return res;
85 }
CanonicalForm res
Definition: facAbsFact.cc:64
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
int j
Definition: facHensel.cc:105
#define MAX_MAP_DEG
Definition: maps.cc:29
#define MATELEM(mat, i, j)
Definition: matpol.h:28
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2144
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1093

◆ maFindPerm()

void maFindPerm ( char const *const *const  preim_names,
int  preim_n,
char const *const *const  preim_par,
int  preim_p,
char const *const *const  names,
int  n,
char const *const *const  par,
int  nop,
int *  perm,
int *  par_perm,
n_coeffType  ch 
)

Definition at line 165 of file maps.cc.

168 {
169  int i,j;
170  /* find correspondig vars */
171  for (i=0; i<preim_n; i++)
172  {
173  for(j=0; j<n; j++)
174  {
175  if (strcmp(preim_names[i],names[j])==0)
176  {
177  if (BVERBOSE(V_IMAP))
178  Print("// var %s: nr %d -> nr %d\n",preim_names[i],i+1,j+1);
179  /* var i+1 from preimage ring is var j+1 (index j+1) from image ring */
180  perm[i+1]=j+1;
181  break;
182  }
183  }
184  if ((perm[i+1]==0)&&(par!=NULL)
185  // do not consider par of Fq
186  && (ch!=n_GF))
187  {
188  for(j=0; j<nop; j++)
189  {
190  if (strcmp(preim_names[i],par[j])==0)
191  {
192  if (BVERBOSE(V_IMAP))
193  Print("// var %s: nr %d -> par %d\n",preim_names[i],i+1,j+1);
194  /* var i+1 from preimage ring is par j+1 (index j) from image ring */
195  perm[i+1]=-(j+1);
196  }
197  }
198  }
199  }
200  if (par_perm!=NULL)
201  {
202  for (i=0; i<preim_p; i++)
203  {
204  for(j=0; j<n; j++)
205  {
206  if (strcmp(preim_par[i],names[j])==0)
207  {
208  if (BVERBOSE(V_IMAP))
209  Print("// par %s: par %d -> nr %d\n",preim_par[i],i+1,j+1);
210  /*par i+1 from preimage ring is var j+1 (index j+1) from image ring*/
211  par_perm[i]=j+1;
212  break;
213  }
214  }
215  if ((par!=NULL) && (par_perm[i]==0))
216  {
217  for(j=0; j<nop; j++)
218  {
219  if (strcmp(preim_par[i],par[j])==0)
220  {
221  if (BVERBOSE(V_IMAP))
222  Print("// par %s: nr %d -> par %d\n",preim_par[i],i+1,j+1);
223  /*par i+1 from preimage ring is par j+1 (index j) from image ring */
224  par_perm[i]=-(j+1);
225  }
226  }
227  }
228  }
229  }
230 }
@ n_GF
\GF{p^n < 2^16}
Definition: coeffs.h:33
#define Print
Definition: emacs.cc:80
#define BVERBOSE(a)
Definition: options.h:35
#define V_IMAP
Definition: options.h:53

◆ maIMap()

poly maIMap ( ring  r,
poly  p,
const ring  dst_r 
)

Definition at line 235 of file maps.cc.

236 {
237  /* the simplest case:*/
238  if(r==dst_r) return p_Copy(p,dst_r);
239  nMapFunc nMap=n_SetMap(r->cf,dst_r->cf);
240  int *perm=(int *)omAlloc0((r->N+1)*sizeof(int));
241  //int *par_perm=(int *)omAlloc0(rPar(r)*sizeof(int));
242  maFindPerm(r->names, rVar(r), rParameter(r), rPar(r),
243  dst_r->names, rVar(dst_r),rParameter(dst_r), rPar(dst_r),
244  perm,NULL, dst_r->cf->type);
245  poly res=p_PermPoly(p,perm,r,dst_r, nMap /*,par_perm,rPar(r)*/);
246  omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int));
247  //omFreeSize((ADDRESS)par_perm,rPar(r)*sizeof(int));
248  return res;
249 }
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:722
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition: maps.cc:165
#define omAlloc0(size)
Definition: omAllocDecl.h:211
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition: p_polys.cc:4014
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition: ring.h:616
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583

◆ maMaxDeg_Ma()

int maMaxDeg_Ma ( ideal  a,
ring  preimage_r 
)

Definition at line 254 of file maps.cc.

255 {
256  int i,j;
257  int N = preimage_r->N;
258  poly p;
259  int *m=(int *)omAlloc0(N*sizeof(int));
260 
261  for (i=MATROWS(a)*MATCOLS(a)-1;i>=0;i--)
262  {
263  p=a->m[i];
264  //pTest(p); // cannot test p because it is from another ring
265  while(p!=NULL)
266  {
267  for(j=N-1;j>=0;j--)
268  {
269  m[j]=si_max(m[j],(int)p_GetExp( p,j+1,preimage_r));
270  if (m[j]>=MAX_MAP_DEG)
271  {
272  i=MAX_MAP_DEG;
273  goto max_deg_fertig_id;
274  }
275  }
276  pIter(p);
277  }
278  }
279  i=m[0];
280  for(j=N-1;j>0;j--)
281  {
282  i=si_max(i,m[j]);
283  }
284 max_deg_fertig_id:
285  omFreeSize((ADDRESS)m,N*sizeof(int));
286  return i;
287 }
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27

◆ maMaxDeg_P()

int maMaxDeg_P ( poly  p,
ring  preimage_r 
)

Definition at line 292 of file maps.cc.

293 {
294  int i,j;
295  int N = preimage_r->N;
296  int *m=(int *)omAlloc0(N*sizeof(int));
297 
298 // pTest(p);
299  while(p!=NULL)
300  {
301  for(j=N-1;j>=0;j--)
302  {
303  m[j]=si_max(m[j],(int)p_GetExp(p,j+1,preimage_r));
304  if (m[j]>=MAX_MAP_DEG)
305  {
306  i=MAX_MAP_DEG;
307  goto max_deg_fertig_p;
308  }
309  }
310  pIter(p);
311  }
312  i=m[0];
313  for(j=N-1;j>0;j--)
314  {
315  i=si_max(i,m[j]);
316  }
317 max_deg_fertig_p:
318  omFreeSize((ADDRESS)m,N*sizeof(int));
319  return i;
320 }

◆ p_MinPolyNormalize()

poly p_MinPolyNormalize ( poly  p,
const ring  r 
)

Definition at line 324 of file maps.cc.

325 {
326  const coeffs C = r->cf;
327  number one = n_Init(1, C);
328  spolyrec rp;
329 
330  poly q = &rp;
331 
332  while (p != NULL)
333  {
334  // this returns 0, if p == MinPoly
335  number product = n_Mult(p_GetCoeff(p, r), one, C);
336  if ((product == NULL)||(n_IsZero(product, C)))
337  {
338  p_LmDelete(&p, r);
339  }
340  else
341  {
342  p_SetCoeff(p, product, r);
343  pNext(q) = p;
344  q = p;
345  p = pNext(p);
346  }
347  }
348  pNext(q) = NULL;
349  n_Delete(&one, C);
350  return rp.next;
351 }
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:637
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:465
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
poly next
Definition: monomials.h:31
#define pNext(p)
Definition: monomials.h:43
#define p_GetCoeff(p, r)
Definition: monomials.h:57
The main handler for Singular numbers which are suitable for Singular polynomials.
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:711
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412