Loading...
Searching...
No Matches
subst_maps.cc
Go to the documentation of this file.
#include "kernel/mod2.h"
#include "polys/monomials/p_polys.h"
#include "kernel/ideals.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/maps.h"
#include "kernel/maps/gen_maps.h"
static poly p_SubstMon(poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
{
assume(!rIsNCRing(image_r));
poly q=p_NSet(nMap(pGetCoeff(p),preimage_r->cf,image_r->cf),image_r);
int i;
poly h=NULL;
for(i=1;i<=preimage_r->N; i++)
{
int pExp=p_GetExp( p,i,preimage_r);
if (i!=var)
{
p_SetExp(q,i,pExp,image_r);
}
else if (pExp!=0)
{
h=maEvalVariable(image,var,pExp,(ideal)cache,image_r);
if (h==NULL)
{
p_LmDelete(q,image_r);
return NULL;
}
}
else
h=p_One(image_r);
}
if (LIKELY(q!=NULL))
{
p_Setm(q,image_r);
h=p_Mult_mm(h,q,image_r);
p_LmDelete(q,image_r);
}
else
{
p_Delete(&h,image_r);
}
return h;
}
poly p_SubstPoly (poly p, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap, matrix cache)
{
if (p==NULL) return NULL;
if (rIsNCRing(image_r))
{
if((image_r!=preimage_r)
||(preimage_r!=currRing))
{
WerrorS("not implemented");
return NULL;
}
return pSubst(pCopy(p),var,image);
}
matrix org_cache=cache;
if (cache==NULL) cache=mpNew(preimage_r->N,maMaxDeg_P(p, preimage_r));
poly result = NULL;
sBucket_pt bucket = sBucketCreate(image_r);
while (p != NULL)
{
poly q=p_SubstMon(p,var,image,preimage_r,image_r,nMap,cache);
pIter(p);
if (q!=NULL) sBucket_Add_p(bucket,q,pLength(q));
}
int l_dummy;
sBucketDestroyAdd(bucket, &result, &l_dummy);
/*if no cache was passed,it is a local cache: */
if (org_cache==NULL) id_Delete((ideal*)&cache,image_r);
return result;
}
ideal id_SubstPoly (ideal id, int var, poly image, const ring preimage_r, const ring image_r, const nMapFunc nMap)
{
matrix cache=mpNew(preimage_r->N,maMaxDeg_Ma(id, preimage_r));
int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
res->rank = id->rank;
for(k--;k>=0;k--)
{
res->m[k]=p_SubstPoly(id->m[k],var,image,preimage_r,image_r,nMap,cache);
}
id_Delete((ideal*)&cache,image_r);
return res;
}
LIKELY
#define LIKELY(X)
Definition auxiliary.h:404
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
p
int p
Definition cfModGcd.cc:4086
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
result
return result
Definition facAbsBiFact.cc:76
res
CanonicalForm res
Definition facAbsFact.cc:60
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
gen_maps.h
ideals.h
h
STATIC_VAR Poly * h
Definition janet.cc:971
maMaxDeg_P
int maMaxDeg_P(poly p, ring preimage_r)
Definition maps.cc:390
maEvalVariable
poly maEvalVariable(poly p, int v, int pExp, ideal s, const ring dst_r)
Definition maps.cc:48
maMaxDeg_Ma
int maMaxDeg_Ma(ideal a, ring preimage_r)
Definition maps.cc:352
maps.h
mpNew
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
matrix
ip_smatrix * matrix
Definition matpol.h:43
MATROWS
#define MATROWS(i)
Definition matpol.h:26
MATCOLS
#define MATCOLS(i)
Definition matpol.h:27
mod2.h
assume
#define assume(x)
Definition mod2.h:389
pIter
#define pIter(p)
Definition monomials.h:37
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
NULL
#define NULL
Definition omList.c:12
p_One
poly p_One(const ring r)
Definition p_polys.cc:1314
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_polys.h
pLength
static int pLength(poly a)
Definition p_polys.h:190
p_LmDelete
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
p_SetExp
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
p_Setm
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
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_Mult_mm
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1053
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
pSubst
#define pSubst(p, n, e)
Definition polys.h:366
pCopy
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
ring.h
rIsNCRing
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427
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
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123
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:78
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
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:46