Functions
maps.h File Reference
#include <coeffs/coeffs.h>
#include <polys/monomials/ring.h>

Go to the source code of this file.

Functions

poly maEval (map theMap, poly p, ring preimage_r, nMapFunc nMap, ideal s, const ring dst_r)
 
map maCopy (map theMap, const ring dst_ring)
 
poly maIMap (ring src_ring, ring dst_ring, poly p)
 
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 pSubstPoly (poly p, int var, poly image)
 
ideal idSubstPoly (ideal id, int n, poly e)
 
poly p_MinPolyNormalize (poly p, const ring r)
 
int maMaxDeg_P (poly p, ring preimage_r)
 
int maMaxDeg_Ma (ideal a, ring preimage_r)
 
poly maEvalVariable (poly p, int v, int pExp, ideal s, const ring dst_r)
 

Function Documentation

◆ idSubstPoly()

ideal idSubstPoly ( ideal  id,
int  n,
poly  e 
)

Definition at line 406 of file maps_ip.cc.

407 {
408 
409 #ifdef HAVE_PLURAL
410  if (rIsPluralRing(currRing))
411  {
412  int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
413  ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
414  res->rank = id->rank;
415  for(k--;k>=0;k--)
416  {
417  res->m[k]=pSubst(pCopy(id->m[k]),n,e);
418  }
419  return res;
420  }
421 #endif
422  return id_SubstPoly(id,n,e,currRing,currRing,ndCopyMap);
423 }
#define pSubst(p, n, e)
Definition: polys.h:348
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:244
int k
Definition: cfEzgcd.cc:93
poly res
Definition: myNF.cc:322
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
poly * m
Definition: matpol.h:19
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
#define MATCOLS(i)
Definition: matpol.h:28
ideal id_SubstPoly(ideal id, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap)
Definition: subst_maps.cc:68
#define MATROWS(i)
Definition: matpol.h:27
long rank
Definition: matpol.h:20
#define pCopy(p)
return a copy of the poly
Definition: polys.h:168

◆ maCopy()

map maCopy ( map  theMap,
const ring  dst_ring 
)

Definition at line 38 of file maps.cc.

39 {
40  int i;
41  map m=(map)idInit(IDELEMS(theMap),0);
42  for (i=IDELEMS(theMap)-1; i>=0; i--)
43  m->m[i] = p_Copy(theMap->m[i],r);
44  m->preimage=omStrDup(theMap->preimage);
45  return m;
46 }
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
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
const ring r
Definition: syzextra.cc:208
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ maEval()

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

Definition at line 121 of file maps.cc.

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

◆ maEvalVariable()

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

Definition at line 52 of file maps.cc.

