My Project  UNKNOWN_GIT_VERSION
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 418 of file maps_ip.cc.

419 {
420 
421 #ifdef HAVE_PLURAL
422  if (rIsPluralRing(currRing))
423  {
424  int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
425  ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
426  res->rank = id->rank;
427  for(k--;k>=0;k--)
428  {
429  res->m[k]=pSubst(pCopy(id->m[k]),n,e);
430  }
431  return res;
432  }
433 #endif
434  return id_SubstPoly(id,n,e,currRing,currRing,ndCopyMap);
435 }

◆ maCopy()

map maCopy ( map  theMap,
const ring  dst_ring 
)

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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ maIMap()

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

◆ 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 }

◆ 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 }

◆ pSubstPoly()

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

Definition at line 402 of file maps_ip.cc.

403 {
404  if (p==NULL) return NULL;
405 #ifdef HAVE_PLURAL
406  if (rIsPluralRing(currRing))
407  {
408  return pSubst(pCopy(p),var,image);
409  }
410 #endif
411  return p_SubstPoly(p,var,image,currRing,currRing,ndCopyMap);
412 }
p_GetCoeff
#define p_GetCoeff(p, r)
Definition: monomials.h:51
ip_smatrix
Definition: matpol.h:15
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:470
j
int j
Definition: facHensel.cc:105
p_Normalize
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3723
k
int k
Definition: cfEzgcd.cc:92
MATELEM
#define MATELEM(mat, i, j)
Definition: matpol.h:28
result
return result
Definition: facAbsBiFact.cc:76
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
map
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
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
ndCopyMap
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:252
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
n_GF
@ n_GF
\GF{p^n < 2^16}
Definition: coeffs.h:33
N
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
maEvalMonom
static poly maEvalMonom(map theMap, poly p, ring preimage_r, ideal s, nMapFunc nMap, const ring dst_r)
Definition: maps.cc:87
spolyrec::next
poly next
Definition: monomials.h:25
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:398
pLength
static unsigned pLength(poly a)
Definition: p_polys.h:193
p_Copy
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:813
p_Power
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2144
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
i
int i
Definition: cfEzgcd.cc:125
res
CanonicalForm res
Definition: facAbsFact.cc:64
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
nCoeff_is_algExt
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:932
ip_smatrix::m
poly * m
Definition: matpol.h:18
p_LmDelete
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:712
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1088
pIter
#define pIter(p)
Definition: monomials.h:38
n_Mult
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:636
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
n_Init
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:538
spolyrec
Definition: monomials.h:24
mpNew
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
p_MinPolyNormalize
poly p_MinPolyNormalize(poly p, const ring r)
Definition: maps.cc:324
MAX_MAP_DEG
#define MAX_MAP_DEG
Definition: maps.cc:29
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:893
p_SubstPoly
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
si_max
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
id_SubstPoly
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
BVERBOSE
#define BVERBOSE(a)
Definition: options.h:35
Print
#define Print
Definition: emacs.cc:80
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
p_SetCoeff
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:413
m
int m
Definition: cfEzgcd.cc:121
MATCOLS
#define MATCOLS(i)
Definition: matpol.h:27
assume
#define assume(x)
Definition: mod2.h:390
NULL
#define NULL
Definition: omList.c:10
l
int l
Definition: cfEzgcd.cc:93
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
pCopy
#define pCopy(p)
return a copy of the poly
Definition: polys.h:180
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:24
MATROWS
#define MATROWS(i)
Definition: matpol.h:26
V_IMAP
#define V_IMAP
Definition: options.h:53
pNext
#define pNext(p)
Definition: monomials.h:37
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
pSubst
#define pSubst(p, n, e)
Definition: polys.h:360