My Project
Loading...
Searching...
No Matches
Functions
maps.h File Reference
#include "coeffs/coeffs.h"
#include "polys/monomials/ring.h"

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 426 of file maps_ip.cc.

427{
428
429#ifdef HAVE_PLURAL
431 {
432 int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
433 ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
434 res->rank = id->rank;
435 for(k--;k>=0;k--)
436 {
437 res->m[k]=pSubst(pCopy(id->m[k]),n,e);
438 }
439 return res;
440 }
441#endif
442#ifdef HAVE_SHIFTBBA
443 if (rIsLPRing(currRing))
444 {
445 int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
446 ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
447 res->rank = id->rank;
448 for(k--;k>=0;k--)
449 {
450 res->m[k]=pSubst(pCopy(id->m[k]),n,e);
451 }
452 return res;
453 }
454#endif
456}
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:291
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:71
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
#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:365
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:411

◆ maCopy()

map maCopy ( map  theMap,
const ring  dst_ring 
)

Definition at line 32 of file maps.cc.

33{
34 int i;
35 map m=(map)idInit(IDELEMS(theMap),0);
36 for (i=IDELEMS(theMap)-1; i>=0; i--)
37 m->m[i] = p_Copy(theMap->m[i],r);
38 m->preimage=omStrDup(theMap->preimage);
39 return m;
40}
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
Definition: cf_map_ext.cc:504
#define omStrDup(s)
Definition: omAllocDecl.h:263
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:844
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ maEval()

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

Definition at line 115 of file maps.cc.

116{
117 poly result = NULL;
118 int i;
119
120// for(i=1; i<=preimage_r->N; i++)
121// {
122// pTest(theMap->m[i-1]);
123// }
124// while (p!=NULL)
125// {
126// poly q=maEvalMonom(theMap,p,preimage_r,s);
127// result = pAdd(result,q);
128// pIter(p);
129// }
130 if (p!=NULL)
131 {
132 int l = pLength(p)-1;
133 poly* monoms;
134 if (l>0)
135 {
136 monoms = (poly*) omAlloc(l*sizeof(poly));
137
138 for (i=0; i<l; i++)
139 {
140 monoms[i]=maEvalMonom(theMap,p,preimage_r,s, nMap, dst_r);
141 pIter(p);
142 }
143 }
144 result=maEvalMonom(theMap,p,preimage_r,s, nMap, dst_r);
145 if (l>0)
146 {
147 for(i = l-1; i>=0; i--)
148 {
149 result=p_Add_q(result, monoms[i], dst_r);
150 }
151 omFreeSize((ADDRESS)monoms,l*sizeof(poly));
152 }
153
154 assume(dst_r != NULL);
155 assume(dst_r->cf != NULL);
156
157 if (nCoeff_is_algExt(dst_r->cf))
159 }
160 return result;
161}
void * ADDRESS
Definition: auxiliary.h:119
int l
Definition: cfEzgcd.cc:100
int p
Definition: cfModGcd.cc:4078
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:907
return result
Definition: facAbsBiFact.cc:75
const CanonicalForm int s
Definition: facAbsFact.cc:51
static poly maEvalMonom(map theMap, poly p, ring preimage_r, ideal s, nMapFunc nMap, const ring dst_r)
Definition: maps.cc:85
poly p_MinPolyNormalize(poly p, const ring r)
Definition: maps.cc:430
#define assume(x)
Definition: mod2.h:389
#define pIter(p)
Definition: monomials.h:37
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define NULL
Definition: omList.c:12
static int pLength(poly a)
Definition: p_polys.h:188
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:934

◆ maEvalVariable()

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

Definition at line 46 of file maps.cc.

