Functions
preimage.h File Reference
#include <polys/monomials/ring.h>

Go to the source code of this file.

Functions

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

Function Documentation

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 63 of file preimage.cc.

64 {
65  ring sourcering = dst_r;
66 
67 #ifdef HAVE_PLURAL
68  if (rIsPluralRing(theImageRing))
69  {
70  if ((rIsPluralRing(sourcering)) && (ncRingType(sourcering)!=nc_comm))
71  {
72  Werror("Sorry, not yet implemented for noncomm. rings");
73  return NULL;
74  }
75  }
76 #endif
77 
78  int i,j;
79  poly p,/*pp,*/q;
80  ideal temp1;
81  ideal temp2;
82 
83  int imagepvariables = rVar(theImageRing);
84  int N = rVar(dst_r)+imagepvariables;
85 
86  ring tmpR;
87  if (rSumInternal(theImageRing,sourcering,tmpR,FALSE,2)!=1)
88  {
89  WerrorS("error in rSumInternal");
90  return NULL;
91  }
92 
93  assume(n_SetMap(theImageRing->cf, dst_r->cf) == ndCopyMap);
94 
95  if (theImageRing->cf != dst_r->cf)
96  {
97  /// TODO: there might be extreme cases where this doesn't hold...
98  Werror("Coefficient fields/rings must be equal");
99  return NULL;
100  }
101 
102  const ring save_ring = currRing; if (currRing!=tmpR) rChangeCurrRing(tmpR); // due to kStd
103 
104  if (id==NULL)
105  j = 0;
106  else
107  j = IDELEMS(id);
108  int j0=j;
109  if (theImageRing->qideal!=NULL) j+=IDELEMS(theImageRing->qideal);
110  temp1 = idInit(sourcering->N+j,1);
111  for (i=0;i<sourcering->N;i++)
112  {
113  q = p_ISet(-1,tmpR);
114  p_SetExp(q,i+1+imagepvariables,1,tmpR);
115  p_Setm(q,tmpR);
116  if ((i<IDELEMS(theMap)) && (theMap->m[i]!=NULL))
117  {
118  p = p_SortMerge(
119  pChangeSizeOfPoly(theImageRing, theMap->m[i], 1, imagepvariables, tmpR),
120  tmpR);
121  p=p_Add_q(p,q,tmpR);
122  }
123  else
124  {
125  p = q;
126  }
127  temp1->m[i] = p;
128  }
129  id_Test(temp1, tmpR);
130  for (i=sourcering->N;i<sourcering->N+j0;i++)
131  {
132  temp1->m[i] = p_SortMerge(
133  pChangeSizeOfPoly(theImageRing, id->m[i-sourcering->N], 1, imagepvariables, tmpR),
134  tmpR);
135  }
136  for (i=sourcering->N+j0;i<sourcering->N+j;i++)
137  {
138  temp1->m[i] = p_SortMerge(
139  pChangeSizeOfPoly(theImageRing, theImageRing->qideal->m[i-sourcering->N-j0], 1, imagepvariables, tmpR),
140  tmpR);
141  }
142  // we ignore here homogenity - may be changed later:
143 
144  temp2 = kStd(temp1,NULL,isNotHomog,NULL);
145 
146  id_Delete(&temp1,tmpR);
147  for (i=0;i<IDELEMS(temp2);i++)
148  {
149  if (p_LowVar(temp2->m[i], currRing)<imagepvariables) p_Delete(&(temp2->m[i]),tmpR);
150  }
151 
152  // let's get back to the original ring
153  //rChangeCurrRing(sourcering);
154  temp1 = idInit(5,1);
155  j = 0;
156  for (i=0;i<IDELEMS(temp2);i++)
157  {
158  p = temp2->m[i];
159  if (p!=NULL)
160  {
161  q = p_SortMerge(
162  pChangeSizeOfPoly(tmpR, p, imagepvariables+1, N, sourcering),
163  sourcering);
164  if (j>=IDELEMS(temp1))
165  {
166  pEnlargeSet(&(temp1->m),IDELEMS(temp1),5);
167  IDELEMS(temp1)+=5;
168  }
169  temp1->m[j] = q;
170  j++;
171  }
172  }
173  id_Delete(&temp2, tmpR);
174  idSkipZeroes(temp1);
175 
176  if (currRing!=save_ring) rChangeCurrRing(save_ring);
177 
178  rDelete(tmpR);
179  return temp1;
180 }
static poly p_SortMerge(poly p, const ring r, BOOLEAN revert=FALSE)
Definition: p_polys.h:1157
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, 1: dp,dp, 2: aa(...),dp vartest: check for name conflicts
Definition: ring.cc:722
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:239
#define id_Test(A, lR)
Definition: simpleideals.h:80
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:540
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
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:2221
void WerrorS(const char *s)
Definition: feFopen.cc:24
static bool rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:361
Definition: nc.h:25
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
static poly pChangeSizeOfPoly(ring p_ring, poly p, int minvar, int maxvar, const ring dst_r)
Definition: preimage.cc:29
int p_LowVar(poly p, const ring r)
the minimal index of used variables - 1
Definition: p_polys.cc:4457
#define IDELEMS(i)
Definition: simpleideals.h:24
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:720
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void rChangeCurrRing(ring r)
Definition: polys.cc:14
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
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:484
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3540
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:175
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:884
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1302
void Werror(const char *fmt,...)
Definition: reporter.cc:199