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

◆ idSubstPoly()

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

Definition at line 402 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);

◆ 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 45 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;

◆ pSubstPar()

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

Definition at line 249 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;

◆ pSubstPoly()

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

Definition at line 386 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);
FALSE
#define FALSE
Definition: auxiliary.h:94
matrix
ip_smatrix * matrix
Definition: matpol.h:30
IMAP_CMD
Definition: grammar.cc:296
ip_smatrix
Definition: matpol.h:13
p_Normalize
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3706
maMaxDeg_Ma
int maMaxDeg_Ma(ideal a, ring preimage_r)
Definition: maps.cc:253
pSubstPar
poly pSubstPar(poly p, int par, poly image)
Definition: maps_ip.cc:249
k
int k
Definition: cfEzgcd.cc:92
idDelete
#define idDelete(H)
delete an ideal
Definition: ideals.h:28
NUMBER_CMD
Definition: grammar.cc:287
LIST_CMD
Definition: tok.h:117
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
n_GetNumerator
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:608
MODUL_CMD
Definition: grammar.cc:286
num
CanonicalForm num(const CanonicalForm &f)
Definition: canonicalform.h:330
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:261
ndCopyMap
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
p_Test
#define p_Test(p, r)
Definition: p_polys.h:155
omAllocBin
#define omAllocBin(bin)
Definition: omAllocDecl.h:203
idTest
#define idTest(id)
Definition: ideals.h:46
N
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
n_Param
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....
Definition: coeffs.h:813
n_IsOne
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
sleftv
Class used for (list of) interpreter objects.
Definition: subexpr.h:81
pMult
#define pMult(p, q)
Definition: polys.h:186
w
const CanonicalForm & w
Definition: facAbsFact.cc:55
slists_bin
omBin slists_bin
Definition: lists.cc:22
n_Normalize
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:578
maApplyFetch
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:45
MATRIX_CMD
Definition: grammar.cc:285
leftv
sleftv * leftv
Definition: structs.h:59
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:403
n_PermNumber
poly n_PermNumber(const number z, const int *par_perm, const int, const ring src, const ring dst)
Definition: p_polys.cc:3907
n_rep_rat_fct
(fraction), see transext.h
Definition: coeffs.h:114
p_Copy
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:797
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
BEGIN_RING
Definition: grammar.cc:282
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
p_PermPoly
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:4011
res
CanonicalForm res
Definition: facAbsFact.cc:64
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
PrintS
void PrintS(const char *s)
Definition: reporter.cc:283
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
nCoeff_is_algExt
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:923
pTest
#define pTest(p)
Definition: polys.h:388
IDEAL_CMD
Definition: grammar.cc:283
ip_smatrix::m
poly * m
Definition: matpol.h:18
sleftv::data
void * data
Definition: subexpr.h:87
pIter
#define pIter(p)
Definition: monomials.h:41
rPar
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:589
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
END_RING
Definition: grammar.cc:308
VECTOR_CMD
Definition: grammar.cc:290
pp
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
slists::m
sleftv * m
Definition: lists.h:44
nCoeff_is_Extension
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:859
maMaxDeg_P
int maMaxDeg_P(poly p, ring preimage_r)
Definition: maps.cc:291
n_rep_poly
(poly), see algext.h
Definition: coeffs.h:113
mpNew
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:35
pAdd
#define pAdd(p, q)
Definition: polys.h:182
p_MinPolyNormalize
poly p_MinPolyNormalize(poly p, const ring r)
Definition: maps.cc:323
pSetCoeff
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:30
slists
Definition: lists.h:21
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
n_Invers
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of 'a'; raise an error if 'a' is not invertible
Definition: coeffs.h:564
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
Print
#define Print
Definition: emacs.cc:79
p_NSet
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1432
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:36
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
m
int m
Definition: cfEzgcd.cc:121
MATCOLS
#define MATCOLS(i)
Definition: matpol.h:27
WarnS
#define WarnS
Definition: emacs.cc:77
sleftv::rtyp
int rtyp
Definition: subexpr.h:90
assume
#define assume(x)
Definition: mod2.h:384
FETCH_CMD
Definition: grammar.cc:293
NULL
#define NULL
Definition: omList.c:9
MAP_CMD
Definition: grammar.cc:284
lists
slists * lists
Definition: mpr_numeric.h:145
sleftv::Copy
void Copy(leftv e)
Definition: subexpr.cc:683
l
int l
Definition: cfEzgcd.cc:93
R
#define R
Definition: sirandom.c:26
Warn
#define Warn
Definition: emacs.cc:76
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
sleftv_bin
omBin sleftv_bin
Definition: subexpr.cc:45
slists::Init
INLINE_THIS void Init(int l=0)
p
int p
Definition: cfModGcd.cc:4019
p_IsConstant
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1901
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
nInit
#define nInit(i)
Definition: numbers.h:24
POLY_CMD
Definition: grammar.cc:288
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:137
pCopy
#define pCopy(p)
return a copy of the poly
Definition: polys.h:165
n_SetMap
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:721
pHead
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition: polys.h:65
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:48
n_Test
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:738
MATROWS
#define MATROWS(i)
Definition: matpol.h:26
omFreeBin
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:257
TEST_V_ALLWARN
#define TEST_V_ALLWARN
Definition: options.h:139
n_GetDenom
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:603
prCopyR
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:35
if
if(yy_init)
Definition: libparse.cc:1417
pSubst
#define pSubst(p, n, e)
Definition: polys.h:340
maEval
poly maEval(map theMap, poly p, ring preimage_r, nMapFunc nMap, ideal s, const ring dst_r)
Definition: maps.cc:116
slists::Clean
void Clean(ring r=currRing)
Definition: lists.h:24