source: git/kernel/units.cc @ 20e3062

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