My Project
Loading...
Searching...
No Matches
Macros | Functions
maps_ip.cc File Reference
#include "kernel/mod2.h"
#include "coeffs/numbers.h"
#include "coeffs/coeffs.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/maps.h"
#include "polys/matpol.h"
#include "polys/prCopy.h"
#include "polys/ext_fields/transext.h"
#include "misc/options.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/maps/gen_maps.h"
#include "maps_ip.h"
#include "ipid.h"
#include "lists.h"
#include "tok.h"
#include "ipshell.h"

Go to the source code of this file.

Macros

#define TRANSEXT_PRIVATES
 

Functions

BOOLEAN maApplyFetch (int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
 
poly pSubstPar (poly p, int par, poly image)
 
ideal idSubstPar (ideal id, int n, poly e)
 
poly pSubstPoly (poly p, int var, poly image)
 
ideal idSubstPoly (ideal id, int n, poly e)
 

Macro Definition Documentation

◆ TRANSEXT_PRIVATES

#define TRANSEXT_PRIVATES

Definition at line 7 of file maps_ip.cc.

Function Documentation

◆ idSubstPar()

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

Definition at line 387 of file maps_ip.cc.

388{
389 int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
391
392 res->rank = id->rank;
393 for(k--;k>=0;k--)
394 {
395 res->m[k]=pSubstPar(id->m[k],n,e);
396 }
397 return res;
398}
int k
Definition cfEzgcd.cc:99
poly * m
Definition matpol.h:18
CanonicalForm res
Definition facAbsFact.cc:60
poly pSubstPar(poly p, int par, poly image)
Definition maps_ip.cc:267
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

◆ 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);
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);
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}
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition numbers.cc:291
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
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

◆ maApplyFetch()

BOOLEAN maApplyFetch ( int what,
map theMap,
leftv res,
leftv w,
ring preimage_r,
int * perm,
int * par_perm,
int P,
nMapFunc nMap )

Definition at line 45 of file maps_ip.cc.

