source: git/Singular/units.cc @ 634dab0

spielwiese
Last change on this file since 634dab0 was 50cbdc, checked in by Hans Schönemann <hannes@…>, 23 years ago
*hannes: merge-2-0-2 git-svn-id: file:///usr/local/Singular/svn/trunk@5619 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*****************************************
2*  Computer Algebra System SINGULAR      *
3*****************************************/
4/* $Id: units.cc,v 1.10 2001-08-27 14:47:44 Singular Exp $ */
5/*
6* ABSTRACT: procedures to compute with units
7*/
8
9#include "mod2.h"
10#include "tok.h"
11#include "febase.h"
12#include "ipid.h"
13#include "numbers.h"
14#include "polys.h"
15#include "ideals.h"
16#include "intvec.h"
17#include "matpol.h"
18#include "kstd1.h"
19#include "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=mpCopy(U);
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,currQuotient,M);
37  while(idElem(M1)>0&&(d==-1||idMinDeg(M1,w)<=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,currQuotient,M);
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.