source: git/kernel/p_Merge_q__T.cc @ 3a0e1a

spielwiese
Last change on this file since 3a0e1a was 35aab3, checked in by Hans Schönemann <hannes@…>, 20 years ago
This commit was generated by cvs2svn to compensate for changes in r6879, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@6880 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.5 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 *  Version: $Id: p_Merge_q__T.cc,v 1.1.1.1 2003-10-06 12:15:59 Singular Exp $
10 *******************************************************************/
11
12/***************************************************************
13 *
14 * Returns:  p merged with q
15 * Destroys: p, q
16 *
17 ***************************************************************/
18LINKAGE poly p_Merge_q(poly p, poly q, const ring r)
19{
20  assume(p != NULL && q != NULL);
21  p_Test(p, r);
22  p_Test(q, r);
23#if PDEBUG > 0
24  int l = pLength(p) + pLength(q);
25#endif
26
27  spolyrec rp;
28  poly a = &rp;
29  DECLARE_LENGTH(const unsigned long length = r->CmpL_Size);
30  DECLARE_ORDSGN(const long* ordsgn = r->ordsgn);
31
32  Top:     // compare p and q w.r.t. monomial ordering
33  p_MemCmp(p->exp, q->exp, length, ordsgn, goto Equal, goto Greater , goto Smaller);
34
35  Equal:
36  // should never get here
37  dReportError("Equal monomials in p_Merge_q");
38  return NULL;
39
40  Greater:
41  a = pNext(a) = p;
42  pIter(p);
43  if (p==NULL) { pNext(a) = q; goto Finish;}
44  goto Top;
45
46  Smaller:
47  a = pNext(a) = q;
48  pIter(q);
49  if (q==NULL) { pNext(a) = p; goto Finish;}
50  goto Top;
51
52  Finish:
53
54  p_Test(pNext(&rp), r);
55#if PDEBUG > 0
56  pAssume1(l - pLength(pNext(&rp)) == 0);
57#endif
58  return pNext(&rp);
59}
60
Note: See TracBrowser for help on using the repository browser.