My Project
Loading...
Searching...
No Matches
subst_maps.cc File Reference

Go to the source code of this file.

Functions

static poly p_SubstMon (poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
poly p_SubstPoly (poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
ideal id_SubstPoly (ideal id, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap)

Function Documentation

◆ id_SubstPoly()

ideal id_SubstPoly ( ideal id,
int var,
poly image,
const ring preimage_r,
const ring image_r,
const nMapFunc nMap )

Definition at line 78 of file subst_maps.cc.

79{
80 matrix cache=mpNew(preimage_r->N,maMaxDeg_Ma(id, preimage_r));
81 int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
82 ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
83 res->rank = id->rank;
84 for(k--;k>=0;k--)
85 {
86 res->m[k]=p_SubstPoly(id->m[k],var,image,preimage_r,image_r,nMap,cache);
87 }
88 id_Delete((ideal*)&cache,image_r);
89 return res;
90}
int k
Definition cfEzgcd.cc:99
poly * m
Definition matpol.h:18
CanonicalForm res
Definition facAbsFact.cc:60
int maMaxDeg_Ma(ideal a, ring preimage_r)
Definition maps.cc:352
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
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
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:46

◆ p_SubstMon()

poly p_SubstMon ( poly p,
int var,
poly image,
const ring preimage_r,
const ring image_r,
const nMapFunc nMap,
matrix cache )
static

Definition at line 8 of file subst_maps.cc.

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 if (LIKELY(q!=NULL))
34 {
35 p_Setm(q,image_r);
36 h=p_Mult_mm(h,q,image_r);
37 p_LmDelete(q,image_r);
38 }
39 else
40 {
41 p_Delete(&h,image_r);
42 }
43 return h;
44}
#define LIKELY(X)
Definition auxiliary.h:404
int i
Definition cfEzgcd.cc:132
int p
Definition cfModGcd.cc:4086
STATIC_VAR Poly * h
Definition janet.cc:971
poly maEvalVariable(poly p, int v, int pExp, ideal s, const ring dst_r)
Definition maps.cc:48
#define assume(x)
Definition mod2.h:389
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:1314
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition p_polys.cc:1474
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
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 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
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1053
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427

◆ p_SubstPoly()

poly p_SubstPoly ( poly p,
int var,
poly image,
const ring preimage_r,
const ring image_r,
const nMapFunc nMap,
matrix cache )

Definition at line 46 of file subst_maps.cc.

47{
48 if (p==NULL) return NULL;
49
50 if (rIsNCRing(image_r))
51 {
52 if((image_r!=preimage_r)
53 ||(preimage_r!=currRing))
54 {
55 WerrorS("not implemented");
56 return NULL;
57 }
58 return pSubst(pCopy(p),var,image);
59 }
60 matrix org_cache=cache;
61 if (cache==NULL) cache=mpNew(preimage_r->N,maMaxDeg_P(p, preimage_r));
62
63 poly result = NULL;
64 sBucket_pt bucket = sBucketCreate(image_r);
65 while (p != NULL)
66 {
67 poly q=p_SubstMon(p,var,image,preimage_r,image_r,nMap,cache);
68 pIter(p);
69 if (q!=NULL) sBucket_Add_p(bucket,q,pLength(q));
70 }
71 int l_dummy;
72 sBucketDestroyAdd(bucket, &result, &l_dummy);
73 /*if no cache was passed,it is a local cache: */
74 if (org_cache==NULL) id_Delete((ideal*)&cache,image_r);
75 return result;
76}
return result
void WerrorS(const char *s)
Definition feFopen.cc:24
int maMaxDeg_P(poly p, ring preimage_r)
Definition maps.cc:390
#define pIter(p)
Definition monomials.h:37
static int pLength(poly a)
Definition p_polys.h:190
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
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
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