My Project
pCoeff.cc
Go to the documentation of this file.
1// emacs edit mode for this file is -*- C++ -*-
2/****************************************
3* Computer Algebra System SINGULAR *
4****************************************/
5/*
6* ABSTRACT: accces single (coeffs of) monoms
7*/
8
9#include "misc/auxiliary.h"
10
11#include "coeffs/coeffs.h"
12
13#include "coeffs/longrat.h" // snumber is necessary
14
16#include "polys/pCoeff.h"
17
18#include "simpleideals.h"
19
20/// find coeff of (polynomial) m in polynomial p
21/// find coeff of (vector) m in vector p
22number p_CoeffTerm(poly p, poly m, const ring r)
23{
24 if (m!=NULL)
25 {
26 while (p!=NULL)
27 {
28 if (p_LmCmp(p,m,r)==0)
29 {
30 return n_Copy(p_GetCoeff(p,r),r->cf);
31 }
32 pIter(p);
33 }
34 }
35 return n_Init(0,r->cf);
36}
37
38/// find vector of coeffs of (polynomial) m in vector v
39poly p_CoeffTermV(poly v, poly m, const ring r)
40{
41 poly res=NULL;
42 if (m!=NULL)
43 {
44 while (v!=NULL)
45 {
46 p_SetComp(m,p_GetComp(v,r),r);
47 if (p_LmCmp(v,m,r)==0)
48 {
49 p_SetComp(m,0,r);
50 poly p=p_Init(r);
52 p_SetComp(p,p_GetComp(v,r),r);
53 res=p_Add_q(res,p,r);
54 }
55 pIter(v);
56 }
57 }
58 return res;
59}
60
61/// find coeffs of (polynomial) m in all polynomials from I
62/// find coeffs of (vector) m in all vectors from I
63ideal id_CoeffTerm(ideal I, poly m, const ring r)
64{
65 ideal res=idInit(IDELEMS(I),I->rank);
66 for(int i=IDELEMS(I)-1;i>=0;i--)
67 {
68 number n=p_CoeffTerm(I->m[i],m,r);
69 res->m[i]=p_NSet(n,r);
70 }
71 return res;
72}
73
74/// find coeffs of (polynomial) m in all vectors from I
75ideal id_CoeffTermV(ideal M, poly m, const ring r)
76{
77 ideal res=idInit(IDELEMS(M),M->rank);
78 for(int i=IDELEMS(M)-1;i>=0;i--)
79 {
80 res->m[i]=p_CoeffTermV(M->m[i],m,r);
81 }
82 return res;
83}
All the auxiliary stuff.
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:538
CanonicalForm res
Definition: facAbsFact.cc:60
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
#define p_SetCoeff0(p, n, r)
Definition: monomials.h:60
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
#define p_GetCoeff(p, r)
Definition: monomials.h:50
#define NULL
Definition: omList.c:12
number p_CoeffTerm(poly p, poly m, const ring r)
find coeff of (polynomial) m in polynomial p find coeff of (vector) m in vector p
Definition: pCoeff.cc:22
ideal id_CoeffTermV(ideal M, poly m, const ring r)
find coeffs of (polynomial) m in all vectors from I
Definition: pCoeff.cc:75
ideal id_CoeffTerm(ideal I, poly m, const ring r)
find coeffs of (polynomial) m in all polynomials from I find coeffs of (vector) m in all vectors from...
Definition: pCoeff.cc:63
poly p_CoeffTermV(poly v, poly m, const ring r)
find vector of coeffs of (polynomial) m in vector v
Definition: pCoeff.cc:39
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1469
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:938
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:249
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1582
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1322
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define IDELEMS(i)
Definition: simpleideals.h:23
#define M
Definition: sirandom.c:25