source: git/kernel/GBEngine/units.cc @ 4f8fd1d

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