source: git/kernel/units.cc @ 599326

spielwiese
Last change on this file since 599326 was 599326, checked in by Kai Krüger <krueger@…>, 14 years ago
Anne, Kai, Frank: - changes to #include "..." statements to allow cleaner build structure - affected directories: omalloc, kernel, Singular - not yet done: IntergerProgramming git-svn-id: file:///usr/local/Singular/svn/trunk@13032 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[35aab3]1/*****************************************
2*  Computer Algebra System SINGULAR      *
3*****************************************/
[341696]4/* $Id$ */
[35aab3]5/*
6* ABSTRACT: procedures to compute with units
7*/
8
[599326]9#include <kernel/mod2.h>
10#include <kernel/structs.h>
11#include <kernel/febase.h>
12#include <kernel/numbers.h>
13#include <kernel/polys.h>
14#include <kernel/ideals.h>
15#include <kernel/intvec.h>
16#include <kernel/matpol.h>
17#include <kernel/kstd1.h>
18#include <kernel/units.h>
[35aab3]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=mpCopy(U);
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);
[18ff4c]35  ideal M1=kNF(N,currQuotient,M,0,KSTD_NF_ECART);
[35aab3]36  while(idElem(M1)>0&&(d==-1||idMinDegW(M1,w)<=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);
[18ff4c]48    M1=kNF(N,currQuotient,M,0,KSTD_NF_ECART);
[35aab3]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.