Functions
preimage.cc File Reference
#include <kernel/mod2.h>
#include <omalloc/omalloc.h>
#include <misc/auxiliary.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 <kernel/GBEngine/kutil.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

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:1158
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:537
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:2225
void WerrorS(const char *s)
Definition: feFopen.cc:24
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
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:361
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:4486
#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:722
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:849
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:483
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3551
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:228
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:883
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
static poly pChangeSizeOfPoly ( ring  p_ring,
poly  p,
int  minvar,
int  maxvar,
const ring  dst_r 
)
static

Definition at line 29 of file preimage.cc.

30 {
31  int i;
32  poly result = NULL,resultWorkP;
33  number n;
34 
35  if (p==NULL) return result;
36  else result = p_Init(dst_r);
37  resultWorkP = result;
38  while (p!=NULL)
39  {
40  for (i=minvar;i<=maxvar;i++)
41  p_SetExp(resultWorkP,i-minvar+1,p_GetExp(p,i,p_ring),dst_r);
42  p_SetComp(resultWorkP,p_GetComp(p,p_ring),dst_r);
43  n=n_Copy(pGetCoeff(p),dst_r->cf);
44  p_SetCoeff(resultWorkP,n,dst_r);
45  p_Setm(resultWorkP,dst_r);
46  pIter(p);
47  if (p!=NULL)
48  {
49  pNext(resultWorkP) = p_Init(dst_r);
50  pIter(resultWorkP);
51  }
52  }
53  return result;
54 }
return P p
Definition: myNF.cc:203
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:242
#define p_GetComp(p, r)
Definition: monomials.h:72
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
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:407
#define pIter(p)
Definition: monomials.h:44
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
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 FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
polyrec * poly
Definition: hilb.h:10
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1249
return result
Definition: facAbsBiFact.cc:76