source: git/kernel/units.cc @ b5d6f0

spielwiese
Last change on this file since b5d6f0 was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • 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 "config.h"
9#include <kernel/mod2.h>
10#include <kernel/structs.h>
11#include <kernel/febase.h>
12#include <coeffs/numbers.h>
13#include <kernel/polys.h>
14#include <kernel/ideals.h>
15#include <misc/intvec.h>
16#include <polys/matpol.h>
17#include <kernel/kstd1.h>
18#include <kernel/units.h>
19
20ideal redNF(ideal N,ideal M,matrix U,int d,intvec *w)
21{
22  matrix U0=NULL;
23  if(U!=NULL)
24  {
25    U0=mp_Copy(U,currRing);
26    number u0;
27    for(int i=IDELEMS(M)-1;i>=0;i--)
28    {
29      u0=nInvers(pGetCoeff(MATELEM(U0,i+1,i+1)));
30      MATELEM(U0,i+1,i+1)=pMult_nn(MATELEM(U0,i+1,i+1),u0);
31      M->m[i]=pMult_nn(M->m[i],u0);
32    }
33  }
34  ideal M0=idInit(IDELEMS(M),M->rank);
35  ideal M1=kNF(N,currQuotient,M,0,KSTD_NF_ECART);
36  while(idElem(M1)>0&&(d==-1||id_MinDegW(M1,w,currRing)<=d))
37  {
38    for(int i=IDELEMS(M)-1;i>=0;i--)
39    {
40      M0->m[i]=pAdd(M0->m[i],pHead(pCopy(M1->m[i])));
41      if(U0!=NULL)
42        M->m[i]=pSub(M->m[i],pMult(pHead(pCopy(M1->m[i])),
43                                   pCopy(MATELEM(U0,i+1,i+1))));
44      else
45        M->m[i]=pSub(M->m[i],pHead(pCopy(M1->m[i])));
46    }
47    idDelete(&M1);
48    M1=kNF(N,currQuotient,M,0,KSTD_NF_ECART);
49  }
50  idDelete(&M1);
51  idDelete(&N);
52  idDelete(&M);
53  if(U0!=NULL)
54    idDelete((ideal*)&U0);
55  return M0;
56}
57
58poly redNF(ideal N,poly p,poly u,int d,intvec *w)
59{
60  ideal M=idInit(1,pGetComp(p));
61  M->m[0]=p;
62  ideal M0;
63  if(u==NULL)
64    M0=redNF(N,M,NULL,d,w);
65  else
66  {
67    matrix U=mpNew(1,1);
68    MATELEM(U,1,1)=u;
69    M0=redNF(N,M,U,d,w);
70    idDelete((ideal*)&U);
71  }
72  poly p0=M0->m[0];
73  M0->m[0]=NULL;
74  idDelete(&M0);
75  return p0;
76}
77
Note: See TracBrowser for help on using the repository browser.