1 | /***************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | *****************************************/ |
---|
4 | /* $Id: gms.cc,v 1.4 2002-02-16 11:00:46 mschulze Exp $ */ |
---|
5 | /* |
---|
6 | * ABSTRACT: Gauss-Manin system normal form |
---|
7 | */ |
---|
8 | |
---|
9 | #include "mod2.h" |
---|
10 | |
---|
11 | #ifdef HAVE_GMS |
---|
12 | |
---|
13 | #include "febase.h" |
---|
14 | #include "tok.h" |
---|
15 | #include "ipid.h" |
---|
16 | #include "numbers.h" |
---|
17 | #include "polys.h" |
---|
18 | #include "ideals.h" |
---|
19 | #include "lists.h" |
---|
20 | #include "matpol.h" |
---|
21 | #include "gms.h" |
---|
22 | |
---|
23 | lists gmsNF(ideal p,ideal g,matrix B,int D,int K) |
---|
24 | { |
---|
25 | ideal r=idInit(IDELEMS(p),1); |
---|
26 | ideal q=idInit(IDELEMS(p),1); |
---|
27 | |
---|
28 | lists l=(lists)omAllocBin(slists_bin); |
---|
29 | l->Init(2); |
---|
30 | |
---|
31 | l->m[0].rtyp=IDEAL_CMD; |
---|
32 | l->m[0].data=r; |
---|
33 | l->m[1].rtyp=IDEAL_CMD; |
---|
34 | l->m[1].data=q; |
---|
35 | |
---|
36 | int i,j,k; |
---|
37 | poly d; |
---|
38 | for(k=0;k<IDELEMS(p);k++) |
---|
39 | { |
---|
40 | while(p->m[k]!=NULL&&pGetExp(p->m[k],1)<=K) |
---|
41 | { |
---|
42 | j=0; |
---|
43 | while(j<IDELEMS(g)&&!pLmDivisibleBy(g->m[j],p->m[k])) |
---|
44 | j++; |
---|
45 | |
---|
46 | if(j<IDELEMS(g)) |
---|
47 | { |
---|
48 | d=pDivideM(pHead(p->m[k]),pHead(g->m[j])); |
---|
49 | p->m[k]=pSub(p->m[k],pMult(pCopy(d),pCopy(g->m[j]))); |
---|
50 | pSetExp(d,1,pGetExp(d,1)+1); |
---|
51 | for(i=0;i<MATROWS(B);i++) |
---|
52 | p->m[k]=pAdd(p->m[k], |
---|
53 | pDiff(pMult(pCopy(d),pCopy(MATELEM(B,i+1,j+1))),i+2)); |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | r->m[k]=pAdd(r->m[k],pHead(p->m[k])); |
---|
58 | pDeleteLm(&p->m[k]); |
---|
59 | } |
---|
60 | |
---|
61 | while(p->m[k]!=NULL&&pWTotaldegree(p->m[k])>D&&pGetExp(p->m[k],1)<=K) |
---|
62 | { |
---|
63 | q->m[k]=pAdd(q->m[k],pHead(p->m[k])); |
---|
64 | pDeleteLm(&p->m[k]); |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | q->m[k]=pAdd(q->m[k],pCopy(p->m[k])); |
---|
69 | } |
---|
70 | |
---|
71 | return l; |
---|
72 | } |
---|
73 | |
---|
74 | BOOLEAN gmsNF(leftv res,leftv h) |
---|
75 | { |
---|
76 | if(currRingHdl) |
---|
77 | { |
---|
78 | if(h&&h->Typ()==IDEAL_CMD) |
---|
79 | { |
---|
80 | ideal p=(ideal)h->Data(); |
---|
81 | h=h->next; |
---|
82 | if(h&&h->Typ()==IDEAL_CMD) |
---|
83 | { |
---|
84 | ideal g=(ideal)h->Data(); |
---|
85 | h=h->next; |
---|
86 | if(h&&h->Typ()==MATRIX_CMD) |
---|
87 | { |
---|
88 | matrix B=(matrix)h->Data(); |
---|
89 | h=h->next; |
---|
90 | if(h&&h->Typ()==INT_CMD) |
---|
91 | { |
---|
92 | int D=(int)h->Data(); |
---|
93 | h=h->next; |
---|
94 | if(h&&h->Typ()==INT_CMD) |
---|
95 | { |
---|
96 | int K=(int)h->Data(); |
---|
97 | res->rtyp=LIST_CMD; |
---|
98 | res->data=(void*)gmsNF(idCopy(p),g,B,D,K); |
---|
99 | return FALSE; |
---|
100 | } |
---|
101 | } |
---|
102 | } |
---|
103 | } |
---|
104 | } |
---|
105 | WerrorS("<ideal>,<ideal>,<matrix>,<int>,<int> expected"); |
---|
106 | return TRUE; |
---|
107 | } |
---|
108 | WerrorS("no ring active"); |
---|
109 | return TRUE; |
---|
110 | } |
---|
111 | |
---|
112 | #endif /* HAVE_GMS */ |
---|
113 | |
---|