Loading...
Searching...
No Matches
maps.cc File Reference
`#include "misc/auxiliary.h"`
`#include "misc/options.h"`
`#include "coeffs/coeffs.h"`
`#include "coeffs/numbers.h"`
`#include "polys/monomials/p_polys.h"`
`#include "polys/monomials/ring.h"`
`#include "polys/simpleideals.h"`
`#include "polys/prCopy.h"`
`#include "polys/monomials/maps.h"`
`#include "polys/sbuckets.h"`
`#include "polys/nc/nc.h"`

Go to the source code of this file.

## Macros

#define | MAX_MAP_DEG 128

## Functions

map | maCopy (map theMap, const ring r)
poly | maEvalVariable (poly p, int v, int pExp, ideal s, const ring dst_r)
static poly | maEvalMonom (map theMap, poly p, ring preimage_r, ideal s, nMapFunc nMap, const ring dst_r)
poly | maEval (map theMap, poly p, ring preimage_r, nMapFunc nMap, ideal s, const ring dst_r)
void | maFindPerm (char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
void | maFindPermLP (char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch, int lV)
void | maFetchPermLP (const ring preimage_r, const ring dst_r, int *perm)
poly | maIMap (ring r, poly p, const ring dst_r)
int | maMaxDeg_Ma (ideal a, ring preimage_r)
int | maMaxDeg_P (poly p, ring preimage_r)
poly | p_MinPolyNormalize (poly p, const ring r)

## Macro Definition Documentation

## MAX_MAP_DEG

#define MAX_MAP_DEG 128

Definition at line 29 of file maps.cc.

## Function Documentation

## maCopy()

map maCopy | ( | map | theMap,
|  | const ring | r )

Definition at line 34 of file maps.cc.

{
int i;
map m=(map)idInit(IDELEMS(theMap),0);
for (i=IDELEMS(theMap)-1; i>=0; i--)
m->m[i] = p_Copy(theMap->m[i],r);
m->preimage=omStrDup(theMap->preimage);
return m;
}
m
int m
Definition cfEzgcd.cc:128
i
int i
Definition cfEzgcd.cc:132
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:505
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
p_Copy
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23

## maEval()

poly maEval | ( | map | theMap,
|  | poly | p,
|  | ring | preimage_r,
|  | nMapFunc | nMap,
|  | ideal | s,
|  | const ring | dst_r )

Definition at line 117 of file maps.cc.

{
poly result = NULL;
int i;
// for(i=1; i<=preimage_r->N; i++)
// {
// pTest(theMap->m[i-1]);
// }
// while (p!=NULL)
// {
// poly q=maEvalMonom(theMap,p,preimage_r,s);
// result = pAdd(result,q);
// pIter(p);
// }
if (p!=NULL)
{
sBucket_pt b=sBucketCreate(dst_r);
int l;
while(p!=NULL)
{
poly h=maEvalMonom(theMap,p,preimage_r,s, nMap, dst_r);
l=pLength(h);
sBucket_Add_p(b,h,l);
pIter(p);
}
sBucketDestroyAdd(b,&result,&l);
assume(dst_r != NULL);
assume(dst_r->cf != NULL);
if (nCoeff_is_algExt(dst_r->cf))
result = p_MinPolyNormalize(result, dst_r);
}
return result;
}
l
int l
Definition cfEzgcd.cc:100
p
int p
Definition cfModGcd.cc:4086
b
CanonicalForm b
Definition cfModGcd.cc:4111
nCoeff_is_algExt
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition coeffs.h:905
result
return result
Definition facAbsBiFact.cc:76
s
const CanonicalForm int s
Definition facAbsFact.cc:51
h
STATIC_VAR Poly * h
Definition janet.cc:971
maEvalMonom
static poly maEvalMonom(map theMap, poly p, ring preimage_r, ideal s, nMapFunc nMap, const ring dst_r)
Definition maps.cc:87
p_MinPolyNormalize
poly p_MinPolyNormalize(poly p, const ring r)
Definition maps.cc:422
assume
#define assume(x)
Definition mod2.h:389
pIter
#define pIter(p)
Definition monomials.h:37
NULL
#define NULL
Definition omList.c:12
pLength
static int pLength(poly a)
Definition p_polys.h:190
sBucket_Add_p
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition sbuckets.cc:203
sBucketCreate
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96
sBucket_pt
sBucket * sBucket_pt
Definition sbuckets.h:16
sBucketDestroyAdd
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.h:68

## maEvalMonom()

poly maEvalMonom | ( | map | theMap,
|  | poly | p,
|  | ring | preimage_r,
|  | ideal | s,
|  | nMapFunc | nMap,
|  | const ring | dst_r )

static

Definition at line 87 of file maps.cc.

{
p_Test(p,preimage_r);
poly q=p_NSet(nMap(pGetCoeff(p),preimage_r->cf,dst_r->cf),dst_r);
int i;
for(i=1;i<=preimage_r->N; i++)
{
int pExp=p_GetExp( p,i,preimage_r);
if (pExp != 0)
{
if (theMap->m[i-1]!=NULL)
{
poly p1=theMap->m[i-1];
poly pp=maEvalVariable(p1,i,pExp,s,dst_r);
q = p_Mult_q(q,pp,dst_r);
}
else
{
p_Delete(&q,dst_r);
break;
}
}
}
int modulComp = p_GetComp( p,preimage_r);
if (q!=NULL) p_SetCompP(q,modulComp,dst_r);
return q;
}
pp
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
maEvalVariable
poly maEvalVariable(poly p, int v, int pExp, ideal s, const ring dst_r)
Definition maps.cc:48
p_GetComp
#define p_GetComp(p, r)
Definition monomials.h:64
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:44
p_NSet
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition p_polys.cc:1474
p_Mult_q
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125
p_SetCompP
static void p_SetCompP(poly p, int i, ring r)
Definition p_polys.h:256
p_GetExp
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
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
p_Test
#define p_Test(p, r)
Definition p_polys.h:161

## maEvalVariable()

poly maEvalVariable | ( | poly | p,
|  | int | v,
|  | int | pExp,
|  | ideal | s,
|  | const ring | dst_r )

Definition at line 48 of file maps.cc.

{
if (pExp==1)
return p_Copy(p,dst_r);
poly res;
if((s!=NULL)&&(pExp<MAX_MAP_DEG))
{
int j=2;
poly p0=p;
// find starting point
if(MATELEM(s,v,1)==NULL)
{
MATELEM(s,v,1)=p_Copy(p/*theMap->m[v-1]*/,dst_r);
}
else
{
while((j<=pExp)&&(MATELEM(s,v,j)!=NULL))
{
j++;
}
p0=MATELEM(s,v,j-1);
}
// multiply
for(;j<=pExp;j++)
{
p0=MATELEM(s,v,j)=pp_Mult_qq(p0, p,dst_r);
p_Normalize(p0, dst_r);
}
res=p_Copy(p0/*MATELEM(s,v,pExp)*/,dst_r);
}
else //if ((p->next!=NULL)&&(p->next->next==NULL))
{
res=p_Power(p_Copy(p,dst_r),pExp,dst_r);
}
return res;
}
res
CanonicalForm res
Definition facAbsFact.cc:60
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
j
int j
Definition facHensel.cc:110
MAX_MAP_DEG
#define MAX_MAP_DEG
Definition maps.cc:29
MATELEM
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
p_Power
poly p_Power(poly p, int i, const ring r)
Definition p_polys.cc:2245
p_Normalize
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3939
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167

## maFetchPermLP()

void maFetchPermLP | ( | const ring | preimage_r,
|  | const ring | dst_r,
|  | int * | perm )

Definition at line 298 of file maps.cc.

{
for (int i = 0; i < preimage_r->N + 1; i++) { perm[i] = 0; }
int preimage_lV = preimage_r->isLPring;
int r_lV = dst_r->isLPring;
int preimage_ncgens = preimage_r->LPncGenCount;
int r_ncges = dst_r->LPncGenCount;
int preimage_vars = preimage_lV - preimage_ncgens;
int r_vars = r_lV - r_ncges;
// for each block
for (int i = 0; i < si_min(preimage_r->N / preimage_lV, dst_r->N / r_lV); i++)
{
// align variables
for (int j = 1; j <= si_min(preimage_vars, r_vars); j++)
{
perm[(i * preimage_lV) + j] = (i * r_lV) + j;
}
// align ncgens
for (int j = 1; j <= si_min(preimage_ncgens, r_ncges); j++)
{
perm[(i * preimage_lV) + preimage_vars + j] = (i * r_lV) + r_vars + j;
}
}
}
si_min
static int si_min(const int a, const int b)
Definition auxiliary.h:126

## maFindPerm()

void maFindPerm | ( | char const *const *const | preim_names,
|  | int | preim_n,
|  | char const *const *const | preim_par,
|  | int | preim_p,
|  | char const *const *const | names,
|  | int | n,
|  | char const *const *const | par,
|  | int | nop,
|  | int * | perm,
|  | int * | par_perm,
|  | n_coeffType | ch )

Definition at line 155 of file maps.cc.

{
int i,j;
/* find corresponding vars */
for (i=0; i<preim_n; i++)
{
for(j=0; j<n; j++)
{
if (strcmp(preim_names[i],names[j])==0)
{
if (BVERBOSE(V_IMAP))
Print("// var %s: nr %d -> nr %d\n",preim_names[i],i+1,j+1);
/* var i+1 from preimage ring is var j+1 (index j+1) from image ring */
perm[i+1]=j+1;
break;
}
}
if ((perm[i+1]==0)&&(par!=NULL)
// do not consider par of Fq
&& (ch!=n_GF))
{
for(j=0; j<nop; j++)
{
if (strcmp(preim_names[i],par[j])==0)
{
if (BVERBOSE(V_IMAP))
Print("// var %s: nr %d -> par %d\n",preim_names[i],i+1,j+1);
/* var i+1 from preimage ring is par j+1 (index j) from image ring */
perm[i+1]=-(j+1);
}
}
}
}
if (par_perm!=NULL)
{
for (i=0; i<preim_p; i++)
{
for(j=0; j<n; j++)
{
if (strcmp(preim_par[i],names[j])==0)
{
if (BVERBOSE(V_IMAP))
Print("// par %s: par %d -> nr %d\n",preim_par[i],i+1,j+1);
/*par i+1 from preimage ring is var j+1 (index j+1) from image ring*/
par_perm[i]=j+1;
break;
}
}
if ((par!=NULL) && (par_perm[i]==0))
{
for(j=0; j<nop; j++)
{
if (strcmp(preim_par[i],par[j])==0)
{
if (BVERBOSE(V_IMAP))
Print("// par %s: nr %d -> par %d\n",preim_par[i],i+1,j+1);
/*par i+1 from preimage ring is par j+1 (index j) from image ring */
par_perm[i]=-(j+1);
}
}
}
}
}
}
n_GF
@ n_GF
\GF{p^n < 2^16}
Definition coeffs.h:32
Print
#define Print
Definition emacs.cc:80
BVERBOSE
#define BVERBOSE(a)
Definition options.h:35
V_IMAP
#define V_IMAP
Definition options.h:53

## maFindPermLP()

void maFindPermLP | ( | char const *const *const | preim_names,
|  | int | preim_n,
|  | char const *const *const | preim_par,
|  | int | preim_p,
|  | char const *const *const | names,
|  | int | n,
|  | char const *const *const | par,
|  | int | nop,
|  | int * | perm,
|  | int * | par_perm,
|  | n_coeffType | ch,
|  | int | lV )

Definition at line 223 of file maps.cc.

{
int i,j,b;
/* find corresponding vars */
for (b=0;b<preim_n/lV;b++)
{
for (i=b*lV; i<(b+1)*lV; i++)
{
int cnt=0;
for(j=0; j<n; j++)
{
if (strcmp(preim_names[i],names[j])==0)
{
if (cnt==b)
{
if (BVERBOSE(V_IMAP))
Print("// var %s: nr %d -> nr %d\n",preim_names[i],i+1,j+1);
/* var i+1 from preimage ring is var j+1 (index j+1) from image ring */
perm[i+1]=j+1;
break;
}
else cnt++;
}
}
if ((perm[i+1]==0)&&(par!=NULL)
// do not consider par of Fq
&& (ch!=n_GF))
{
for(j=0; j<nop; j++)
{
if (strcmp(preim_names[i],par[j])==0)
{
if (BVERBOSE(V_IMAP))
Print("// var %s: nr %d -> par %d\n",preim_names[i],i+1,j+1);
/* var i+1 from preimage ring is par j+1 (index j) from image ring */
perm[i+1]=-(j+1);
}
}
}
}
}
if (par_perm!=NULL)
{
for (i=0; i<preim_p; i++)
{
for(j=0; j<n; j++)
{
if (strcmp(preim_par[i],names[j])==0)
{
if (BVERBOSE(V_IMAP))
Print("// par %s: par %d -> nr %d\n",preim_par[i],i+1,j+1);
/*par i+1 from preimage ring is var j+1 (index j+1) from image ring*/
par_perm[i]=j+1;
break;
}
}
if ((par!=NULL) && (par_perm[i]==0))
{
for(j=0; j<nop; j++)
{
if (strcmp(preim_par[i],par[j])==0)
{
if (BVERBOSE(V_IMAP))
Print("// par %s: nr %d -> par %d\n",preim_par[i],i+1,j+1);
/*par i+1 from preimage ring is par j+1 (index j) from image ring */
par_perm[i]=-(j+1);
}
}
}
}
}
}

## maIMap()

poly maIMap | ( | ring | r,
|  | poly | p,
|  | const ring | dst_r )

Definition at line 333 of file maps.cc.

{
/* the simplest case:*/
if(r==dst_r) return p_Copy(p,dst_r);
nMapFunc nMap=n_SetMap(r->cf,dst_r->cf);
int *perm=(int *)omAlloc0((r->N+1)*sizeof(int));
//int *par_perm=(int *)omAlloc0(rPar(r)*sizeof(int));
maFindPerm(r->names, rVar(r), rParameter(r), rPar(r),
dst_r->names, rVar(dst_r),rParameter(dst_r), rPar(dst_r),
perm,NULL, dst_r->cf->type);
poly res=p_PermPoly(p,perm,r,dst_r, nMap /*,par_perm,rPar(r)*/);
omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int));
//omFreeSize((ADDRESS)par_perm,rPar(r)*sizeof(int));
return res;
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
n_SetMap
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:703
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
maFindPerm
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition maps.cc:155
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
p_PermPoly
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition p_polys.cc:4256
rPar
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:605
rParameter
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition ring.h:631
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598