47{
49#ifdef HAVE_PLURAL
50 if ((what==IMAP_CMD)
53 {
54 assume(perm!=NULL);
55 int i=1;
56 while((i<preimage_r->N)&&(perm[i]==0)) i++;
58 {
59 int prev_nonnull=i;
60 i++;
61 for(;i<=preimage_r->N;i++)
62 {
63 if (perm[prev_nonnull] > perm[i])
64 {
66 {
67 Warn("imap not usable for permuting variables, use map (%s <-> %s)", preimage_r->names[prev_nonnull-1],preimage_r->names[i-1]);
68 }
70 break;
71 }
72 else
74 }
75 }
76 }
77#endif
78 int i;
79 int N = preimage_r->N;
80#if 0
81 Print("N=%d what=%s ",N,Tok2Cmdname(what));
82 if (perm!=NULL) for(i=1;i<=N;i++) Print("%d -> %d ",i,perm[i]);
83 PrintS("\n");
84 Print("P=%d ",P);
85 if (par_perm!=NULL) for(i=0;i<P;i++) Print("%d -> %d ",i,par_perm[i]);
86 PrintS("\n");
87#endif
88
89 void *data=w->Data();
90 res->rtyp = w->rtyp;
91 switch (w->rtyp)
92 {
93 case NUMBER_CMD:
94 if (P!=0)
95 {
96// poly n_PermNumber(const number z, const int *par_perm, const int OldPar, const ring src, const ring dst);
97 res->data= (void *) n_PermNumber((number)data, par_perm, P, preimage_r, currRing);
98 res->rtyp=POLY_CMD;
100 res->data=(void *)p_MinPolyNormalize((poly)res->data, currRing);
101 pTest((poly) res->data);
102 }
103 else
104 {
105 assume( nMap != NULL );
106 number a = nMap((number)data, preimage_r->cf, currRing->cf);
108 {
109 n_Normalize(a, currRing->cf);
110/*
111 number a = (number)res->data;
112 number one = nInit(1);
113 number product = nMult(a, one );
114 nDelete(&one);
115 nDelete(&a);
116 res->data=(void *)product;
117 */
118 }
119 #ifdef LDEBUG
120 n_Test(a, currRing->cf);
121 #endif
122 res->data=(void *)a;
123
124 }
125 break;
126 case BUCKET_CMD:
127 if (
128 (what==FETCH_CMD) && (preimage_r->cf==currRing->cf)
131#endif
132 )
133 res->data=(void *)prCopyR(sBucketPeek((sBucket_pt)data), preimage_r, currRing);
134 else
135 if ( (what==IMAP_CMD) || /*(*/ (what==FETCH_CMD) /*)*/) /* && (nMap!=nCopy)*/
137 else /*if (what==MAP_CMD)*/
138 {
140 }
143 break;
144 case POLY_CMD:
145 case VECTOR_CMD:
146 if (
147 (what==FETCH_CMD) && (preimage_r->cf==currRing->cf)
150#endif
151 )
152 res->data=(void *)prCopyR( (poly)data, preimage_r, currRing);
153 else
154 if ( (what==IMAP_CMD) || /*(*/ (what==FETCH_CMD) /*)*/) /* && (nMap!=nCopy)*/
155 res->data=(void *)p_PermPoly((poly)data,perm,preimage_r,currRing, nMap,par_perm,P,use_mult);
156 else /*if (what==MAP_CMD)*/
157 {
158 p_Test((poly)data,preimage_r);
159 res->data=(void*)maMapPoly((poly)data,preimage_r,(ideal)theMap,currRing,nMap);
160 }
162 res->data=(void *)p_MinPolyNormalize((poly)res->data, currRing);
163 pTest((poly)res->data);
164 break;
165 case MODUL_CMD:
166 case MATRIX_CMD:
167 case IDEAL_CMD:
168 case MAP_CMD:
169 {
170 int C=((matrix)data)->cols();
171 int R;
172 if (w->rtyp==MAP_CMD) R=1;
173 else R=((matrix)data)->rows();
174 matrix m=mpNew(R,C);
175 char *tmpR=NULL;
176 if(w->rtyp==MAP_CMD)
177 {
178 tmpR=((map)data)->preimage;
179 ((matrix)data)->rank=((matrix)data)->rows();
180 }
181 if (
182 (what==FETCH_CMD) && (preimage_r->cf == currRing->cf)
185#endif
186 )
187 {
188 for (i=R*C-1;i>=0;i--)
189 {
190 m->m[i]=prCopyR(((ideal)data)->m[i], preimage_r, currRing);
191 pTest(m->m[i]);
192 }
193 }
194 else if ((what==IMAP_CMD) || (what==FETCH_CMD))
195 {
196 for (i=R*C-1;i>=0;i--)
197 {
198 m->m[i]=p_PermPoly(((ideal)data)->m[i],perm,preimage_r,currRing,
200 pTest(m->m[i]);
201 }
202 }
203 else /* (what==MAP_CMD) */
204 {
205 assume(what==MAP_CMD);
207 for (i=R*C-1;i>=0;i--)
208 {
209 m->m[i]=maEval(theMap, ((ideal)data)->m[i], preimage_r, nMap, (ideal)s, currRing);
210 pTest(m->m[i]);
211 }
212 idDelete((ideal *)&s);
213 }
214 if(w->rtyp==MAP_CMD)
215 {
216 ((map)data)->preimage=tmpR;
217 ((map)m)->preimage=omStrDup(tmpR);
218 }
219 else
220 {
221 m->rank=((matrix)data)->rank;
222 }
223 res->data=(char *)m;
224 idTest((ideal) m);
225 break;
226 }
227
228 case LIST_CMD:
229 {
230 lists l=(lists)data;
232 ml->Init(l->nr+1);
233 for(i=0;i<=l->nr;i++)
234 {
235 if (((l->m[i].rtyp>BEGIN_RING)&&(l->m[i].rtyp<END_RING))
236 ||(l->m[i].rtyp==LIST_CMD))
237 {
238 if (maApplyFetch(what,theMap,&ml->m[i],&l->m[i],
239 preimage_r,perm,par_perm,P,nMap))
240 {
241 ml->Clean();
243 res->rtyp=0;
244 return TRUE;
245 }
246 }
247 else
248 {
249 ml->m[i].Copy(&l->m[i]);
250 }
251 }
252 res->data=(char *)ml;
253 break;
254 }
255 default:
256 {
257 return TRUE;
258 }
259 }
260 return FALSE;
261}
int BOOLEAN
Definition auxiliary.h:87
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
int l
Definition cfEzgcd.cc:100
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 lists.h:24
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition coeffs.h:843
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition coeffs.h:709
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition coeffs.h:907
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:575
#define Print
Definition emacs.cc:80
#define Warn
Definition emacs.cc:77
const CanonicalForm int s
Definition facAbsFact.cc:51
const CanonicalForm & w
Definition facAbsFact.cc:51
poly maMapPoly(const poly map_p, const ring map_r, const ideal image_id, const ring image_r, const nMapFunc nMap)
polynomial map for poly (vector) map_p: the poly (vector) to map map_r: the base ring for map_p image...
Definition gen_maps.cc:159
const char * Tok2Cmdname(int tok)
Definition gentable.cc:140
@ END_RING
Definition grammar.cc:310
@ IDEAL_CMD
Definition grammar.cc:284
@ MATRIX_CMD
Definition grammar.cc:286
@ BUCKET_CMD
Definition grammar.cc:283
@ IMAP_CMD
Definition grammar.cc:298
@ MAP_CMD
Definition grammar.cc:285
@ BEGIN_RING
Definition grammar.cc:282
@ MODUL_CMD
Definition grammar.cc:287
@ VECTOR_CMD
Definition grammar.cc:292
@ NUMBER_CMD
Definition grammar.cc:288
@ POLY_CMD
Definition grammar.cc:289
@ FETCH_CMD
Definition grammar.cc:295
#define idDelete(H)
delete an ideal
Definition ideals.h:29
#define idTest(id)
Definition ideals.h:47
VAR omBin slists_bin
Definition lists.cc:23
poly maEval(map theMap, poly p, ring preimage_r, nMapFunc nMap, ideal s, const ring dst_r)
Definition maps.cc:115
int maMaxDeg_Ma(ideal a, ring preimage_r)
Definition maps.cc:360
poly p_MinPolyNormalize(poly p, const ring r)
Definition maps.cc:430
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
Definition maps_ip.cc:45
ip_smatrix * matrix
Definition matpol.h:43
#define assume(x)
Definition mod2.h:389
slists * lists
#define omStrDup(s)
#define omAllocBin(bin)
#define omFreeBin(addr, bin)
#define NULL
Definition omList.c:12
#define TEST_V_ALLWARN
Definition options.h:142
poly n_PermNumber(const number z, const int *par_perm, const int, const ring src, const ring dst)
Definition p_polys.cc:4027
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition p_polys.cc:4130
#define p_Test(p, r)
Definition p_polys.h:161
#define pTest(p)
Definition polys.h:414
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition prCopy.cc:34
void PrintS(const char *s)
Definition reporter.cc:284
poly sBucketPeek(sBucket_pt b)
Definition sbuckets.cc:455
#define R
Definition sirandom.c:27
@ LIST_CMD
Definition tok.h:118

◆ pSubstPar()

poly pSubstPar ( poly p,
int par,
poly image )

Definition at line 267 of file maps_ip.cc.

268{
269 const ring R = currRing->cf->extRing;
271 nMapFunc nMap = n_SetMap(R->cf, currRing->cf);
272 int i;
273 for(i = rPar(currRing);i>0;i--)
274 {
275 if (i != par)
277 else
278 theMapI->m[i-1] = p_Copy(image, currRing);
279 p_Test(theMapI->m[i-1],currRing);
280 }
281 //iiWriteMatrix((matrix)theMapI,"map:",1,currRing,0);
282
284 theMap->preimage=NULL;
285
287 sleftv tmpW;
288 poly res=NULL;
289
291 if (currRing->cf->rep==n_rep_rat_fct )
292 {
293 while (p!=NULL)
294 {
295 memset(v,0,sizeof(sleftv));
296
298 p_Test((poly)NUM((fraction)d), R);
299
300 if ( n_IsOne (d, currRing->cf) )
301 {
302 n_Delete(&d, currRing->cf); d = NULL;
303 }
304 else if (!p_IsConstant((poly)NUM((fraction)d), R))
305 {
306 WarnS("ignoring denominators of coefficients...");
307 n_Delete(&d, currRing->cf); d = NULL;
308 }
309
311 memset(&tmpW,0,sizeof(sleftv));
312 tmpW.rtyp = POLY_CMD;
313 p_Test((poly)NUM((fraction)num), R);
314
315 tmpW.data = NUM ((fraction)num); // a copy of this poly will be used
316
319 {
320 WerrorS("map failed");
321 v->data=NULL;
322 }
323 n_Delete(&num, currRing->cf);
324 //TODO check for memory leaks
325 poly pp = pHead(p);
326 //PrintS("map:");pWrite(pp);
327 if( d != NULL )
328 {
329 pSetCoeff(pp, n_Invers(d, currRing->cf));
330 n_Delete(&d, currRing->cf); // d = NULL;
331 }
332 else
333 pSetCoeff(pp, nInit(1));
334
335 //PrintS("->");pWrite((poly)(v->data));
336 poly ppp = pMult((poly)(v->data),pp);
337 //PrintS("->");pWrite(ppp);
338 res=pAdd(res,ppp);
339 pIter(p);
340 }
341 }
342 else if (currRing->cf->rep==n_rep_poly )
343 {
344 while (p!=NULL)
345 {
346 memset(v,0,sizeof(sleftv));
347
349 memset(&tmpW,0,sizeof(sleftv));
350 tmpW.rtyp = POLY_CMD;
351 p_Test((poly)num, R);
352
353
354 p_Normalize((poly)num,R);
355 if (num==NULL) num=(number)R->qideal->m[0];
356 tmpW.data = num; // a copy of this poly will be used
358 {
359 WerrorS("map failed");
360 v->data=NULL;
361 }
362 if (num!=(number)R->qideal->m[0]) n_Delete(&num, currRing->cf);
363 //TODO check for memory leaks
364 poly pp = pHead(p);
365 //PrintS("map:");pWrite(pp);
366 pSetCoeff(pp,n_Init(1,currRing->cf));
367 //PrintS("cf->");pWrite((poly)(v->data));
368 poly ppp = pMult((poly)(v->data),pp);
369 //PrintS("->");pWrite(ppp);
370 res=pAdd(res,ppp);
371 pIter(p);
372 }
373 }
374 else
375 {
376 WerrorS("cannot apply subst for these coefficients");
377 }
378 idDelete((ideal *)(&theMap));
380 return res;
381}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
CanonicalForm num(const CanonicalForm &f)
int p
Definition cfModGcd.cc:4077
Class used for (list of) interpreter objects.
Definition subexpr.h:83
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1....
Definition coeffs.h:780
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1)
Definition coeffs.h:600
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of 'a'; raise an error if 'a' is not invertible
Definition coeffs.h:561
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:697
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
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition coeffs.h:605
@ n_rep_poly
(poly), see algext.h
Definition coeffs.h:113
@ n_rep_rat_fct
(fraction), see transext.h
Definition coeffs.h:114
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:73
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:465
#define WarnS
Definition emacs.cc:78
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
void WerrorS(const char *s)
Definition feFopen.cc:24
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
#define pIter(p)
Definition monomials.h:37
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
#define nInit(i)
Definition numbers.h:24
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3813
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition p_polys.cc:1473
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition p_polys.h:1964
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:846
#define pAdd(p, q)
Definition polys.h:203
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:67
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:31
#define pMult(p, q)
Definition polys.h:207
#define NUM
Definition readcf.cc:180
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:599
ideal idInit(int idsize, int rank)
initialise an ideal / module
sleftv * leftv
Definition structs.h:57

◆ 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
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