My Project
Loading...
Searching...
No Matches
subst_maps.cc
Go to the documentation of this file.
1#include "kernel/mod2.h"
3#include "kernel/ideals.h"
7
8static poly p_SubstMon(poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
9{
10 assume(!rIsNCRing(image_r));
11 poly q=p_NSet(nMap(pGetCoeff(p),preimage_r->cf,image_r->cf),image_r);
12 int i;
13 poly h=NULL;
14 for(i=1;i<=preimage_r->N; i++)
15 {
16 int pExp=p_GetExp( p,i,preimage_r);
17 if (i!=var)
18 {
19 p_SetExp(q,i,pExp,image_r);
20 }
21 else if (pExp!=0)
22 {
23 h=maEvalVariable(image,var,pExp,(ideal)cache,image_r);
24 if (h==NULL)
25 {
26 p_LmDelete(q,image_r);
27 return NULL;
28 }
29 }
30 else
31 h=p_One(image_r);
32 }
33 p_Setm(q,image_r);
34 h=p_Mult_mm(h,q,image_r);
35 p_LmDelete(q,image_r);
36 return h;
37}
38
39poly p_SubstPoly (poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
40{
41 if (p==NULL) return NULL;
42
43 if (rIsNCRing(image_r))
44 {
45 if((image_r!=preimage_r)
46 ||(preimage_r!=currRing))
47 {
48 WerrorS("not implemented");
49 return NULL;
50 }
51 return pSubst(pCopy(p),var,image);
52 }
53 matrix org_cache=cache;
54 if (cache==NULL) cache=mpNew(preimage_r->N,maMaxDeg_P(p, preimage_r));
55
56 poly result = NULL;
57 sBucket_pt bucket = sBucketCreate(image_r);
58 while (p != NULL)
59 {
60 poly q=p_SubstMon(p,var,image,preimage_r,image_r,nMap,cache);
61 pIter(p);
62 if (q!=NULL) sBucket_Add_p(bucket,q,pLength(q));
63 }
64 int l_dummy;
65 sBucketDestroyAdd(bucket, &result, &l_dummy);
66 /*if no cache was passed,it is a local cache: */
67 if (org_cache==NULL) id_Delete((ideal*)&cache,image_r);
68 return result;
69}
70
71ideal id_SubstPoly (ideal id, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap)
72{
73 matrix cache=mpNew(preimage_r->N,maMaxDeg_Ma(id, preimage_r));
74 int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
75 ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
76 res->rank = id->rank;
77 for(k--;k>=0;k--)
78 {
79 res->m[k]=p_SubstPoly(id->m[k],var,image,preimage_r,image_r,nMap,cache);
80 }
81 id_Delete((ideal*)&cache,image_r);
82 return res;
83}
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
int p
Definition: cfModGcd.cc:4078
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
return result
Definition: facAbsBiFact.cc:75
CanonicalForm res
Definition: facAbsFact.cc:60
void WerrorS(const char *s)
Definition: feFopen.cc:24
STATIC_VAR Poly * h
Definition: janet.cc:971
int maMaxDeg_P(poly p, ring preimage_r)
Definition: maps.cc:398
poly maEvalVariable(poly p, int v, int pExp, ideal s, const ring dst_r)
Definition: maps.cc:46
int maMaxDeg_Ma(ideal a, ring preimage_r)
Definition: maps.cc:360
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
#define assume(x)
Definition: mod2.h:389
#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 NULL
Definition: omList.c:12
poly p_One(const ring r)
Definition: p_polys.cc:1313
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1473
static int pLength(poly a)
Definition: p_polys.h:188
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:721
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:486
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:231
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
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1049
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 rIsNCRing(const ring r)
Definition: ring.h:421
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
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:68
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
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
static poly p_SubstMon(poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
Definition: subst_maps.cc:8
poly p_SubstPoly(poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
Definition: subst_maps.cc:39