Functions
maps_ip.h File Reference
#include "kernel/mod2.h"
#include "polys/matpol.h"
#include "kernel/structs.h"
#include "kernel/ideals.h"
#include "kernel/polys.h"

Go to the source code of this file.

Functions

poly pSubstPoly (poly p, int var, poly image)
 
poly pSubstPar (poly p, int par, poly image)
 
ideal idSubstPoly (ideal id, int n, poly e)
 
ideal idSubstPar (ideal id, int n, poly e)
 
BOOLEAN maApplyFetch (int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
 

Function Documentation

◆ idSubstPar()

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

Definition at line 370 of file maps_ip.cc.

371 {
372  int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
373  ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
374 
375  res->rank = id->rank;
376  for(k--;k>=0;k--)
377  {
378  res->m[k]=pSubstPar(id->m[k],n,e);
379  }
380  return res;
381 }
int k
Definition: cfEzgcd.cc:92
poly * m
Definition: matpol.h:18
CanonicalForm res
Definition: facAbsFact.cc:64
poly pSubstPar(poly p, int par, poly image)
Definition: maps_ip.cc:250
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
#define MATCOLS(i)
Definition: matpol.h:27
#define MATROWS(i)
Definition: matpol.h:26
long rank
Definition: matpol.h:19

◆ idSubstPoly()

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

Definition at line 403 of file maps_ip.cc.

404 {
405 
406 #ifdef HAVE_PLURAL
407  if (rIsPluralRing(currRing))
408  {
409  int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
410  ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
411  res->rank = id->rank;
412  for(k--;k>=0;k--)
413  {
414  res->m[k]=pSubst(pCopy(id->m[k]),n,e);
415  }
416  return res;
417  }
418 #endif
419  return id_SubstPoly(id,n,e,currRing,currRing,ndCopyMap);
420 }
#define pSubst(p, n, e)
Definition: polys.h:352
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
int k
Definition: cfEzgcd.cc:92
poly * m
Definition: matpol.h:18
CanonicalForm res
Definition: facAbsFact.cc:64
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:36
#define MATCOLS(i)
Definition: matpol.h:27
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
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:26
long rank
Definition: matpol.h:19
#define pCopy(p)
return a copy of the poly
Definition: polys.h:172

◆ maApplyFetch()

BOOLEAN maApplyFetch ( int  what,
map  theMap,
leftv  res,
leftv  w,
ring  preimage_r,
int *  perm,
int *  par_perm,
int  P,
nMapFunc  nMap 
)

Definition at line 46 of file maps_ip.cc.

48 {
49  BOOLEAN use_mult=FALSE;
50 #ifdef HAVE_PLURAL
51  if ((what==IMAP_CMD)
53  && rIsPluralRing(preimage_r))
54  {
55  assume(perm!=NULL);
56  int i=1;
57  while((i<currRing->N)&&(perm[i]==0)) i++;
58  if (i<currRing->N)
59  {
60  int prev_nonnull=i;
61  i++;
62  for(;i<=currRing->N;i++)
63  {
64  if (perm[prev_nonnull] > perm[i])
65  {
66  if (TEST_V_ALLWARN)
67  {
68  Warn("imap not usable for permuting variables, use map (%s <-> %s)",currRing->names[prev_nonnull-1],currRing->names[i-1]);
69  }
70  use_mult=TRUE;
71  break;
72  }
73  else
74  prev_nonnull=i;
75  }
76  }
77  }
78 #endif
79  int i;
80  int N = preimage_r->N;
81 #if 0
82  Print("N=%d what=%s ",N,Tok2Cmdname(what));
83  if (perm!=NULL) for(i=1;i<=N;i++) Print("%d -> %d ",i,perm[i]);
84  PrintS("\n");
85  Print("P=%d ",P);
86  if (par_perm!=NULL) for(i=0;i<P;i++) Print("%d -> %d ",i,par_perm[i]);
87  PrintS("\n");
88 #endif
89 
90  void *data=w->Data();
91  res->rtyp = w->rtyp;
92  switch (w->rtyp)
93  {
94  case NUMBER_CMD:
95  if (P!=0)
96  {
97 // poly n_PermNumber(const number z, const int *par_perm, const int OldPar, const ring src, const ring dst);
98  res->data= (void *) n_PermNumber((number)data, par_perm, P, preimage_r, currRing);
99  res->rtyp=POLY_CMD;
100  if (nCoeff_is_algExt(currRing->cf))
101  res->data=(void *)p_MinPolyNormalize((poly)res->data, currRing);
102  pTest((poly) res->data);
103  }
104  else
105  {
106  assume( nMap != NULL );
107  number a = nMap((number)data, preimage_r->cf, currRing->cf);
108  if (nCoeff_is_Extension(currRing->cf))
109  {
110  n_Normalize(a, currRing->cf);
111 /*
112  number a = (number)res->data;
113  number one = nInit(1);
114  number product = nMult(a, one );
115  nDelete(&one);
116  nDelete(&a);
117  res->data=(void *)product;
118  */
119  }
120  #ifdef LDEBUG
121  n_Test(a, currRing->cf);
122  #endif
123  res->data=(void *)a;
124 
125  }
126  break;
127  case POLY_CMD:
128  case VECTOR_CMD:
129  if ((what==FETCH_CMD)&& (preimage_r->cf==currRing->cf))
130  res->data=(void *)prCopyR( (poly)data, preimage_r, currRing);
131  else
132  if ( (what==IMAP_CMD) || /*(*/ (what==FETCH_CMD) /*)*/) /* && (nMap!=nCopy)*/
133  res->data=(void *)p_PermPoly((poly)data,perm,preimage_r,currRing, nMap,par_perm,P,use_mult);
134  else /*if (what==MAP_CMD)*/
135  {
136  p_Test((poly)data,preimage_r);
137  matrix s=mpNew(N,maMaxDeg_P((poly)data, preimage_r));
138  res->data=(void *)maEval(theMap, (poly)data, preimage_r, nMap, (ideal)s, currRing);
139  idDelete((ideal *)&s);
140  }
141  if (nCoeff_is_Extension(currRing->cf))
142  res->data=(void *)p_MinPolyNormalize((poly)res->data, currRing);
143  pTest((poly)res->data);
144  break;
145  case MODUL_CMD:
146  case MATRIX_CMD:
147  case IDEAL_CMD:
148  case MAP_CMD:
149  {
150  int C=((matrix)data)->cols();
151  int R;
152  if (w->rtyp==MAP_CMD) R=1;
153  else R=((matrix)data)->rows();
154  matrix m=mpNew(R,C);
155  char *tmpR=NULL;
156  if(w->rtyp==MAP_CMD)
157  {
158  tmpR=((map)data)->preimage;
159  ((matrix)data)->rank=((matrix)data)->rows();
160  }
161  if ((what==FETCH_CMD)&& (preimage_r->cf == currRing->cf))
162  {
163  for (i=R*C-1;i>=0;i--)
164  {
165  m->m[i]=prCopyR(((ideal)data)->m[i], preimage_r, currRing);
166  pTest(m->m[i]);
167  }
168  }
169  else if ((what==IMAP_CMD) || (what==FETCH_CMD))
170  {
171  for (i=R*C-1;i>=0;i--)
172  {
173  m->m[i]=p_PermPoly(((ideal)data)->m[i],perm,preimage_r,currRing,
174  nMap,par_perm,P,use_mult);
175  pTest(m->m[i]);
176  }
177  }
178  else /* (what==MAP_CMD) */
179  {
180  assume(what==MAP_CMD);
181  matrix s=mpNew(N,maMaxDeg_Ma((ideal)data,preimage_r));
182  for (i=R*C-1;i>=0;i--)
183  {
184  m->m[i]=maEval(theMap, ((ideal)data)->m[i], preimage_r, nMap, (ideal)s, currRing);
185  pTest(m->m[i]);
186  }
187  idDelete((ideal *)&s);
188  }
189  if (nCoeff_is_algExt(currRing->cf))
190  {
191  for (i=R*C-1;i>=0;i--)
192  {
193  m->m[i]=p_MinPolyNormalize(m->m[i], currRing);
194  pTest(m->m[i]);
195  }
196  }
197  if(w->rtyp==MAP_CMD)
198  {
199  ((map)data)->preimage=tmpR;
200  ((map)m)->preimage=omStrDup(tmpR);
201  }
202  else
203  {
204  m->rank=((matrix)data)->rank;
205  }
206  res->data=(char *)m;
207  idTest((ideal) m);
208  break;
209  }
210 
211  case LIST_CMD:
212  {
213  lists l=(lists)data;
215  ml->Init(l->nr+1);
216  for(i=0;i<=l->nr;i++)
217  {
218  if (((l->m[i].rtyp>BEGIN_RING)&&(l->m[i].rtyp<END_RING))
219  ||(l->m[i].rtyp==LIST_CMD))
220  {
221  if (maApplyFetch(what,theMap,&ml->m[i],&l->m[i],
222  preimage_r,perm,par_perm,P,nMap))
223  {
224  ml->Clean();
226  res->rtyp=0;
227  return TRUE;
228  }
229  }
230  else
231  {
232  ml->m[i].Copy(&l->m[i]);
233  }
234  }
235  res->data=(char *)ml;
236  break;
237  }
238  default:
239  {
240  return TRUE;
241  }
242  }
243  return FALSE;
244 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
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
const CanonicalForm int s
Definition: facAbsFact.cc:55
sleftv * m
Definition: lists.h:45
#define Print
Definition: emacs.cc:80
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:35
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
Definition: lists.h:22
#define FALSE
Definition: auxiliary.h:94
#define pTest(p)
Definition: polys.h:401
int maMaxDeg_Ma(ideal a, ring preimage_r)
Definition: maps.cc:254
#define TRUE
Definition: auxiliary.h:98
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
Definition: maps_ip.cc:46
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:579
void * ADDRESS
Definition: auxiliary.h:133
void * data
Definition: subexpr.h:88
poly * m
Definition: matpol.h:18
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 FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:924
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
#define assume(x)
Definition: mod2.h:390
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
void Copy(leftv e)
Definition: subexpr.cc:684
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
#define p_Test(p, r)
Definition: p_polys.h:163
INLINE_THIS void Init(int l=0)
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
poly p_MinPolyNormalize(poly p, const ring r)
Definition: maps.cc:324
int nr
Definition: lists.h:43
#define NULL
Definition: omList.c:10
slists * lists
Definition: mpr_numeric.h:146
poly n_PermNumber(const number z, const int *par_perm, const int, const ring src, const ring dst)
Definition: p_polys.cc:3910
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:138
#define R
Definition: sirandom.c:26
int rtyp
Definition: subexpr.h:91
int maMaxDeg_P(poly p, ring preimage_r)
Definition: maps.cc:292
void Clean(ring r=currRing)
Definition: lists.h:25
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void * Data()
Definition: subexpr.cc:1134
Definition: tok.h:118
omBin slists_bin
Definition: lists.cc:23
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:860
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
int BOOLEAN
Definition: auxiliary.h:85
#define TEST_V_ALLWARN
Definition: options.h:140
ip_smatrix * matrix
Definition: matpol.h:31
int l
Definition: cfEzgcd.cc:93
poly maEval(map theMap, poly p, ring preimage_r, nMapFunc nMap, ideal s, const ring dst_r)
Definition: maps.cc:117
long rank
Definition: matpol.h:19
#define idTest(id)
Definition: ideals.h:47
#define Warn
Definition: emacs.cc:77
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ pSubstPar()

poly pSubstPar ( poly  p,
int  par,
poly  image 
)

Definition at line 250 of file maps_ip.cc.

251 {
252  const ring R = currRing->cf->extRing;
253  ideal theMapI = idInit(rPar(currRing),1);
254  nMapFunc nMap = n_SetMap(R->cf, currRing->cf);
255  int i;
256  for(i = rPar(currRing);i>0;i--)
257  {
258  if (i != par)
259  theMapI->m[i-1]= p_NSet(n_Param(i, currRing), currRing);
260  else
261  theMapI->m[i-1] = p_Copy(image, currRing);
262  p_Test(theMapI->m[i-1],currRing);
263  }
264  //iiWriteMatrix((matrix)theMapI,"map:",1,currRing,0);
265 
266  map theMap=(map)theMapI;
267  theMap->preimage=NULL;
268 
270  sleftv tmpW;
271  poly res=NULL;
272 
274  if (currRing->cf->rep==n_rep_rat_fct )
275  {
276  while (p!=NULL)
277  {
278  memset(v,0,sizeof(sleftv));
279 
280  number d = n_GetDenom(pGetCoeff(p), currRing->cf);
281  p_Test((poly)NUM((fraction)d), R);
282 
283  if ( n_IsOne (d, currRing->cf) )
284  {
285  n_Delete(&d, currRing->cf); d = NULL;
286  }
287  else if (!p_IsConstant((poly)NUM((fraction)d), R))
288  {
289  WarnS("ignoring denominators of coefficients...");
290  n_Delete(&d, currRing->cf); d = NULL;
291  }
292 
293  number num = n_GetNumerator(pGetCoeff(p), currRing->cf);
294  memset(&tmpW,0,sizeof(sleftv));
295  tmpW.rtyp = POLY_CMD;
296  p_Test((poly)NUM((fraction)num), R);
297 
298  tmpW.data = NUM ((fraction)num); // a copy of this poly will be used
299 
300  p_Normalize(NUM((fraction)num),R);
301  if (maApplyFetch(MAP_CMD,theMap,v,&tmpW,R,NULL,NULL,0,nMap))
302  {
303  WerrorS("map failed");
304  v->data=NULL;
305  }
306  n_Delete(&num, currRing->cf);
307  //TODO check for memory leaks
308  poly pp = pHead(p);
309  //PrintS("map:");pWrite(pp);
310  if( d != NULL )
311  {
312  pSetCoeff(pp, n_Invers(d, currRing->cf));
313  n_Delete(&d, currRing->cf); // d = NULL;
314  }
315  else
316  pSetCoeff(pp, nInit(1));
317 
318  //PrintS("->");pWrite((poly)(v->data));
319  poly ppp = pMult((poly)(v->data),pp);
320  //PrintS("->");pWrite(ppp);
321  res=pAdd(res,ppp);
322  pIter(p);
323  }
324  }
325  else if (currRing->cf->rep==n_rep_poly )
326  {
327  while (p!=NULL)
328  {
329  memset(v,0,sizeof(sleftv));
330 
331  number num = n_GetNumerator(pGetCoeff(p), currRing->cf);
332  memset(&tmpW,0,sizeof(sleftv));
333  tmpW.rtyp = POLY_CMD;
334  p_Test((poly)num, R);
335 
336 
337  p_Normalize((poly)num,R);
338  if (num==NULL) num=(number)R->qideal->m[0];
339  tmpW.data = num; // a copy of this poly will be used
340  if (maApplyFetch(MAP_CMD,theMap,v,&tmpW,R,NULL,NULL,0,nMap))
341  {
342  WerrorS("map failed");
343  v->data=NULL;
344  }
345  if (num!=(number)R->qideal->m[0]) n_Delete(&num, currRing->cf);
346  //TODO check for memory leaks
347  poly pp = pHead(p);
348  //PrintS("map:");pWrite(pp);
349  pSetCoeff(pp,n_Init(1,currRing->cf));
350  //PrintS("cf->");pWrite((poly)(v->data));
351  poly ppp = pMult((poly)(v->data),pp);
352  //PrintS("->");pWrite(ppp);
353  res=pAdd(res,ppp);
354  pIter(p);
355  }
356  }
357  else
358  {
359  WerrorS("cannot apply subst for these coeffcients");
360  }
361  idDelete((ideal *)(&theMap));
363  return res;
364 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
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 FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n) ...
Definition: coeffs.h:609
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define pAdd(p, q)
Definition: polys.h:190
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
CanonicalForm num(const CanonicalForm &f)
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
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
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
Definition: maps_ip.cc:46
void * ADDRESS
Definition: auxiliary.h:133
sleftv * leftv
Definition: structs.h:60
void WerrorS(const char *s)
Definition: feFopen.cc:24
(fraction), see transext.h
Definition: coeffs.h:115
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
#define WarnS
Definition: emacs.cc:78
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
(poly), see algext.h
Definition: coeffs.h:114
void * data
Definition: subexpr.h:88
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1..n_NumberOfParameters(...)
Definition: coeffs.h:814
#define pIter(p)
Definition: monomials.h:44
if(yy_init)
Definition: libparse.cc:1418
CanonicalForm res
Definition: facAbsFact.cc:64
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of &#39;a&#39;; raise an error if &#39;a&#39; is not invertible ...
Definition: coeffs.h:565
omBin sleftv_bin
Definition: subexpr.cc:46
int i
Definition: cfEzgcd.cc:125
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
Definition: polys.h:67
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
#define p_Test(p, r)
Definition: p_polys.h:163
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
#define pMult(p, q)
Definition: polys.h:194
#define R
Definition: sirandom.c:26
int rtyp
Definition: subexpr.h:91
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1) ...
Definition: coeffs.h:604
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
int p
Definition: cfModGcd.cc:4019
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define nInit(i)
Definition: numbers.h:25
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31

◆ pSubstPoly()

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

Definition at line 387 of file maps_ip.cc.

388 {
389  if (p==NULL) return NULL;
390 #ifdef HAVE_PLURAL
391  if (rIsPluralRing(currRing))
392  {
393  return pSubst(pCopy(p),var,image);
394  }
395 #endif
396  return p_SubstPoly(p,var,image,currRing,currRing,ndCopyMap);
397 }
#define pSubst(p, n, e)
Definition: polys.h:352
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
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
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
#define NULL
Definition: omList.c:10
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
int p
Definition: cfModGcd.cc:4019
#define pCopy(p)
return a copy of the poly
Definition: polys.h:172