47{
48 if (pExp==1)
49 return p_Copy(p,dst_r);
50
51 poly res;
52
53 if((s!=NULL)&&(pExp<MAX_MAP_DEG))
54 {
55 int j=2;
56 poly p0=p;
57 // find starting point
58 if(MATELEM(s,v,1)==NULL)
59 {
60 MATELEM(s,v,1)=p_Copy(p/*theMap->m[v-1]*/,dst_r);
61 }
62 else
63 {
64 while((j<=pExp)&&(MATELEM(s,v,j)!=NULL))
65 {
66 j++;
67 }
68 p0=MATELEM(s,v,j-1);
69 }
70 // multiply
71 for(;j<=pExp;j++)
72 {
73 p0=MATELEM(s,v,j)=pp_Mult_qq(p0, p,dst_r);
74 p_Normalize(p0, dst_r);
75 }
76 res=p_Copy(p0/*MATELEM(s,v,pExp)*/,dst_r);
77 }
78 else //if ((p->next!=NULL)&&(p->next->next==NULL))
79 {
80 res=p_Power(p_Copy(p,dst_r),pExp,dst_r);
81 }
82 return res;
83}
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:27
#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:2197
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3813
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1149

◆ maFetchPermLP()

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

Definition at line 306 of file maps.cc.

308{
309 for (int i = 0; i < preimage_r->N + 1; i++) { perm[i] = 0; }
310
311 int preimage_lV = preimage_r->isLPring;
312 int r_lV = dst_r->isLPring;
313
314 int preimage_ncgens = preimage_r->LPncGenCount;
315 int r_ncges = dst_r->LPncGenCount;
316
317 int preimage_vars = preimage_lV - preimage_ncgens;
318 int r_vars = r_lV - r_ncges;
319
320 // for each block
321 for (int i = 0; i < si_min(preimage_r->N / preimage_lV, dst_r->N / r_lV); i++)
322 {
323 // align variables
324 for (int j = 1; j <= si_min(preimage_vars, r_vars); j++)
325 {
326 perm[(i * preimage_lV) + j] = (i * r_lV) + j;
327 }
328
329 // align ncgens
330 for (int j = 1; j <= si_min(preimage_ncgens, r_ncges); j++)
331 {
332 perm[(i * preimage_lV) + preimage_vars + j] = (i * r_lV) + r_vars + j;
333 }
334 }
335}
static int si_min(const int a, const int b)
Definition: auxiliary.h:125

◆ 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 163 of file maps.cc.

166{
167 int i,j;
168 /* find correspondig vars */
169 for (i=0; i<preim_n; i++)
170 {
171 for(j=0; j<n; j++)
172 {
173 if (strcmp(preim_names[i],names[j])==0)
174 {
175 if (BVERBOSE(V_IMAP))
176 Print("// var %s: nr %d -> nr %d\n",preim_names[i],i+1,j+1);
177 /* var i+1 from preimage ring is var j+1 (index j+1) from image ring */
178 perm[i+1]=j+1;
179 break;
180 }
181 }
182 if ((perm[i+1]==0)&&(par!=NULL)
183 // do not consider par of Fq
184 && (ch!=n_GF))
185 {
186 for(j=0; j<nop; j++)
187 {
188 if (strcmp(preim_names[i],par[j])==0)
189 {
190 if (BVERBOSE(V_IMAP))
191 Print("// var %s: nr %d -> par %d\n",preim_names[i],i+1,j+1);
192 /* var i+1 from preimage ring is par j+1 (index j) from image ring */
193 perm[i+1]=-(j+1);
194 }
195 }
196 }
197 }
198 if (par_perm!=NULL)
199 {
200 for (i=0; i<preim_p; i++)
201 {
202 for(j=0; j<n; j++)
203 {
204 if (strcmp(preim_par[i],names[j])==0)
205 {
206 if (BVERBOSE(V_IMAP))
207 Print("// par %s: par %d -> nr %d\n",preim_par[i],i+1,j+1);
208 /*par i+1 from preimage ring is var j+1 (index j+1) from image ring*/
209 par_perm[i]=j+1;
210 break;
211 }
212 }
213 if ((par!=NULL) && (par_perm[i]==0))
214 {
215 for(j=0; j<nop; j++)
216 {
217 if (strcmp(preim_par[i],par[j])==0)
218 {
219 if (BVERBOSE(V_IMAP))
220 Print("// par %s: nr %d -> par %d\n",preim_par[i],i+1,j+1);
221 /*par i+1 from preimage ring is par j+1 (index j) from image ring */
222 par_perm[i]=-(j+1);
223 }
224 }
225 }
226 }
227 }
228}
@ 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 231 of file maps.cc.

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

