source: git/libpolys/polys/templates/p_Merge_q__T.cc @ a44bcf

spielwiese
Last change on this file since a44bcf was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *  File:    p_Merge_q__Template.cc
6 *  Purpose: template for p_Add_q
7 *  Author:  obachman (Olaf Bachmann)
8 *  Created: 8/00
9 *******************************************************************/
10
11/***************************************************************
12 *
13 * Returns:  p merged with q
14 * Destroys: p, q
15 *
16 ***************************************************************/
17LINKAGE poly p_Merge_q__T(poly p, poly q, const ring r)
18{
19  assume(p != NULL && q != NULL);
20  p_Test(p, r);
21  p_Test(q, r);
22#if PDEBUG > 0
23  int l = pLength(p) + pLength(q);
24#endif
25
26  spolyrec rp;
27  poly a = &rp;
28  DECLARE_LENGTH(const unsigned long length = r->CmpL_Size);
29  DECLARE_ORDSGN(const long* ordsgn = r->ordsgn);
30
31  Top:     // compare p and q w.r.t. monomial ordering
32  p_MemCmp__T(p->exp, q->exp, length, ordsgn, goto Equal, goto Greater , goto Smaller);
33
34  Equal:
35  // should never get here
36  dReportError("Equal monomials in p_Merge_q");
37  return NULL;
38
39  Greater:
40  a = pNext(a) = p;
41  pIter(p);
42  if (p==NULL) { pNext(a) = q; goto Finish;}
43  goto Top;
44
45  Smaller:
46  a = pNext(a) = q;
47  pIter(q);
48  if (q==NULL) { pNext(a) = p; goto Finish;}
49  goto Top;
50
51  Finish:
52
53  p_Test(pNext(&rp), r);
54#if PDEBUG > 0
55  pAssume1(l - pLength(pNext(&rp)) == 0);
56#endif
57  return pNext(&rp);
58}
59
Note: See TracBrowser for help on using the repository browser.