## maMaxDeg_Ma()

int maMaxDeg_Ma | ( | ideal | a,
|  | ring | preimage_r )

Definition at line 352 of file maps.cc.

{
int i,j;
int N = preimage_r->N;
poly p;
int *m=(int *)omAlloc0(N*sizeof(int));
for (i=MATROWS(a)*MATCOLS(a)-1;i>=0;i--)
{
p=a->m[i];
//pTest(p); // cannot test p because it is from another ring
while(p!=NULL)
{
for(j=N-1;j>=0;j--)
{
m[j]=si_max(m[j],(int)p_GetExp( p,j+1,preimage_r));
if (m[j]>=MAX_MAP_DEG)
{
i=MAX_MAP_DEG;
goto max_deg_fertig_id;
}
}
pIter(p);
}
}
i=m[0];
for(j=N-1;j>0;j--)
{
i=si_max(i,m[j]);
}
max_deg_fertig_id:
omFreeSize((ADDRESS)m,N*sizeof(int));
return i;
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
N
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
MATROWS
#define MATROWS(i)
Definition matpol.h:26
MATCOLS
#define MATCOLS(i)
Definition matpol.h:27

## maMaxDeg_P()

int maMaxDeg_P | ( | poly | p,
|  | ring | preimage_r )

Definition at line 390 of file maps.cc.

{
int i,j;
int N = preimage_r->N;
int *m=(int *)omAlloc0(N*sizeof(int));
// pTest(p);
while(p!=NULL)
{
for(j=N-1;j>=0;j--)
{
m[j]=si_max(m[j],(int)p_GetExp(p,j+1,preimage_r));
if (m[j]>=MAX_MAP_DEG)
{
i=MAX_MAP_DEG;
goto max_deg_fertig_p;
}
}
pIter(p);
}
i=m[0];
for(j=N-1;j>0;j--)
{
i=si_max(i,m[j]);
}
max_deg_fertig_p:
omFreeSize((ADDRESS)m,N*sizeof(int));
return i;
}

## p_MinPolyNormalize()

poly p_MinPolyNormalize | ( | poly | p,
|  | const ring | r )

Definition at line 422 of file maps.cc.

{
const coeffs C = r->cf;
number one = n_Init(1, C);
spolyrec rp;
poly q = &rp;
while (p != NULL)
{
// this returns 0, if p == MinPoly
number product = n_Mult(p_GetCoeff(p, r), one, C);
if ((product == NULL)||(n_IsZero(product, C)))
{
p_LmDelete(&p, r);
}
else
{
p_SetCoeff(p, product, r);
pNext(q) = p;
q = p;
p = pNext(p);
}
}
pNext(q) = NULL;
n_Delete(&one, C);
return rp.next;
}
n_Mult
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:639
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
n_Init
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:541
spolyrec::next
poly next
Definition monomials.h:24
pNext
#define pNext(p)
Definition monomials.h:36
p_GetCoeff
#define p_GetCoeff(p, r)
Definition monomials.h:50
spolyrec
Definition monomials.h:23
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
p_LmDelete
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
p_SetCoeff
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414