◆ maIMap()

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

◆ maMaxDeg_Ma()

int maMaxDeg_Ma ( ideal  a,
ring  preimage_r 
)

Definition at line 360 of file maps.cc.

361{
362 int i,j;
363 int N = preimage_r->N;
364 poly p;
365 int *m=(int *)omAlloc0(N*sizeof(int));
366
367 for (i=MATROWS(a)*MATCOLS(a)-1;i>=0;i--)
368 {
369 p=a->m[i];
370 //pTest(p); // cannot test p because it is from another ring
371 while(p!=NULL)
372 {
373 for(j=N-1;j>=0;j--)
374 {
375 m[j]=si_max(m[j],(int)p_GetExp( p,j+1,preimage_r));
376 if (m[j]>=MAX_MAP_DEG)
377 {
379 goto max_deg_fertig_id;
380 }
381 }
382 pIter(p);
383 }
384 }
385 i=m[0];
386 for(j=N-1;j>0;j--)
387 {
388 i=si_max(i,m[j]);
389 }
390max_deg_fertig_id:
391 omFreeSize((ADDRESS)m,N*sizeof(int));
392 return i;
393}
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
#define omAlloc0(size)
Definition: omAllocDecl.h:211
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:467

◆ maMaxDeg_P()

int maMaxDeg_P ( poly  p,
ring  preimage_r 
)

Definition at line 398 of file maps.cc.

399{
400 int i,j;
401 int N = preimage_r->N;
402 int *m=(int *)omAlloc0(N*sizeof(int));
403
404// pTest(p);
405 while(p!=NULL)
406 {
407 for(j=N-1;j>=0;j--)
408 {
409 m[j]=si_max(m[j],(int)p_GetExp(p,j+1,preimage_r));
410 if (m[j]>=MAX_MAP_DEG)
411 {
413 goto max_deg_fertig_p;
414 }
415 }
416 pIter(p);
417 }
418 i=m[0];
419 for(j=N-1;j>0;j--)
420 {
421 i=si_max(i,m[j]);
422 }
423max_deg_fertig_p:
424 omFreeSize((ADDRESS)m,N*sizeof(int));
425 return i;
426}

◆ p_MinPolyNormalize()

poly p_MinPolyNormalize ( poly  p,
const ring  r 
)

Definition at line 430 of file maps.cc.

431{
432 const coeffs C = r->cf;
433 number one = n_Init(1, C);
434 spolyrec rp;
435
436 poly q = &rp;
437
438 while (p != NULL)
439 {
440 // this returns 0, if p == MinPoly
441 number product = n_Mult(p_GetCoeff(p, r), one, C);
442 if ((product == NULL)||(n_IsZero(product, C)))
443 {
444 p_LmDelete(&p, r);
445 }
446 else
447 {
448 p_SetCoeff(p, product, r);
449 pNext(q) = p;
450 q = p;
451 p = pNext(p);
452 }
453 }
454 pNext(q) = NULL;
455 n_Delete(&one, C);
456 return rp.next;
457}
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:633
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:461
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
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:535
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:721
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:410

◆ pSubstPoly()

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

Definition at line 404 of file maps_ip.cc.

405{
406 if (p==NULL) return NULL;
407#ifdef HAVE_PLURAL
409 {
410 return pSubst(pCopy(p),var,image);
411 }
412#endif
413#ifdef HAVE_SHIFTBBA
414 if (rIsLPRing(currRing))
415 {
416 return pSubst(pCopy(p),var,image);
417 }
418#endif
419 return p_SubstPoly(p,var,image,currRing,currRing,ndCopyMap);
420}
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:39