53 {
54  if (pExp==1)
55  return p_Copy(p,dst_r);
56 
57  poly res;
58 
59  if((s!=NULL)&&(pExp<MAX_MAP_DEG))
60  {
61  int j=2;
62  poly p0=p;
63  // find starting point
64  if(MATELEM(s,v,1)==NULL)
65  {
66  MATELEM(s,v,1)=p_Copy(p/*theMap->m[v-1]*/,dst_r);
67  }
68  else
69  {
70  while((j<=pExp)&&(MATELEM(s,v,j)!=NULL))
71  {
72  j++;
73  }
74  p0=MATELEM(s,v,j-1);
75  }
76  // multiply
77  for(;j<=pExp;j++)
78  {
79  p0=MATELEM(s,v,j)=pp_Mult_qq(p0, p,dst_r);
80  p_Normalize(p0, dst_r);
81  }
82  res=p_Copy(p0/*MATELEM(s,v,pExp)*/,dst_r);
83  }
84  else //if ((p->next!=NULL)&&(p->next->next==NULL))
85  {
86  res=p_Power(p_Copy(p,dst_r),pExp,dst_r);
87  }
88  return res;
89 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define MAX_MAP_DEG
Definition: maps.cc:33
return P p
Definition: myNF.cc:203
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1070
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3680
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2158
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ 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 169 of file maps.cc.

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

◆ maIMap()

poly maIMap ( ring  src_ring,
ring  dst_ring,
poly  p 
)

◆ maMaxDeg_Ma()

int maMaxDeg_Ma ( ideal  a,
ring  preimage_r 
)

Definition at line 258 of file maps.cc.

259 {
260  int i,j;
261  int N = preimage_r->N;
262  poly p;
263  int *m=(int *)omAlloc0(N*sizeof(int));
264 
265  for (i=MATROWS(a)*MATCOLS(a)-1;i>=0;i--)
266  {
267  p=a->m[i];
268  //pTest(p); // cannot test p because it is from another ring
269  while(p!=NULL)
270  {
271  for(j=N-1;j>=0;j--)
272  {
273  m[j]=si_max(m[j],(int)p_GetExp( p,j+1,preimage_r));
274  if (m[j]>=MAX_MAP_DEG)
275  {
276  i=MAX_MAP_DEG;
277  goto max_deg_fertig_id;
278  }
279  }
280  pIter(p);
281  }
282  }
283  i=m[0];
284  for(j=N-1;j>0;j--)
285  {
286  i=si_max(i,m[j]);
287  }
288 max_deg_fertig_id:
289  omFreeSize((ADDRESS)m,N*sizeof(int));
290  return i;
291 }
const poly a
Definition: syzextra.cc:212
#define MAX_MAP_DEG
Definition: maps.cc:33
return P p
Definition: myNF.cc:203
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:115
#define pIter(p)
Definition: monomials.h:44
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
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 m
Definition: cfEzgcd.cc:119
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ maMaxDeg_P()

int maMaxDeg_P ( poly  p,
ring  preimage_r 
)

Definition at line 296 of file maps.cc.

297 {
298  int i,j;
299  int N = preimage_r->N;
300  int *m=(int *)omAlloc0(N*sizeof(int));
301 
302 // pTest(p);
303  while(p!=NULL)
304  {
305  for(j=N-1;j>=0;j--)
306  {
307  m[j]=si_max(m[j],(int)p_GetExp(p,j+1,preimage_r));
308  if (m[j]>=MAX_MAP_DEG)
309  {
310  i=MAX_MAP_DEG;
311  goto max_deg_fertig_p;
312  }
313  }
314  pIter(p);
315  }
316  i=m[0];
317  for(j=N-1;j>0;j--)
318  {
319  i=si_max(i,m[j]);
320  }
321 max_deg_fertig_p:
322  omFreeSize((ADDRESS)m,N*sizeof(int));
323  return i;
324 }
#define MAX_MAP_DEG
Definition: maps.cc:33
return P p
Definition: myNF.cc:203
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:115
#define pIter(p)
Definition: monomials.h:44
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
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 m
Definition: cfEzgcd.cc:119
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ p_MinPolyNormalize()

poly p_MinPolyNormalize ( poly  p,
const ring  r 
)

Definition at line 328 of file maps.cc.

329 {
330  const coeffs C = r->cf;
331  number one = n_Init(1, C);
332  spolyrec rp;
333 
334  poly q = &rp;
335 
336  while (p != NULL)
337  {
338  // this returns 0, if p == MinPoly
339  number product = n_Mult(p_GetCoeff(p, r), one, C);
340  if ((product == NULL)||(n_IsZero(product, C)))
341  {
342  p_LmDelete(&p, r);
343  }
344  else
345  {
346  p_SetCoeff(p, product, r);
347  pNext(q) = p;
348  q = p;
349  p = pNext(p);
350  }
351  }
352  pNext(q) = NULL;
353  n_Delete(&one, C);
354  return rp.next;
355 }
return P p
Definition: myNF.cc:203
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:542
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:407
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
const ring r
Definition: syzextra.cc:208
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:706
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
polyrec * poly
Definition: hilb.h:10
poly next
Definition: monomials.h:31

◆ pSubstPoly()

poly pSubstPoly ( poly  p,
int  var,
poly  image 
)

Definition at line 390 of file maps_ip.cc.

391 {
392  if (p==NULL) return NULL;
393 #ifdef HAVE_PLURAL
394  if (rIsPluralRing(currRing))
395  {
396  return pSubst(pCopy(p),var,image);
397  }
398 #endif
399  return p_SubstPoly(p,var,image,currRing,currRing,ndCopyMap);
400 }
#define pSubst(p, n, e)
Definition: polys.h:348
return P p
Definition: myNF.cc:203
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:244
poly p_SubstPoly(poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache=NULL)
Definition: subst_maps.cc:39
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
#define NULL
Definition: omList.c:10
#define pCopy(p)
return a copy of the poly
Definition: polys.h:168