My Project
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 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:4080
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:2430
@ 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:4708
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1292
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3766
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:896
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:1189
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:861
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:449
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:747
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:594
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:41