My Project
Loading...
Searching...
No Matches
units.cc
Go to the documentation of this file.
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"
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
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
Definition: intvec.h:23
const CanonicalForm & w
Definition: facAbsFact.cc:51
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:3182
#define KSTD_NF_ECART
Definition: kstd1.h:19
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition: matpol.cc:57
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
#define nInvers(a)
Definition: numbers.h:33
#define NULL
Definition: omList.c:12
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:969
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
Compatibility layer for legacy polynomial operations (over currRing)
#define pAdd(p, q)
Definition: polys.h:203
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition: polys.h:67
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pSub(a, b)
Definition: polys.h:287
#define pMult(p, q)
Definition: polys.h:207
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
int id_MinDegW(ideal M, intvec *w, const ring r)
#define IDELEMS(i)
Definition: simpleideals.h:23
static int idElem(const ideal F)
number of non-zero polys in F
Definition: simpleideals.h:67
#define M
Definition: sirandom.c:25
ideal redNF(ideal N, ideal M, matrix U, int d, intvec *w)
Definition: units.cc:18