My Project  debian-1:4.1.1-p2+ds-4build4
Functions
gen_maps.cc File Reference
#include "kernel/mod2.h"
#include "omalloc/omalloc.h"
#include "misc/options.h"
#include "polys/monomials/p_polys.h"
#include "polys/prCopy.h"
#include "kernel/ideals.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/maps.h"
#include "polys/sbuckets.h"
#include "kernel/maps/fast_maps.h"
#include "kernel/maps/find_perm.h"
#include "kernel/maps/gen_maps.h"

Go to the source code of this file.

Functions

static void find_subst_for_map (const ring preimage_r, const ring image_r, const ideal image, int &var, poly &p)
 
ideal maMapIdeal (const ideal map_id, const ring preimage_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...
 

Function Documentation

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

Definition at line 17 of file gen_maps.cc.

18 {
19  p=NULL;
20  var=0;
21  int i,v;
22  for (i=si_min(IDELEMS(image),preimage_r->N)-1; i>=0; i--)
23  {
24  if (image->m[i]!=NULL)
25  {
26  if ((pNext(image->m[i])==NULL)
27  && (n_IsOne(pGetCoeff(image->m[i]),image_r->cf)))
28  {
29  v=p_IsUnivariate(image->m[i],image_r);
30  if ((v<=0) /*not univariate */
31  || (v!=i+1) /* non-trivial */
32  || (p_GetExp(image->m[i],v,image_r)!=1))
33  {
34  if (var==0)
35  {
36  var=i+1;
37  p=image->m[i];
38  }
39  else /* found second non-trivial entry */
40  {
41  goto non_trivial;
42  }
43  }
44  }
45  else
46  {
47  if (var==0)
48  {
49  var=i+1;
50  p=image->m[i];
51  }
52  else /* found second non-trivial entry */
53  {
54  goto non_trivial;
55  }
56  }
57  }
58  else
59  {
60  if (var==0)
61  {
62  var=i+1;
63  p=image->m[i];
64  }
65  else /* found second non-trivial entry */
66  {
67  goto non_trivial;
68  }
69  }
70  }
71  //Print("elms:%d, N:%d\n",IDELEMS(image),preimage_r->N);
72  //iiWriteMatrix((matrix)image,"_",1,image_r,0);
73  //PrintS("\npreimage:\n");rWrite(preimage_r);
74  //PrintS("image:\n");rWrite(image_r);
75  //Print("\nsusbt: v%d -> ",var);
76  //p_wrp(p,image_r,image_r);
77 non_trivial:
78  var=0;
79  p=NULL;
80 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
int i
Definition: cfEzgcd.cc:125
int p
Definition: cfModGcd.cc:4019
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:469
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define pNext(p)
Definition: monomials.h:43
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:51
#define NULL
Definition: omList.c:10
int p_IsUnivariate(poly p, const ring r)
return i, if poly depends only on var(i)
Definition: p_polys.cc:1239
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:469
#define IDELEMS(i)
Definition: simpleideals.h:24

◆ maMapIdeal()

ideal maMapIdeal ( const ideal  map_id,
const ring  preimage_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 88 of file gen_maps.cc.

89 {
90  if(!rIsPluralRing(image_r))
91  {
92  // heuristic:
93  // is the map a permutation ?
94  matrix m=ma_ApplyPermForMap((matrix)map_id,preimage_r,image_id,image_r,nMap);
95  if (m!=NULL)
96  {
97  if (TEST_OPT_PROT) PrintS("map is a permutation\n");
98  return (ideal)m;
99  }
100  // ----------------------------------------------------------
101  // is it a substitution of one variable ?
102  {
103  poly p;
104  int var;
105  find_subst_for_map(preimage_r,image_r,image_id,var,p);
106  if (var!=0)
107  {
108  return id_SubstPoly(map_id,var,p,preimage_r,image_r,nMap);
109  }
110  }
111  // ----------------------------------------------------------
112  // long polys in the image ?: possiblity of many common subexpressions
113  if ((nMap==ndCopyMap) /* and !rIsPluralRing(image_r) */
114  && (map_id->nrows==1) /* i.e. only for ideal/map */
115  && (map_id->rank==1))
116  {
117  int sz=IDELEMS(map_id);
118  int sz_l=0;
119  int sz_more=0;
120  int t,i;
121  for(i=sz-1;i>=0;i--)
122  {
123  sz_l+=pLength(map_id->m[i]);
124  }
125  for(i=IDELEMS(image_id)-1;i>=0;i--)
126  {
127  t=pLength(image_id->m[i]);
128  if ((t==0) || (t>1)) sz_more++;
129  }
130  if (((sz_l > sz*2) && (sz_more != 1))||(sz<5))
131  {
132  if (TEST_OPT_PROT) PrintS("map via common subexpressions\n");
133  return fast_map_common_subexp(map_id, preimage_r, image_id, image_r);
134  }
135  }
136  }
137  // ----------------------------------------------------------
138  // otherwise: try the generic method (generic map with cache)
139  if (TEST_OPT_PROT) PrintS("map with cache\n");
140  int C=((matrix)map_id)->cols();
141  int R=((matrix)map_id)->rows();
142  matrix m=mpNew(R,C);
143  int N = preimage_r->N;
144  matrix cache=mpNew(N,maMaxDeg_Ma(map_id,preimage_r));
145  int i;
146  for (i=R*C-1;i>=0;i--)
147  {
148  if (map_id->m[i]!=NULL)
149  {
150  m->m[i]=maEval((map)image_id, map_id->m[i], preimage_r, nMap, (ideal)cache, image_r);
151  p_Test(m->m[i],image_r);
152  }
153  }
154  idDelete((ideal *)&cache);
155  ideal ii=(ideal)m;
156  ii->rank=((ideal)map_id)->rank;
157  return (ideal)m;
158 }
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
int m
Definition: cfEzgcd.cc:121
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
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:354
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:70
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:17
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
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
poly maEval(map theMap, poly p, ring preimage_r, nMapFunc nMap, ideal s, const ring dst_r)
Definition: maps.cc:117
int maMaxDeg_Ma(ideal a, ring preimage_r)
Definition: maps.cc:254
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
ip_smatrix * matrix
Definition: matpol.h:31
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
#define TEST_OPT_PROT
Definition: options.h:102
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define p_Test(p, r)
Definition: p_polys.h:163
void PrintS(const char *s)
Definition: reporter.cc:284
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
#define R
Definition: sirandom.c:26