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

Go to the source code of this file.

Functions

poly maEval (map theMap, poly p, ring preimage_r, nMapFunc nMap, ideal s, const ring dst_r)
map maCopy (map theMap, const ring dst_ring)
poly maIMap (ring src_ring, ring dst_ring, poly p)
void maFindPerm (char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
void maFindPermLP (char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch, int lV)
void maFetchPermLP (const ring preimage_r, const ring dst_r, int *perm)
poly pSubstPoly (poly p, int var, poly image)
ideal idSubstPoly (ideal id, int n, poly e)
poly p_MinPolyNormalize (poly p, const ring r)
int maMaxDeg_P (poly p, ring preimage_r)
int maMaxDeg_Ma (ideal a, ring preimage_r)
poly maEvalVariable (poly p, int v, int pExp, ideal s, const ring dst_r)

Function Documentation

◆ idSubstPoly()

ideal idSubstPoly ( ideal id,
int n,
poly e )

Definition at line 425 of file maps_ip.cc.

426{
427
428#ifdef HAVE_PLURAL
430 {
431 int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
432 ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
433 res->rank = id->rank;
434 for(k--;k>=0;k--)
435 {
436 res->m[k]=pSubst(pCopy(id->m[k]),n,e);
437 }
438 return res;
439 }
440#endif
441#ifdef HAVE_SHIFTBBA
442 if (rIsLPRing(currRing))
443 {
444 int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
445 ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
446 res->rank = id->rank;
447 for(k--;k>=0;k--)
448 {
449 res->m[k]=pSubst(pCopy(id->m[k]),n,e);
450 }
451 return res;
452 }
453#endif
455}
int k
Definition cfEzgcd.cc:99
poly * m
Definition matpol.h:18
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition numbers.cc:293
CanonicalForm res
Definition facAbsFact.cc:60
ideal id_SubstPoly(ideal id, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap)
Definition subst_maps.cc:78
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
ip_smatrix * matrix
Definition matpol.h:43
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pSubst(p, n, e)
Definition polys.h:366
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417

◆ maCopy()

map maCopy ( map theMap,
const ring dst_ring )

Definition at line 34 of file maps.cc.

35{
36 int i;
37 map m=(map)idInit(IDELEMS(theMap),0);
38 for (i=IDELEMS(theMap)-1; i>=0; i--)
39 m->m[i] = p_Copy(theMap->m[i],r);
40 m->preimage=omStrDup(theMap->preimage);
41 return m;
42}
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
#define omStrDup(s)
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define IDELEMS(i)

◆ maEval()

poly maEval ( map theMap,
poly p,
ring preimage_r,
nMapFunc nMap,
ideal s,
const ring dst_r )

Definition at line 117 of file maps.cc.

118{
119 poly result = NULL;
120 int i;
121
122// for(i=1; i<=preimage_r->N; i++)
123// {
124// pTest(theMap->m[i-1]);
125// }
126// while (p!=NULL)
127// {
128// poly q=maEvalMonom(theMap,p,preimage_r,s);
129// result = pAdd(result,q);
130// pIter(p);
131// }
132 if (p!=NULL)
133 {
135 int l;
136
137 while(p!=NULL)
138 {
139 poly h=maEvalMonom(theMap,p,preimage_r,s, nMap, dst_r);
140 l=pLength(h);
142 pIter(p);
143 }
145
146 assume(dst_r != NULL);
147 assume(dst_r->cf != NULL);
148
149 if (nCoeff_is_algExt(dst_r->cf))
151 }
152 return result;
153}
int l
Definition cfEzgcd.cc:100
int p
Definition cfModGcd.cc:4086
CanonicalForm b
Definition cfModGcd.cc:4111
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition coeffs.h:908
return result
const CanonicalForm int s
Definition facAbsFact.cc:51
STATIC_VAR Poly * h
Definition janet.cc:971
static poly maEvalMonom(map theMap, poly p, ring preimage_r, ideal s, nMapFunc nMap, const ring dst_r)
Definition maps.cc:87
poly p_MinPolyNormalize(poly p, const ring r)
Definition maps.cc:422
#define assume(x)
Definition mod2.h:389
#define pIter(p)
Definition monomials.h:37
#define NULL
Definition omList.c:12
static int pLength(poly a)
Definition p_polys.h:190
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition sbuckets.cc:203
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96
sBucket * sBucket_pt
Definition sbuckets.h:16
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.h:68

◆ maEvalVariable()

poly maEvalVariable ( poly p,
int v,
int pExp,
ideal s,
const ring dst_r )

Definition at line 48 of file maps.cc.

49{
50 if (pExp==1)
51 return p_Copy(p,dst_r);
52
53 poly res;
54
55 if((s!=NULL)&&(pExp<MAX_MAP_DEG))
56 {
57 int j=2;
58 poly p0=p;
59 // find starting point
60 if(MATELEM(s,v,1)==NULL)
61 {
62 MATELEM(s,v,1)=p_Copy(p/*theMap->m[v-1]*/,dst_r);
63 }
64 else
65 {
66 while((j<=pExp)&&(MATELEM(s,v,j)!=NULL))
67 {
68 j++;
69 }
70 p0=MATELEM(s,v,j-1);
71 }
72 // multiply
73 for(;j<=pExp;j++)
74 {
75 p0=MATELEM(s,v,j)=pp_Mult_qq(p0, p,dst_r);
76 p_Normalize(p0, dst_r);
77 }
78 res=p_Copy(p0/*MATELEM(s,v,pExp)*/,dst_r);
79 }
80 else //if ((p->next!=NULL)&&(p->next->next==NULL))
81 {
82 res=p_Power(p_Copy(p,dst_r),pExp,dst_r);
83 }
84 return res;
85}
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
int j
Definition facHensel.cc:110
#define MAX_MAP_DEG
Definition maps.cc:29
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
poly p_Power(poly p, int i, const ring r)
Definition p_polys.cc:2245
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3952
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167

◆ maFetchPermLP()

void maFetchPermLP ( const ring preimage_r,
const ring dst_r,
int * perm )

Definition at line 298 of file maps.cc.

300{
301 for (int i = 0; i < preimage_r->N + 1; i++) { perm[i] = 0; }
302
303 int preimage_lV = preimage_r->isLPring;
304 int r_lV = dst_r->isLPring;
305
306 int preimage_ncgens = preimage_r->LPncGenCount;
307 int r_ncges = dst_r->LPncGenCount;
308
309 int preimage_vars = preimage_lV - preimage_ncgens;
310 int r_vars = r_lV - r_ncges;
311
312 // for each block
313 for (int i = 0; i < si_min(preimage_r->N / preimage_lV, dst_r->N / r_lV); i++)
314 {
315 // align variables
316 for (int j = 1; j <= si_min(preimage_vars, r_vars); j++)
317 {
318 perm[(i * preimage_lV) + j] = (i * r_lV) + j;
319 }
320
321 // align ncgens
322 for (int j = 1; j <= si_min(preimage_ncgens, r_ncges); j++)
323 {
324 perm[(i * preimage_lV) + preimage_vars + j] = (i * r_lV) + r_vars + j;
325 }
326 }
327}
static int si_min(const int a, const int b)
Definition auxiliary.h:126

◆ maFindPerm()

void maFindPerm ( char const *const *const preim_names,
int preim_n,
char const *const *const preim_par,
int preim_p,
char const *const *const names,
int n,
char const *const *const par,
int nop,
int * perm,
int * par_perm,
n_coeffType ch )

Definition at line 155 of file maps.cc.

158{
159 int i,j;
160 /* find corresponding vars */
161 for (i=0; i<preim_n; i++)
162 {
163 for(j=0; j<n; j++)
164 {
165 if (strcmp(preim_names[i],names[j])==0)
166 {
167 if (BVERBOSE(V_IMAP))
168 Print("// var %s: nr %d -> nr %d\n",preim_names[i],i+1,j+1);
169 /* var i+1 from preimage ring is var j+1 (index j+1) from image ring */
170 perm[i+1]=j+1;
171 break;
172 }
173 }
174 if ((perm[i+1]==0)&&(par!=NULL)
175 // do not consider par of Fq
176 && (ch!=n_GF))
177 {
178 for(j=0; j<nop; j++)
179 {
180 if (strcmp(preim_names[i],par[j])==0)
181 {
182 if (BVERBOSE(V_IMAP))
183 Print("// var %s: nr %d -> par %d\n",preim_names[i],i+1,j+1);
184 /* var i+1 from preimage ring is par j+1 (index j) from image ring */
185 perm[i+1]=-(j+1);
186 }
187 }
188 }
189 }
190 if (par_perm!=NULL)
191 {
192 for (i=0; i<preim_p; i++)
193 {
194 for(j=0; j<n; j++)
195 {
196 if (strcmp(preim_par[i],names[j])==0)
197 {
198 if (BVERBOSE(V_IMAP))
199 Print("// par %s: par %d -> nr %d\n",preim_par[i],i+1,j+1);
200 /*par i+1 from preimage ring is var j+1 (index j+1) from image ring*/
201 par_perm[i]=j+1;
202 break;
203 }
204 }
205 if ((par!=NULL) && (par_perm[i]==0))
206 {
207 for(j=0; j<nop; j++)
208 {
209 if (strcmp(preim_par[i],par[j])==0)
210 {
211 if (BVERBOSE(V_IMAP))
212 Print("// par %s: nr %d -> par %d\n",preim_par[i],i+1,j+1);
213 /*par i+1 from preimage ring is par j+1 (index j) from image ring */
214 par_perm[i]=-(j+1);
215 }
216 }
217 }
218 }
219 }
220}
@ n_GF
\GF{p^n < 2^16}
Definition coeffs.h:32
#define Print
Definition emacs.cc:80
#define BVERBOSE(a)
Definition options.h:35
#define V_IMAP
Definition options.h:53

◆ maFindPermLP()

void maFindPermLP ( char const *const *const preim_names,
int preim_n,
char const *const *const preim_par,
int preim_p,
char const *const *const names,
int n,
char const *const *const par,
int nop,
int * perm,
int * par_perm,
n_coeffType ch,
int lV )

Definition at line 223 of file maps.cc.

226{
227 int i,j,b;
228 /* find corresponding vars */
229 for (b=0;b<preim_n/lV;b++)
230 {
231 for (i=b*lV; i<(b+1)*lV; i++)
232 {
233 int cnt=0;
234 for(j=0; j<n; j++)
235 {
236 if (strcmp(preim_names[i],names[j])==0)
237 {
238 if (cnt==b)
239 {
240 if (BVERBOSE(V_IMAP))
241 Print("// var %s: nr %d -> nr %d\n",preim_names[i],i+1,j+1);
242 /* var i+1 from preimage ring is var j+1 (index j+1) from image ring */
243 perm[i+1]=j+1;
244 break;
245 }
246 else cnt++;
247 }
248 }
249 if ((perm[i+1]==0)&&(par!=NULL)
250 // do not consider par of Fq
251 && (ch!=n_GF))
252 {
253 for(j=0; j<nop; j++)
254 {
255 if (strcmp(preim_names[i],par[j])==0)
256 {
257 if (BVERBOSE(V_IMAP))
258 Print("// var %s: nr %d -> par %d\n",preim_names[i],i+1,j+1);
259 /* var i+1 from preimage ring is par j+1 (index j) from image ring */
260 perm[i+1]=-(j+1);
261 }
262 }
263 }
264 }
265 }
266 if (par_perm!=NULL)
267 {
268 for (i=0; i<preim_p; i++)
269 {
270 for(j=0; j<n; j++)
271 {
272 if (strcmp(preim_par[i],names[j])==0)
273 {
274 if (BVERBOSE(V_IMAP))
275 Print("// par %s: par %d -> nr %d\n",preim_par[i],i+1,j+1);
276 /*par i+1 from preimage ring is var j+1 (index j+1) from image ring*/
277 par_perm[i]=j+1;
278 break;
279 }
280 }
281 if ((par!=NULL) && (par_perm[i]==0))
282 {
283 for(j=0; j<nop; j++)
284 {
285 if (strcmp(preim_par[i],par[j])==0)
286 {
287 if (BVERBOSE(V_IMAP))
288 Print("// par %s: nr %d -> par %d\n",preim_par[i],i+1,j+1);
289 /*par i+1 from preimage ring is par j+1 (index j) from image ring */
290 par_perm[i]=-(j+1);
291 }
292 }
293 }
294 }
295 }
296}

◆ maIMap()

poly maIMap ( ring src_ring,
ring dst_ring,
poly p )

◆ maMaxDeg_Ma()

int maMaxDeg_Ma ( ideal a,
ring preimage_r )

Definition at line 352 of file maps.cc.

353{
354 int i,j;
355 int N = preimage_r->N;
356 poly p;
357 int *m=(int *)omAlloc0(N*sizeof(int));
358
359 for (i=MATROWS(a)*MATCOLS(a)-1;i>=0;i--)
360 {
361 p=a->m[i];
362 //pTest(p); // cannot test p because it is from another ring
363 while(p!=NULL)
364 {
365 for(j=N-1;j>=0;j--)
366 {
367 m[j]=si_max(m[j],(int)p_GetExp( p,j+1,preimage_r));
368 if (m[j]>=MAX_MAP_DEG)
369 {
371 goto max_deg_fertig_id;
372 }
373 }
374 pIter(p);
375 }
376 }
377 i=m[0];
378 for(j=N-1;j>0;j--)
379 {
380 i=si_max(i,m[j]);
381 }
382max_deg_fertig_id:
383 omFreeSize((ADDRESS)m,N*sizeof(int));
384 return i;
385}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
void * ADDRESS
Definition auxiliary.h:120
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
#define omFreeSize(addr, size)
#define omAlloc0(size)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471

◆ maMaxDeg_P()

int maMaxDeg_P ( poly p,
ring preimage_r )

Definition at line 390 of file maps.cc.

391{
392 int i,j;
393 int N = preimage_r->N;
394 int *m=(int *)omAlloc0(N*sizeof(int));
395
396// pTest(p);
397 while(p!=NULL)
398 {
399 for(j=N-1;j>=0;j--)
400 {
401 m[j]=si_max(m[j],(int)p_GetExp(p,j+1,preimage_r));
402 if (m[j]>=MAX_MAP_DEG)
403 {
405 goto max_deg_fertig_p;
406 }
407 }
408 pIter(p);
409 }
410 i=m[0];
411 for(j=N-1;j>0;j--)
412 {
413 i=si_max(i,m[j]);
414 }
415max_deg_fertig_p:
416 omFreeSize((ADDRESS)m,N*sizeof(int));
417 return i;
418}

◆ p_MinPolyNormalize()

poly p_MinPolyNormalize ( poly p,
const ring r )

Definition at line 422 of file maps.cc.

423{
424 const coeffs C = r->cf;
425 number one = n_Init(1, C);
426 spolyrec rp;
427
428 poly q = &rp;
429
430 while (p != NULL)
431 {
432 // this returns 0, if p == MinPoly
433 number product = n_Mult(p_GetCoeff(p, r), one, C);
434 if ((product == NULL)||(n_IsZero(product, C)))
435 {
436 p_LmDelete(&p, r);
437 }
438 else
439 {
440 p_SetCoeff(p, product, r);
441 pNext(q) = p;
442 q = p;
443 p = pNext(p);
444 }
445 }
446 pNext(q) = NULL;
447 n_Delete(&one, C);
448 return rp.next;
449}
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:639
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:541
poly next
Definition monomials.h:24
#define pNext(p)
Definition monomials.h:36
#define p_GetCoeff(p, r)
Definition monomials.h:50
The main handler for Singular numbers which are suitable for Singular polynomials.
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414

◆ pSubstPoly()

poly pSubstPoly ( poly p,
int var,
poly image )

Definition at line 403 of file maps_ip.cc.

404{
405 if (p==NULL) return NULL;
406#ifdef HAVE_PLURAL
408 {
409 return pSubst(pCopy(p),var,image);
410 }
411#endif
412#ifdef HAVE_SHIFTBBA
413 if (rIsLPRing(currRing))
414 {
415 return pSubst(pCopy(p),var,image);
416 }
417#endif
418 return p_SubstPoly(p,var,image,currRing,currRing,ndCopyMap);
419}
poly p_SubstPoly(poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache=NULL)
Definition subst_maps.cc:46