My Project  UNKNOWN_GIT_VERSION
digitech.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 
5 
6 
7 #include "kernel/mod2.h"
8 #include "polys/monomials/ring.h"
9 
10 #include "kernel/digitech.h"
11 #include "polys/kbuckets.h"
12 #include "kernel/ideals.h"
13 static ideal zero_ideal;
14 
15 void bit_reduce(poly & f,ring r)
16 {
17  poly p=f;
18  kBucket_pt erg_bucket= kBucketCreate(r);
19  kBucketInit(erg_bucket,NULL,0 /*pLength(P.p)*/);
20  while(p)
21  {
22  poly next=pNext(p);
23  pNext(p)=NULL;
24 
25  int i;
26  int max=rVar(r);
27  for(i=1;i<=max;i++)
28  {
29  unsigned long exp=p_GetExp(p,i,r);
30  if(exp!=0)
31  p_SetExp(p,i,1,r);
32 
33  }
34  p_Setm(p,r);
35  int pseudo_len=0;
36  kBucket_Add_q(erg_bucket,p,&pseudo_len);
37  p=next;
38  }
39 
40  int len=0;
41  poly erg;
42  kBucketClear(erg_bucket,&erg, &len);
43  kBucketDestroy(&erg_bucket);
44  f=erg;
45 }
46 
47 poly uni_subst_bits(poly outer_uni, poly inner_multi, ring r)
48 {
49  zero_ideal=idInit(0,1);
50  //assumes outer_uni is univariate and ordering global
51  int d_max=p_GetExp(outer_uni,1,r);
52  poly* potences=(poly*) omAlloc((d_max+1)*sizeof(poly));
53  potences[0]=p_ISet(1,r);
54  int i;
55  for(i=1;i<=d_max;i++)
56  {
57  potences[i]=pp_Mult_qq(potences[i-1],inner_multi,r);
58  bit_reduce(potences[i],r);
59  }
60 
61  poly p=outer_uni;
62  kBucket_pt erg_bucket= kBucketCreate(r);
63  kBucketInit(erg_bucket,NULL,0 /*pLength(P.p)*/);
64 
65 
66  while(p)
67  {
68  int d=p_GetExp(p,1,r);
69  assume(potences[d]!=NULL); //mustn't always hold, but for most input
70  int pseudo_len=0;
71  kBucket_Add_q(erg_bucket,p_Mult_nn(potences[d],p_GetCoeff(p,r),r),&pseudo_len);
72  potences[d]=NULL;
73  p=pNext(p);
74  }
75 
76  //free potences
77  for(i=0;i<=d_max;i++)
78  {
79  p_Delete(&potences[i],r);
80  }
81  omfree(potences);
82  int len=0;
83  poly erg;
84  kBucketClear(erg_bucket,&erg, &len);
85  kBucketDestroy(&erg_bucket);
86  return(erg);
87 }
p_GetCoeff
#define p_GetCoeff(p, r)
Definition: monomials.h:48
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:458
f
FILE * f
Definition: checklibs.c:9
bit_reduce
void bit_reduce(poly &f, ring r)
Definition: digitech.cc:15
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:477
next
ListNode * next
Definition: janet.h:31
digitech.h
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:581
i
int i
Definition: cfEzgcd.cc:125
kBucket_Add_q
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
Definition: kbuckets.cc:650
kBucketDestroy
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:212
kBucketInit
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition: kbuckets.cc:489
mod2.h
max
static int max(int a, int b)
Definition: fast_mult.cc:264
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1073
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:208
kBucketClear
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition: kbuckets.cc:517
uni_subst_bits
poly uni_subst_bits(poly outer_uni, poly inner_multi, ring r)
Definition: digitech.cc:47
exp
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
kbuckets.h
ring.h
p_Delete
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:36
assume
#define assume(x)
Definition: mod2.h:384
NULL
#define NULL
Definition: omList.c:9
ideals.h
kBucket
Definition: kbuckets.h:177
p_Setm
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:225
p
int p
Definition: cfModGcd.cc:4019
kBucketCreate
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition: kbuckets.cc:205
p_ISet
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1286
zero_ideal
static ideal zero_ideal
Definition: digitech.cc:13
pNext
#define pNext(p)
Definition: monomials.h:34
p_Mult_nn
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:900
omfree
#define omfree(addr)
Definition: omAllocDecl.h:235