My Project
Functions
preimage.cc File Reference
#include "kernel/mod2.h"
#include "misc/options.h"
#include "misc/intvec.h"
#include "kernel/polys.h"
#include "polys/monomials/ring.h"
#include "kernel/ideals.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/khstd.h"
#include "polys/nc/nc.h"

Go to the source code of this file.

Functions

static poly pChangeSizeOfPoly (ring p_ring, poly p, int minvar, int maxvar, const ring dst_r)
 
ideal maGetPreimage (ring theImageRing, map theMap, ideal id, const ring dst_r)
 

Function Documentation

◆ maGetPreimage()

ideal maGetPreimage ( ring  theImageRing,
map  theMap,
ideal  id,
const ring  dst_r 
)

TODO: there might be extreme cases where this doesn't hold...

Definition at line 57 of file preimage.cc.

58 {
59  ring sourcering = dst_r;
60 
61 #ifdef HAVE_PLURAL
62  if (rIsPluralRing(theImageRing))
63  {
64  if ((rIsPluralRing(sourcering)) && (ncRingType(sourcering)!=nc_comm))
65  {
66  WerrorS("Sorry, not yet implemented for noncomm. rings");
67  return NULL;
68  }
69  }
70 #endif
71 
72  int i,j;
73  poly p,/*pp,*/q;
74  ideal temp1;
75  ideal temp2;
76 
77  int imagepvariables = rVar(theImageRing);
78  int N = rVar(dst_r)+imagepvariables;
79 
80  ring tmpR;
81  if (rSumInternal(theImageRing,sourcering,tmpR,FALSE,2)!=1)
82  {
83  WerrorS("error in rSumInternal");
84  return NULL;
85  }
86 
87  if (theImageRing->cf != dst_r->cf)
88  {
89  /// TODO: there might be extreme cases where this doesn't hold...
90  WerrorS("Coefficient fields/rings must be equal");
91  return NULL;
92  }
93 
94  const ring save_ring = currRing; if (currRing!=tmpR) rChangeCurrRing(tmpR); // due to kStd
95 
96  if (id==NULL)
97  j = 0;
98  else
99  j = IDELEMS(id);
100  int j0=j;
101  if (theImageRing->qideal!=NULL) j+=IDELEMS(theImageRing->qideal);
102  temp1 = idInit(sourcering->N+j,1);
103  for (i=0;i<sourcering->N;i++)
104  {
105  q = p_ISet(-1,tmpR);
106  p_SetExp(q,i+1+imagepvariables,1,tmpR);
107  p_Setm(q,tmpR);
108  if ((i<IDELEMS(theMap)) && (theMap->m[i]!=NULL))
109  {
110  p = p_SortMerge(
111  pChangeSizeOfPoly(theImageRing, theMap->m[i], 1, imagepvariables, tmpR),
112  tmpR);
113  p=p_Add_q(p,q,tmpR);
114  }
115  else
116  {
117  p = q;
118  }
119  temp1->m[i] = p;
120  }
121  id_Test(temp1, tmpR);
122  for (i=sourcering->N;i<sourcering->N+j0;i++)
123  {
124  temp1->m[i] = p_SortMerge(
125  pChangeSizeOfPoly(theImageRing, id->m[i-sourcering->N], 1, imagepvariables, tmpR),
126  tmpR);
127  }
128  for (i=sourcering->N+j0;i<sourcering->N+j;i++)
129  {
130  temp1->m[i] = p_SortMerge(
131  pChangeSizeOfPoly(theImageRing, theImageRing->qideal->m[i-sourcering->N-j0], 1, imagepvariables, tmpR),
132  tmpR);
133  }
134  // we ignore here homogenity - may be changed later:
135 
136  temp2 = kStd(temp1,NULL,isNotHomog,NULL);
137 
138  id_Delete(&temp1,tmpR);
139  for (i=0;i<IDELEMS(temp2);i++)
140  {
141  if (p_LowVar(temp2->m[i], currRing)<imagepvariables) p_Delete(&(temp2->m[i]),tmpR);
142  }
143 
144  // let's get back to the original ring
145  //rChangeCurrRing(sourcering);
146  temp1 = idInit(5,1);
147  j = 0;
148  for (i=0;i<IDELEMS(temp2);i++)
149  {
150  p = temp2->m[i];
151  if (p!=NULL)
152  {
153  q = p_SortMerge(
154  pChangeSizeOfPoly(tmpR, p, imagepvariables+1, N, sourcering),
155  sourcering);
156  if (j>=IDELEMS(temp1))
157  {
158  pEnlargeSet(&(temp1->m),IDELEMS(temp1),5);
159  IDELEMS(temp1)+=5;
160  }
161  temp1->m[j] = q;
162  j++;
163  }
164  }
165  id_Delete(&temp2, tmpR);
166  idSkipZeroes(temp1);
167 
168  if (currRing!=save_ring) rChangeCurrRing(save_ring);
169 
170  rDelete(tmpR);
171  return temp1;
172 }
#define FALSE
Definition: auxiliary.h:96
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
int j
Definition: facHensel.cc:110
void WerrorS(const char *s)
Definition: feFopen.cc:24
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2433
@ nc_comm
Definition: nc.h:17
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:159
#define NULL
Definition: omList.c:12
int p_LowVar(poly p, const ring r)
the minimal index of used variables - 1
Definition: p_polys.cc:4745
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1297
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3774
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:936
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 poly p_SortMerge(poly p, const ring r, BOOLEAN revert=FALSE)
Definition: p_polys.h:1229
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:901
void rChangeCurrRing(ring r)
Definition: polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static poly pChangeSizeOfPoly(ring p_ring, poly p, int minvar, int maxvar, const ring dst_r)
Definition: preimage.cc:23
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
int rSumInternal(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp)
returns -1 for not compatible, 1 for compatible (and sum) dp_dp:0: block ordering,...
Definition: ring.cc:749
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:593
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define IDELEMS(i)
Definition: simpleideals.h:23
#define id_Test(A, lR)
Definition: simpleideals.h:78
@ isNotHomog
Definition: structs.h:36

◆ pChangeSizeOfPoly()

static poly pChangeSizeOfPoly ( ring  p_ring,
poly  p,
int  minvar,
int  maxvar,
const ring  dst_r 
)
static

Definition at line 23 of file preimage.cc.

24 {
25  int i;
26  poly result = NULL,resultWorkP;
27  number n;
28 
29  if (p==NULL) return result;
30  else result = p_Init(dst_r);
31  resultWorkP = result;
32  while (p!=NULL)
33  {
34  for (i=minvar;i<=maxvar;i++)
35  p_SetExp(resultWorkP,i-minvar+1,p_GetExp(p,i,p_ring),dst_r);
36  p_SetComp(resultWorkP,p_GetComp(p,p_ring),dst_r);
37  n=n_Copy(pGetCoeff(p),dst_r->cf);
38  p_SetCoeff0(resultWorkP,n,dst_r);
39  p_Setm(resultWorkP,dst_r);
40  pIter(p);
41  if (p!=NULL)
42  {
43  pNext(resultWorkP) = p_Init(dst_r);
44  pIter(resultWorkP);
45  }
46  }
47  return result;
48 }
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
return result
Definition: facAbsBiFact.cc:75
#define p_SetCoeff0(p, n, r)
Definition: monomials.h:60
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
#define pNext(p)
Definition: monomials.h:36
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
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 poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1320