source: git/kernel/GBEngine/units.cc @ 9e8bfa

spielwiese
Last change on this file since 9e8bfa was ac00e2f, checked in by Hans Schoenemann <hannes@…>, 10 years ago
removed currQuotient
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*****************************************
2*  Computer Algebra System SINGULAR      *
3*****************************************/
4/*
5* ABSTRACT: procedures to compute with units
6*/
7
8
9
10
11#include <kernel/mod2.h>
12#include <kernel/structs.h>
13#include <coeffs/numbers.h>
14#include <kernel/polys.h>
15#include <kernel/ideals.h>
16#include <misc/intvec.h>
17#include <polys/matpol.h>
18#include <kernel/GBEngine/kstd1.h>
19#include <kernel/GBEngine/units.h>
20
21ideal redNF(ideal N,ideal M,matrix U,int d,intvec *w)
22{
23  matrix U0=NULL;
24  if(U!=NULL)
25  {
26    U0=mp_Copy(U,currRing);
27    number u0;
28    for(int i=IDELEMS(M)-1;i>=0;i--)
29    {
30      u0=nInvers(pGetCoeff(MATELEM(U0,i+1,i+1)));
31      MATELEM(U0,i+1,i+1)=pMult_nn(MATELEM(U0,i+1,i+1),u0);
32      M->m[i]=pMult_nn(M->m[i],u0);
33    }
34  }
35  ideal M0=idInit(IDELEMS(M),M->rank);
36  ideal M1=kNF(N,currRing->qideal,M,0,KSTD_NF_ECART);
37  while(idElem(M1)>0&&(d==-1||id_MinDegW(M1,w,currRing)<=d))
38  {
39    for(int i=IDELEMS(M)-1;i>=0;i--)
40    {
41      M0->m[i]=pAdd(M0->m[i],pHead(pCopy(M1->m[i])));
42      if(U0!=NULL)
43        M->m[i]=pSub(M->m[i],pMult(pHead(pCopy(M1->m[i])),
44                                   pCopy(MATELEM(U0,i+1,i+1))));
45      else
46        M->m[i]=pSub(M->m[i],pHead(pCopy(M1->m[i])));
47    }
48    idDelete(&M1);
49    M1=kNF(N,currRing->qideal,M,0,KSTD_NF_ECART);
50  }
51  idDelete(&M1);
52  idDelete(&N);
53  idDelete(&M);
54  if(U0!=NULL)
55    idDelete((ideal*)&U0);
56  return M0;
57}
58
59poly redNF(ideal N,poly p,poly u,int d,intvec *w)
60{
61  ideal M=idInit(1,pGetComp(p));
62  M->m[0]=p;
63  ideal M0;
64  if(u==NULL)
65    M0=redNF(N,M,NULL,d,w);
66  else
67  {
68    matrix U=mpNew(1,1);
69    MATELEM(U,1,1)=u;
70    M0=redNF(N,M,U,d,w);
71    idDelete((ideal*)&U);
72  }
73  poly p0=M0->m[0];
74  M0->m[0]=NULL;
75  idDelete(&M0);
76  return p0;
77}
78
Note: See TracBrowser for help on using the repository browser.