Loading...
Searching...
No Matches
p_Merge_q__T.cc
Go to the documentation of this file.
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/***************************************************************
* File: p_Merge_q__Template.cc
* Purpose: template for p_Add_q
* Author: obachman (Olaf Bachmann)
* Created: 8/00
*******************************************************************/
/***************************************************************
*
* Returns: p merged with q
* Destroys: p, q
*
***************************************************************/
LINKAGE poly p_Merge_q__T(poly p, poly q, const ring r)
{
assume(p != NULL && q != NULL);
p_Test(p, r);
p_Test(q, r);
#if PDEBUG > 0
int l = pLength(p) + pLength(q);
#endif
spolyrec rp;
poly a = &rp;
DECLARE_LENGTH(const unsigned long length = r->CmpL_Size);
DECLARE_ORDSGN(const long* ordsgn = r->ordsgn);
Top: // compare p and q w.r.t. monomial ordering
p_MemCmp__T(p->exp, q->exp, length, ordsgn, goto Equal, goto Greater , goto Smaller);
Equal:
// should never get here
dReportError("Equal monomials in p_Merge_q");
return NULL;
Greater:
a = pNext(a) = p;
pIter(p);
if (p==NULL) { pNext(a) = q; goto Finish;}
goto Top;
Smaller:
a = pNext(a) = q;
pIter(q);
if (q==NULL) { pNext(a) = p; goto Finish;}
goto Top;
Finish:
p_Test(pNext(&rp), r);
#if PDEBUG > 0
pAssume1(l - pLength(pNext(&rp)) == 0);
#endif
return pNext(&rp);
}
l
int l
Definition cfEzgcd.cc:100
p
int p
Definition cfModGcd.cc:4086
Equal
static BOOLEAN Equal(number a, number b, const coeffs)
Definition flintcf_Q.cc:381
Greater
static bool Greater(mono_type m1, mono_type m2)
Definition interpolation.cc:285
length
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
assume
#define assume(x)
Definition mod2.h:389
LINKAGE
#define LINKAGE
Definition mod2.h:140
dReportError
int dReportError(const char *fmt,...)
Definition dError.cc:44
pIter
#define pIter(p)
Definition monomials.h:37
pNext
#define pNext(p)
Definition monomials.h:36
pAssume1
#define pAssume1(cond)
Definition monomials.h:171
spolyrec
Definition monomials.h:23
NULL
#define NULL
Definition omList.c:12
p_Merge_q__T
LINKAGE poly p_Merge_q__T(poly p, poly q, const ring r)
Definition p_Merge_q__T.cc:17
pLength
static int pLength(poly a)
Definition p_polys.h:190
p_Test
#define p_Test(p, r)
Definition p_polys.h:161