My Project  debian-1:4.1.2-p1+ds-2
Functions
gen_maps.h File Reference

Go to the source code of this file.

Functions

ideal maMapIdeal (const ideal map_id, const ring map_r, const ideal image_id, const ring image_r, const nMapFunc nMap)
 polynomial map for ideals/module/matrix map_id: the ideal to map map_r: the base ring for map_id image_id: the image of the variables image_r: the base ring for image_id nMap: map for coeffcients More...
 
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_id: the image of the variables image_r: the base ring for image_id nMap: map for coeffcients More...
 
poly p_SubstPoly (poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache=NULL)
 
ideal id_SubstPoly (ideal id, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap)
 
number maEvalAt (const poly p, const number *pt, const ring r)
 evaluate the polynomial p at the pt given by the array pt More...
 

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 68 of file subst_maps.cc.

69 {
70  matrix cache=mpNew(preimage_r->N,maMaxDeg_Ma(id, preimage_r));
71  int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
72  ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
73  res->rank = id->rank;
74  for(k--;k>=0;k--)
75  {
76  res->m[k]=p_SubstPoly(id->m[k],var,image,preimage_r,image_r,nMap,cache);
77  }
78  return res;
79 }

◆ maEvalAt()

number maEvalAt ( const poly  p,
const number *  pt,
const ring  r 
)

evaluate the polynomial p at the pt given by the array pt

Definition at line 167 of file gen_maps.cc.

168 {
169  ideal map=idInit(r->N,1);
170  for(int i=r->N-1;i>=0;i--)
171  {
172  map->m[i]=p_NSet(n_Copy(pt[i],r->cf),r);
173  }
174  poly v=maMapPoly(p,r,map,r,ndCopyMap);
175  id_Delete(&map,r);
176  number vv=pGetCoeff(v);
177  p_LmFree(&v,r);
178  return vv;
179 }

◆ maMapIdeal()

ideal maMapIdeal ( const ideal  map_id,
const ring  map_r,
const ideal  image_id,
const ring  image_r,
const nMapFunc  nMap 
)

polynomial map for ideals/module/matrix map_id: the ideal to map map_r: the base ring for map_id image_id: the image of the variables image_r: the base ring for image_id nMap: map for coeffcients

Definition at line 87 of file gen_maps.cc.

88 {
89  if(!rIsPluralRing(image_r))
90  {
91  // heuristic:
92  // is the map a permutation ?
93  matrix m=ma_ApplyPermForMap((matrix)map_id,preimage_r,image_id,image_r,nMap);
94  if (m!=NULL)
95  {
96  if (TEST_OPT_PROT) PrintS("map is a permutation\n");
97  return (ideal)m;
98  }
99  // ----------------------------------------------------------
100  // is it a substitution of one variable ?
101  {
102  poly p;
103  int var;
104  find_subst_for_map(preimage_r,image_r,image_id,var,p);
105  if (var!=0)
106  {
107  return id_SubstPoly(map_id,var,p,preimage_r,image_r,nMap);
108  }
109  }
110  // ----------------------------------------------------------
111  // long polys in the image ?: possiblity of many common subexpressions
112  if ((nMap==ndCopyMap) /* and !rIsPluralRing(image_r) */
113  && (map_id->nrows==1) /* i.e. only for ideal/map */
114  && (map_id->rank==1))
115  {
116  int sz=IDELEMS(map_id);
117  int sz_l=0;
118  int sz_more=0;
119  int t,i;
120  for(i=sz-1;i>=0;i--)
121  {
122  sz_l+=pLength(map_id->m[i]);
123  }
124  for(i=IDELEMS(image_id)-1;i>=0;i--)
125  {
126  t=pLength(image_id->m[i]);
127  if ((t==0) || (t>1)) sz_more++;
128  }
129  if (((sz_l > sz*2) && (sz_more != 1))||(sz<5))
130  {
131  if (TEST_OPT_PROT) PrintS("map via common subexpressions\n");
132  return fast_map_common_subexp(map_id, preimage_r, image_id, image_r);
133  }
134  }
135  }
136  // ----------------------------------------------------------
137  // otherwise: try the generic method (generic map with cache)
138  if (TEST_OPT_PROT) PrintS("map with cache\n");
139  int C=((matrix)map_id)->cols();
140  int R=((matrix)map_id)->rows();
141  matrix m=mpNew(R,C);
142  int N = preimage_r->N;
143  matrix cache=mpNew(N,maMaxDeg_Ma(map_id,preimage_r));
144  int i;
145  for (i=R*C-1;i>=0;i--)
146  {
147  if (map_id->m[i]!=NULL)
148  {
149  m->m[i]=maEval((map)image_id, map_id->m[i], preimage_r, nMap, (ideal)cache, image_r);
150  p_Test(m->m[i],image_r);
151  }
152  }
153  idDelete((ideal *)&cache);
154  ideal ii=(ideal)m;
155  ii->rank=((ideal)map_id)->rank;
156  return (ideal)m;
157 }

