source: git/Singular/gms.cc @ 35aab3

spielwiese
Last change on this file since 35aab3 was 15d67db, checked in by Mathias Schulze <mschulze@…>, 22 years ago
*** empty log message *** git-svn-id: file:///usr/local/Singular/svn/trunk@5903 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*****************************************
2*  Computer Algebra System SINGULAR      *
3*****************************************/
4/* $Id: gms.cc,v 1.7 2002-02-20 17:32:12 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
24lists gmsNF(ideal p,ideal g,matrix B,int D,int K)
25{
26  ideal r=idInit(IDELEMS(p),1);
27  ideal q=idInit(IDELEMS(p),1);
28
29  matrix B0=mpNew(MATROWS(B),MATCOLS(B));
30  for(int i=1;i<=MATROWS(B0);i++)
31    for(int j=1;j<=MATCOLS(B0);j++)
32      if(MATELEM(B,i,j)!=NULL)
33        MATELEM(B0,i,j)=pDiff(MATELEM(B,i,j),i+1);
34
35  for(int k=0;k<IDELEMS(p);k++)
36  {
37    while(p->m[k]!=NULL&&pGetExp(p->m[k],1)<=K)
38    {
39      int j=0;
40      while(j<IDELEMS(g)&&!pLmDivisibleBy(g->m[j],p->m[k]))
41        j++;
42
43      if(j<IDELEMS(g))
44      {
45        poly m=pDivideM(pHead(p->m[k]),pHead(g->m[j]));
46        p->m[k]=pSub(p->m[k],ppMult_mm(g->m[j],m));
47        pIncrExp(m,1);
48        pSetm(m);
49        for(int i=0;i<MATROWS(B);i++)
50        {
51          poly m0=pDiff(m,i+2);
52          if(MATELEM(B0,i+1,j+1)!=NULL)
53            p->m[k]=pAdd(p->m[k],ppMult_mm(MATELEM(B0,i+1,j+1),m));
54          if(MATELEM(B,i+1,j+1)!=NULL&&m0!=NULL)
55            p->m[k]=pAdd(p->m[k],ppMult_mm(MATELEM(B,i+1,j+1),m0));
56          pDelete(&m0);
57        }
58        pDelete(&m);
59      }
60      else
61      {
62        poly p0=p->m[k];
63        pIter(p->m[k]);
64        pNext(p0)=NULL;
65        r->m[k]=pAdd(r->m[k],p0);
66      }
67
68      while(p->m[k]!=NULL&&pGetExp(p->m[k],1)<=K&&pWTotaldegree(p->m[k])>D)
69      {
70        int i=pGetExp(p->m[k],1);
71        do
72        {
73          poly p0=p->m[k];
74          pIter(p->m[k]);
75          pNext(p0)=NULL;
76          q->m[k]=pAdd(q->m[k],p0);
77        }while(p->m[k]!=NULL&&pGetExp(p->m[k],1)==i);
78      }
79
80      pNormalize(p->m[k]);
81    }
82
83    q->m[k]=pAdd(q->m[k],p->m[k]);
84    p->m[k]=NULL;
85  }
86  idDelete(&p);
87  idDelete((ideal *)&B0);
88
89  idNormalize(r);
90  idNormalize(q);
91
92  lists l=(lists)omAllocBin(slists_bin);
93  l->Init(2);
94
95  l->m[0].rtyp=IDEAL_CMD;
96  l->m[0].data=r;
97  l->m[1].rtyp=IDEAL_CMD;
98  l->m[1].data=q;
99
100  return l;
101}
102
103
104BOOLEAN gmsNF(leftv res,leftv h)
105{
106  if(currRingHdl)
107  {
108    if(h&&h->Typ()==IDEAL_CMD)
109    {
110      ideal p=(ideal)h->Data();
111      h=h->next;
112      if(h&&h->Typ()==IDEAL_CMD)
113      {
114        ideal g=(ideal)h->Data();
115        h=h->next;
116        if(h&&h->Typ()==MATRIX_CMD)
117        {
118          matrix B=(matrix)h->Data();
119          h=h->next;
120          if(h&&h->Typ()==INT_CMD)
121          {
122            int D=(int)h->Data();
123            h=h->next;
124            if(h&&h->Typ()==INT_CMD)
125            {
126              int K=(int)h->Data();
127              res->rtyp=LIST_CMD;
128              res->data=(void *)gmsNF(idCopy(p),g,B,D,K);
129              return FALSE;
130            }
131          }
132        }
133      }
134    }
135    WerrorS("<ideal>,<ideal>,<matrix>,<int>,<int> expected");
136    return TRUE;
137  }
138  WerrorS("no ring active");
139  return TRUE;
140}
141
142#endif /* HAVE_GMS */
143
Note: See TracBrowser for help on using the repository browser.