My Project  debian-1:4.1.1-p2+ds-4build4
subst_maps.cc
Go to the documentation of this file.
1 #include "kernel/mod2.h"
3 #include "kernel/ideals.h"
4 #include "polys/monomials/ring.h"
5 #include "polys/monomials/maps.h"
6 #include "kernel/maps/gen_maps.h"
7 
8 static poly p_SubstMon(poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
9 {
10  assume(!rIsPluralRing(image_r));
11  poly q=p_NSet(nMap(pGetCoeff(p),preimage_r->cf,image_r->cf),image_r);
12  int i;
13  poly h=NULL;
14  for(i=1;i<=preimage_r->N; i++)
15  {
16  int pExp=p_GetExp( p,i,preimage_r);
17  if (i!=var)
18  {
19  p_SetExp(q,i,pExp,image_r);
20  }
21  else if (pExp!=0)
22  {
23  h=maEvalVariable(image,var,pExp,(ideal)cache,image_r);
24  if (h==NULL)
25  {
26  p_LmDelete(q,image_r);
27  return NULL;
28  }
29  }
30  else
31  h=p_One(image_r);
32  }
33  p_Setm(q,image_r);
34  h=p_Mult_mm(h,q,image_r);
35  p_LmDelete(q,image_r);
36  return h;
37 }
38 
39 poly p_SubstPoly (poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
40 {
41  if (p==NULL) return NULL;
42 
43  if (rIsPluralRing(image_r))
44  {
45  if((image_r!=preimage_r)
46  ||(preimage_r!=currRing))
47  {
48  WerrorS("not implemented");
49  return NULL;
50  }
51  return pSubst(pCopy(p),var,image);
52  }
53  if (cache==NULL) cache=mpNew(preimage_r->N,maMaxDeg_P(p, preimage_r));
54 
55  poly result = NULL;
56  sBucket_pt bucket = sBucketCreate(image_r);
57  while (p != NULL)
58  {
59  poly q=p_SubstMon(p,var,image,preimage_r,image_r,nMap,cache);
60  pIter(p);
61  if (q!=NULL) sBucket_Add_p(bucket,q,pLength(q));
62  }
63  int l_dummy;
64  sBucketDestroyAdd(bucket, &result, &l_dummy);
65  return result;
66 }
67 
68 ideal id_SubstPoly (ideal id, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap)
69 {
70  matrix cache=mpNew(preimage_r->N,maMaxDeg_Ma(id, preimage_r));
71  int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
72  ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
73  res->rank = id->rank;
74  for(k--;k>=0;k--)
75  {
76  res->m[k]=p_SubstPoly(id->m[k],var,image,preimage_r,image_r,nMap,cache);
77  }
78  return res;
79 }
int i
Definition: cfEzgcd.cc:125
int k
Definition: cfEzgcd.cc:92
int p
Definition: cfModGcd.cc:4019
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
return result
Definition: facAbsBiFact.cc:76
CanonicalForm res
Definition: facAbsFact.cc:64
void WerrorS(const char *s)
Definition: feFopen.cc:24
static Poly * h
Definition: janet.cc:972
int maMaxDeg_P(poly p, ring preimage_r)
Definition: maps.cc:292
poly maEvalVariable(poly p, int v, int pExp, ideal s, const ring dst_r)
Definition: maps.cc:48
int maMaxDeg_Ma(ideal a, ring preimage_r)
Definition: maps.cc:254
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27
#define assume(x)
Definition: mod2.h:390
#define pIter(p)
Definition: monomials.h:44
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 NULL
Definition: omList.c:10
poly p_One(const ring r)
Definition: p_polys.cc:1305
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:711
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:488
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
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 unsigned pLength(poly a)
Definition: p_polys.h:192
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:997
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define pSubst(p, n, e)
Definition: polys.h:352
#define pCopy(p)
return a copy of the poly
Definition: polys.h:172
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition: sbuckets.cc:206
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:99
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:68
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
static poly p_SubstMon(poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
Definition: subst_maps.cc:8
poly p_SubstPoly(poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
Definition: subst_maps.cc:39