◆ maMapPoly()

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_id: the image of the variables image_r: the base ring for image_id nMap: map for coeffcients

Definition at line 159 of file gen_maps.cc.

160 {
161  matrix s=mpNew(map_r->N,maMaxDeg_P(map_p, map_r));
162  poly p=maEval((map)image_id, map_p, map_r, nMap, (ideal)s, image_r);
163  id_Delete((ideal*)&s,image_r);
164  return p;
165 }

◆ p_SubstPoly()

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

Definition at line 39 of file subst_maps.cc.

40 {
41  if (p==NULL) return NULL;
42 
43  if (rIsPluralRing(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  if (cache==NULL) cache=mpNew(preimage_r->N,maMaxDeg_P(p, preimage_r));
54 
55  poly result = NULL;
56  sBucket_pt bucket = sBucketCreate(image_r);
57  while (p != NULL)
58  {
59  poly q=p_SubstMon(p,var,image,preimage_r,image_r,nMap,cache);
60  pIter(p);
61  if (q!=NULL) sBucket_Add_p(bucket,q,pLength(q));
62  }
63  int l_dummy;
64  sBucketDestroyAdd(bucket, &result, &l_dummy);
65  return result;
66 }
matrix
ip_smatrix * matrix
Definition: matpol.h:42
ip_smatrix
Definition: matpol.h:13
ma_ApplyPermForMap
matrix ma_ApplyPermForMap(const matrix to_map, const ring preimage_r, const ideal image, const ring image_r, const nMapFunc nMap)
helper function for maMapIdeal mapping ideal/matrix/module for the case of a permutation: maps the id...
Definition: find_perm.cc:69
maMaxDeg_Ma
int maMaxDeg_Ma(ideal a, ring preimage_r)
Definition: maps.cc:328
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition: options.h:100
k
int k
Definition: cfEzgcd.cc:92
idDelete
#define idDelete(H)
delete an ideal
Definition: ideals.h:28
maMapPoly
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
result
return result
Definition: facAbsBiFact.cc:76
sBucketDestroyAdd
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:66
map
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:400
ndCopyMap
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
p_Test
#define p_Test(p, r)
Definition: p_polys.h:154
N
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:396
pLength
static unsigned pLength(poly a)
Definition: p_polys.h:182
i
int i
Definition: cfEzgcd.cc:125
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:122
res
CanonicalForm res
Definition: facAbsFact.cc:64
PrintS
void PrintS(const char *s)
Definition: reporter.cc:283
sBucket_Add_p
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition: sbuckets.cc:201
sBucketCreate
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:94
find_subst_for_map
static void find_subst_for_map(const ring preimage_r, const ring image_r, const ideal image, int &var, poly &p)
Definition: gen_maps.cc:16
ip_smatrix::m
poly * m
Definition: matpol.h:18
pIter
#define pIter(p)
Definition: monomials.h:34
maMaxDeg_P
int maMaxDeg_P(poly p, ring preimage_r)
Definition: maps.cc:366
mpNew
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
fast_map_common_subexp
ideal fast_map_common_subexp(const ideal map_id, const ring map_r, const ideal image_id, const ring image_r)
Definition: fast_maps.cc:346
sBucket
Definition: sbuckets.cc:27
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: subst_maps.cc:39
p_LmFree
static void p_LmFree(poly p, ring)
Definition: p_polys.h:669
id_SubstPoly
ideal id_SubstPoly(ideal id, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap)
Definition: subst_maps.cc:68
p_NSet
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1452
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:34
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:450
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
m
int m
Definition: cfEzgcd.cc:121
MATCOLS
#define MATCOLS(i)
Definition: matpol.h:27
NULL
#define NULL
Definition: omList.c:11
R
#define R
Definition: sirandom.c:27
p_SubstMon
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
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
p
int p
Definition: cfModGcd.cc:4019
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
pCopy
#define pCopy(p)
return a copy of the poly
Definition: polys.h:174
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:23
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:41
MATROWS
#define MATROWS(i)
Definition: matpol.h:26
pSubst
#define pSubst(p, n, e)
Definition: polys.h:350
maEval
poly maEval(map theMap, poly p, ring preimage_r, nMapFunc nMap, ideal s, const ring dst_r)
Definition: maps.cc:114