My Project
UNKNOWN_GIT_VERSION
libpolys
polys
templates
Functions
p_Add_q__T.cc File Reference
Go to the source code of this file.
Functions
LINKAGE
poly
p_Add_q__T
(poly
p
, poly q, int &Shorter,
const
ring r)
Function Documentation
◆
p_Add_q__T()
LINKAGE
poly p_Add_q__T
(
poly
p
,
poly
q
,
int &
Shorter
,
const
ring
r
)
Definition at line
18
of file
p_Add_q__T.cc
.
19
{
20
p_Test
(
p
, r);
21
p_Test
(q, r);
22
#if PDEBUG > 0
23
int
l
=
pLength
(
p
) +
pLength
(q);
24
#endif
25
assume
(
p
!=
NULL
&& q!=
NULL
);
26
27
Shorter = 0;
28
29
number t, n1, n2;
30
int
shorter = 0;
31
spolyrec
rp;
32
poly a = &rp;
33
DECLARE_LENGTH(
const
unsigned
long
length
= r->CmpL_Size);
34
DECLARE_ORDSGN(
const
long
* ordsgn = r->ordsgn);
35
36
Top:
// compare p and q w.r.t. monomial ordering
37
p_MemCmp__T(
p
->exp, q->exp,
length
, ordsgn,
goto
Equal
,
goto
Greater
,
goto
Smaller);
38
39
Equal
:
40
n1 =
pGetCoeff
(
p
);
41
n2 =
pGetCoeff
(q);
42
n_InpAdd__T(n1,n2,r->cf);
43
t = n1;
44
n_Delete__T
(&n2, r->cf);
45
q =
p_LmFreeAndNext
(q, r);
46
47
if
(n_IsZero__T(t, r->cf))
48
{
49
shorter += 2;
50
n_Delete__T
(&t, r->cf);
51
p
=
p_LmFreeAndNext
(
p
, r);
52
}
53
else
54
{
55
shorter++;
56
pSetCoeff0
(
p
,t);
57
a =
pNext
(a) =
p
;
58
pIter
(
p
);
59
}
60
if
(
p
==
NULL
) {
pNext
(a) = q;
goto
Finish;}
61
if
(q==
NULL
) {
pNext
(a) =
p
;
goto
Finish;}
62
goto
Top;
63
64
Greater
:
65
a =
pNext
(a) =
p
;
66
pIter
(
p
);
67
if
(
p
==
NULL
) {
pNext
(a) = q;
goto
Finish;}
68
goto
Top;
69
70
Smaller:
71
a =
pNext
(a) = q;
72
pIter
(q);
73
if
(q==
NULL
) {
pNext
(a) =
p
;
goto
Finish;}
74
goto
Top;
75
76
77
Finish:
78
Shorter = shorter;
79
80
p_Test
(
pNext
(&rp), r);
81
#if PDEBUG > 0
82
pAssume1
(
l
-
pLength
(
pNext
(&rp)) == Shorter);
83
#endif
84
return
pNext
(&rp);
85
}
p_LmFreeAndNext
static poly p_LmFreeAndNext(poly p, ring)
Definition:
p_polys.h:704
Equal
static BOOLEAN Equal(number a, number b, const coeffs r)
Definition:
flintcf_Q.cc:323
length
static BOOLEAN length(leftv result, leftv arg)
Definition:
interval.cc:263
p_Test
#define p_Test(p, r)
Definition:
p_polys.h:164
pLength
static unsigned pLength(poly a)
Definition:
p_polys.h:193
Greater
static bool Greater(mono_type m1, mono_type m2)
Definition:
interpolation.cc:285
pIter
#define pIter(p)
Definition:
monomials.h:38
spolyrec
Definition:
monomials.h:24
n_Delete__T
#define n_Delete__T(n, r)
Definition:
p_polys.cc:4796
pAssume1
#define pAssume1(cond)
Definition:
monomials.h:172
pSetCoeff0
#define pSetCoeff0(p, n)
Definition:
monomials.h:60
assume
#define assume(x)
Definition:
mod2.h:390
NULL
#define NULL
Definition:
omList.c:10
l
int l
Definition:
cfEzgcd.cc:93
p
int p
Definition:
cfModGcd.cc:4019
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition:
monomials.h:45
pNext
#define pNext(p)
Definition:
monomials.h:37
Generated on Thu Dec 17 2020 00:00:00 for My Project by
doxygen 1.8.20
for
Singular UNKNOWN_GIT_VERSION