My Project  debian-1:4.1.2-p1+ds-2
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

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

61 {
62  ring sourcering = dst_r;
63 
64 #ifdef HAVE_PLURAL
65  if (rIsPluralRing(theImageRing))
66  {
67  if ((rIsPluralRing(sourcering)) && (ncRingType(sourcering)!=nc_comm))
68  {
69  WerrorS("Sorry, not yet implemented for noncomm. rings");
70  return NULL;
71  }
72  }
73 #endif
74 
75  int i,j;
76  poly p,/*pp,*/q;
77  ideal temp1;
78  ideal temp2;
79 
80  int imagepvariables = rVar(theImageRing);
81  int N = rVar(dst_r)+imagepvariables;
82 
83  ring tmpR;
84  if (rSumInternal(theImageRing,sourcering,tmpR,FALSE,2)!=1)
85  {
86  WerrorS("error in rSumInternal");
87  return NULL;
88  }
89 
90  assume(n_SetMap(theImageRing->cf, dst_r->cf) == ndCopyMap);
91 
92  if (theImageRing->cf != dst_r->cf)
93  {
94  /// TODO: there might be extreme cases where this doesn't hold...
95  WerrorS("Coefficient fields/rings must be equal");
96  return NULL;
97  }
98 
99  const ring save_ring = currRing; if (currRing!=tmpR) rChangeCurrRing(tmpR); // due to kStd
100 
101  if (id==NULL)
102  j = 0;
103  else
104  j = IDELEMS(id);
105  int j0=j;
106  if (theImageRing->qideal!=NULL) j+=IDELEMS(theImageRing->qideal);
107  temp1 = idInit(sourcering->N+j,1);
108  for (i=0;i<sourcering->N;i++)
109  {
110  q = p_ISet(-1,tmpR);
111  p_SetExp(q,i+1+imagepvariables,1,tmpR);
112  p_Setm(q,tmpR);
113  if ((i<IDELEMS(theMap)) && (theMap->m[i]!=NULL))
114  {
115  p = p_SortMerge(
116  pChangeSizeOfPoly(theImageRing, theMap->m[i], 1, imagepvariables, tmpR),
117  tmpR);
118  p=p_Add_q(p,q,tmpR);
119  }
120  else
121  {
122  p = q;
123  }
124  temp1->m[i] = p;
125  }
126  id_Test(temp1, tmpR);
127  for (i=sourcering->N;i<sourcering->N+j0;i++)
128  {
129  temp1->m[i] = p_SortMerge(
130  pChangeSizeOfPoly(theImageRing, id->m[i-sourcering->N], 1, imagepvariables, tmpR),
131  tmpR);
132  }
133  for (i=sourcering->N+j0;i<sourcering->N+j;i++)
134  {
135  temp1->m[i] = p_SortMerge(
136  pChangeSizeOfPoly(theImageRing, theImageRing->qideal->m[i-sourcering->N-j0], 1, imagepvariables, tmpR),
137  tmpR);
138  }
139  // we ignore here homogenity - may be changed later:
140 
141  temp2 = kStd(temp1,NULL,isNotHomog,NULL);
142 
143  id_Delete(&temp1,tmpR);
144  for (i=0;i<IDELEMS(temp2);i++)
145  {
146  if (p_LowVar(temp2->m[i], currRing)<imagepvariables) p_Delete(&(temp2->m[i]),tmpR);
147  }
148 
149  // let's get back to the original ring
150  //rChangeCurrRing(sourcering);
151  temp1 = idInit(5,1);
152  j = 0;
153  for (i=0;i<IDELEMS(temp2);i++)
154  {
155  p = temp2->m[i];
156  if (p!=NULL)
157  {
158  q = p_SortMerge(
159  pChangeSizeOfPoly(tmpR, p, imagepvariables+1, N, sourcering),
160  sourcering);
161  if (j>=IDELEMS(temp1))
162  {
163  pEnlargeSet(&(temp1->m),IDELEMS(temp1),5);
164  IDELEMS(temp1)+=5;
165  }
166  temp1->m[j] = q;
167  j++;
168  }
169  }
170  id_Delete(&temp2, tmpR);
171  idSkipZeroes(temp1);
172 
173  if (currRing!=save_ring) rChangeCurrRing(save_ring);
174 
175  rDelete(tmpR);
176  return temp1;
177 }
#define FALSE
Definition: auxiliary.h:96
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
int i
Definition: cfEzgcd.cc:125
int p
Definition: cfModGcd.cc:4019
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:721
int j
Definition: facHensel.cc:105
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:2088
@ nc_comm
Definition: nc.h:17
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:159
#define assume(x)
Definition: mod2.h:390
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
#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:4586
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1287
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3656
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:895
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:487
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:232
static poly p_SortMerge(poly p, const ring r, BOOLEAN revert=FALSE)
Definition: p_polys.h:1168
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
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:26
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
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:397
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587
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:79
@ isNotHomog
Definition: structs.h:41