My Project
Loading...
Searching...
No Matches
Functions
gen_maps.cc File Reference
#include "kernel/mod2.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 coefficients
 
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 coefficients
 
number maEvalAt (const poly p, const number *pt, const ring r)
 evaluate the polynomial p at the pt given by the array pt
 

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 16 of file gen_maps.cc.

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

◆ 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 170 of file gen_maps.cc.

171{
172 ideal map=idInit(r->N,1);
173 for(int i=r->N-1;i>=0;i--)
174 {
175 map->m[i]=p_NSet(n_Copy(pt[i],r->cf),r);
176 }
177 poly v=maMapPoly(p,r,map,r,ndCopyMap);
178 id_Delete(&map,r);
179 number vv;
180 if (v==NULL)
181 vv=n_Init(0,r->cf);
182 else
183 {
184 vv=pGetCoeff(v);
185 p_LmFree(&v,r);
186 }
187 return vv;
188}
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:455
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition numbers.cc:287
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:539
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:162
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_LmFree(poly p, ring)
Definition p_polys.h:684
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix

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

Definition at line 87 of file gen_maps.cc.

88{
89 // handle special cases
90 if (IDELEMS(map_id)<=0)
91 return idInit(0,map_id->rank);
92 if(!rIsNCRing(image_r))
93 {
94 // heuristic:
95 // is the map a permutation ?
97 if (m!=NULL)
98 {
99 if (TEST_OPT_PROT) PrintS("map is a permutation\n");
100 return (ideal)m;
101 }
102 // ----------------------------------------------------------
103 // is it a substitution of one variable ?
104 {
105 poly p;
106 int var;
108 if (var!=0)
109 {
111 }
112 }
113 // ----------------------------------------------------------
114 // long polys in the image ?: possibility of many common subexpressions
115 if ((nMap==ndCopyMap) /* and !rIsPluralRing(image_r) */
116 && (map_id->nrows==1) /* i.e. only for ideal/map */
117 && (map_id->rank==1))
118 {
119 int sz=IDELEMS(map_id);
120 int sz_l=0;
121 int sz_more=0;
122 int t,i;
123 for(i=sz-1;i>=0;i--)
124 {
125 sz_l+=pLength(map_id->m[i]);
126 }
127 for(i=IDELEMS(image_id)-1;i>=0;i--)
128 {
129 t=pLength(image_id->m[i]);
130 if ((t==0) || (t>1)) sz_more++;
131 }
132 if (((sz_l > sz*2) && (sz_more != 1))||(sz<5))
133 {
134 if (TEST_OPT_PROT) PrintS("map via common subexpressions\n");
136 }
137 }
138 }
139 // ----------------------------------------------------------
140 // otherwise: try the generic method (generic map with cache)
141 if (TEST_OPT_PROT) PrintS("map with cache\n");
142 int C=((matrix)map_id)->cols();
143 int R=((matrix)map_id)->rows();
144 matrix m=mpNew(R,C);
145 int N = preimage_r->N;
147 int i;
148 for (i=R*C-1;i>=0;i--)
149 {
150 if (map_id->m[i]!=NULL)
151 {
153 p_Test(m->m[i],image_r);
154 }
155 }
156 idDelete((ideal *)&cache);
157 ideal ii=(ideal)m;
158 ii->rank=((ideal)map_id)->rank;
159 return (ideal)m;
160}
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
int m
Definition cfEzgcd.cc:128
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:69
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
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
#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:115
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
ip_smatrix * matrix
Definition matpol.h:43
#define TEST_OPT_PROT
Definition options.h:105
static int pLength(poly a)
Definition p_polys.h:190
#define p_Test(p, r)
Definition p_polys.h:161
void PrintS(const char *s)
Definition reporter.cc:284
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:426
#define R
Definition sirandom.c:27

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

Definition at line 162 of file gen_maps.cc.

163{
167 return p;
168}
const CanonicalForm int s
Definition facAbsFact.cc:51
int maMaxDeg_P(poly p, ring preimage_r)
Definition maps.cc:398