My Project
Loading...
Searching...
No Matches
preimage.h File Reference

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 homogeneity - may be changed later:
135 BITSET save;
136 SI_SAVE_OPT2(save);
137 temp2 = kStd2(temp1,NULL,isNotHomog,NULL,(bigintmat*)NULL);
138 SI_RESTORE_OPT2(save);
139
140 id_Delete(&temp1,tmpR);
141 for (i=0;i<IDELEMS(temp2);i++)
142 {
143 if (p_LowVar(temp2->m[i], currRing)<imagepvariables) p_Delete(&(temp2->m[i]),tmpR);
144 }
145
146 // let's get back to the original ring
147 //rChangeCurrRing(sourcering);
148 temp1 = idInit(5,1);
149 j = 0;
150 for (i=0;i<IDELEMS(temp2);i++)
151 {
152 p = temp2->m[i];
153 if (p!=NULL)
154 {
155 q = p_SortMerge(
156 pChangeSizeOfPoly(tmpR, p, imagepvariables+1, N, sourcering),
157 sourcering);
158 if (j>=IDELEMS(temp1))
159 {
160 pEnlargeSet(&(temp1->m),IDELEMS(temp1),5);
161 IDELEMS(temp1)+=5;
162 }
163 temp1->m[j] = q;
164 j++;
165 }
166 }
167 id_Delete(&temp2, tmpR);
168 idSkipZeroes(temp1);
169
170 if (currRing!=save_ring) rChangeCurrRing(save_ring);
171
172 rDelete(tmpR);
173 return temp1;
174}
#define BITSET
Definition auxiliary.h:85
#define FALSE
Definition auxiliary.h:97
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
int i
Definition cfEzgcd.cc:132
int p
Definition cfModGcd.cc:4086
Matrices of numbers.
Definition bigintmat.h:51
int j
Definition facHensel.cc:110
void WerrorS(const char *s)
Definition feFopen.cc:24
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2602
@ nc_comm
Definition nc.h:17
static nc_type & ncRingType(nc_struct *p)
Definition nc.h:159
#define NULL
Definition omList.c:12
#define SI_SAVE_OPT2(A)
Definition options.h:22
#define SI_RESTORE_OPT2(A)
Definition options.h:25
int p_LowVar(poly p, const ring r)
the minimal index of used variables - 1
Definition p_polys.cc:4789
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3776
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
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:490
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static poly p_SortMerge(poly p, const ring r, BOOLEAN revert=FALSE)
Definition p_polys.h:1245
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
void rChangeCurrRing(ring r)
Definition polys.cc:16
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:454
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:754
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598
ideal idInit(int idsize, int rank)
initialise an ideal / module
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)
#define id_Test(A, lR)
@ isNotHomog
Definition structs.h:32