Functions
subst_maps.cc File Reference
#include <kernel/mod2.h>
#include <polys/monomials/p_polys.h>
#include <kernel/ideals.h>
#include <polys/monomials/ring.h>
#include <polys/monomials/maps.h>
#include <kernel/maps/gen_maps.h>

Go to the source code of this file.

Functions

static poly p_SubstMon (poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
 
poly p_SubstPoly (poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
 
ideal id_SubstPoly (ideal id, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap)
 

Function Documentation

◆ id_SubstPoly()

ideal id_SubstPoly ( ideal  id,
int  var,
poly  image,
const ring  preimage_r,
const ring  image_r,
const nMapFunc  nMap 
)

Definition at line 68 of file subst_maps.cc.

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 maMaxDeg_Ma(ideal a, ring preimage_r)
Definition: maps.cc:258
int k
Definition: cfEzgcd.cc:93
poly res
Definition: myNF.cc:322
poly * m
Definition: matpol.h:19
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
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:47
#define MATCOLS(i)
Definition: matpol.h:28
#define MATROWS(i)
Definition: matpol.h:27
long rank
Definition: matpol.h:20

◆ p_SubstMon()

static poly p_SubstMon ( poly  p,
int  var,
poly  image,
const ring  preimage_r,
const ring  image_r,
const nMapFunc  nMap,
matrix  cache 
)
static

Definition at line 8 of file subst_maps.cc.

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 }
return P p
Definition: myNF.cc:203
poly maEvalVariable(poly p, int v, int pExp, ideal s, const ring dst_r)
Definition: maps.cc:52
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:968
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1442
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
poly p_One(const ring r)
Definition: p_polys.cc:1312
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
#define assume(x)
Definition: mod2.h:394
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
int i
Definition: cfEzgcd.cc:123
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
#define NULL
Definition: omList.c:10
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:706
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978

◆ p_SubstPoly()

poly p_SubstPoly ( poly  p,
int  var,
poly  image,
const ring  preimage_r,
const ring  image_r,
const nMapFunc  nMap,
matrix  cache 
)

Definition at line 39 of file subst_maps.cc.

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 }
#define pSubst(p, n, e)
Definition: polys.h:348
return P p
Definition: myNF.cc:203
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:72
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition: sbuckets.cc:201
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define pIter(p)
Definition: monomials.h:44
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
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:120
P bucket
Definition: myNF.cc:79
static unsigned pLength(poly a)
Definition: p_polys.h:189
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:47
#define NULL
Definition: omList.c:10
int maMaxDeg_P(poly p, ring preimage_r)
Definition: maps.cc:296
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
polyrec * poly
Definition: hilb.h:10
return result
Definition: facAbsBiFact.cc:76
#define pCopy(p)
return a copy of the poly
Definition: polys.h:168