My Project  debian-1:4.1.1-p2+ds-4build3
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 61 of file preimage.cc.

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