source: git/kernel/kpolys.cc @ abe5c8

spielwiese
Last change on this file since abe5c8 was 762407, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
config.h is for sources files only FIX: config.h should only be used by source (not from inside kernel/mod2.h!) NOTE: each source file should better include mod2.h right after config.h, while headers should better not include mod2.h.
  • Property mode set to 100644
File size: 3.2 KB
Line 
1#include "config.h"
2#include "mod2.h"
3
4#include <omalloc/omalloc.h>
5#include <misc/auxiliary.h>
6
7#include "polys.h"
8
9
10/* Returns TRUE if
11     * LM(p) | LM(lcm)
12     * LC(p) | LC(lcm) only if ring
13     * Exists i, j:
14         * LE(p, i)  != LE(lcm, i)
15         * LE(p1, i) != LE(lcm, i)   ==> LCM(p1, p) != lcm
16         * LE(p, j)  != LE(lcm, j)
17         * LE(p2, j) != LE(lcm, j)   ==> LCM(p2, p) != lcm
18*/
19BOOLEAN pCompareChain (poly p,poly p1,poly p2,poly lcm, const ring R)
20{
21  int k, j;
22
23  if (lcm==NULL) return FALSE;
24
25  for (j=(R->N); j; j--)
26    if ( p_GetExp(p,j, R) >  p_GetExp(lcm,j, R)) return FALSE;
27  if ( pGetComp(p) !=  pGetComp(lcm)) return FALSE;
28  for (j=(R->N); j; j--)
29  {
30    if (p_GetExp(p1,j, R)!=p_GetExp(lcm,j, R))
31    {
32      if (p_GetExp(p,j, R)!=p_GetExp(lcm,j, R))
33      {
34        for (k=(R->N); k>j; k--)
35        {
36          if ((p_GetExp(p,k, R)!=p_GetExp(lcm,k, R))
37          && (p_GetExp(p2,k, R)!=p_GetExp(lcm,k, R)))
38            return TRUE;
39        }
40        for (k=j-1; k; k--)
41        {
42          if ((p_GetExp(p,k, R)!=p_GetExp(lcm,k, R))
43          && (p_GetExp(p2,k, R)!=p_GetExp(lcm,k, R)))
44            return TRUE;
45        }
46        return FALSE;
47      }
48    }
49    else if (p_GetExp(p2,j, R)!=p_GetExp(lcm,j, R))
50    {
51      if (p_GetExp(p,j, R)!=p_GetExp(lcm,j, R))
52      {
53        for (k=(R->N); k>j; k--)
54        {
55          if ((p_GetExp(p,k, R)!=p_GetExp(lcm,k, R))
56          && (p_GetExp(p1,k, R)!=p_GetExp(lcm,k, R)))
57            return TRUE;
58        }
59        for (k=j-1; k!=0 ; k--)
60        {
61          if ((p_GetExp(p,k, R)!=p_GetExp(lcm,k, R))
62          && (p_GetExp(p1,k, R)!=p_GetExp(lcm,k, R)))
63            return TRUE;
64        }
65        return FALSE;
66      }
67    }
68  }
69  return FALSE;
70}
71#ifdef HAVE_RATGRING
72BOOLEAN pCompareChainPart (poly p,poly p1,poly p2,poly lcm, const ring R)
73{
74  int k, j;
75
76  if (lcm==NULL) return FALSE;
77
78  for (j=R->real_var_end; j>=R->real_var_start; j--)
79    if ( p_GetExp(p,j, R) >  p_GetExp(lcm,j, R)) return FALSE;
80  if ( pGetComp(p) !=  pGetComp(lcm)) return FALSE;
81  for (j=R->real_var_end; j>=R->real_var_start; j--)
82  {
83    if (p_GetExp(p1,j, R)!=p_GetExp(lcm,j, R))
84    {
85      if (p_GetExp(p,j, R)!=p_GetExp(lcm,j, R))
86      {
87        for (k=(R->N); k>j; k--)
88        for (k=R->real_var_end; k>j; k--)
89        {
90          if ((p_GetExp(p,k, R)!=p_GetExp(lcm,k, R))
91          && (p_GetExp(p2,k, R)!=p_GetExp(lcm,k, R)))
92            return TRUE;
93        }
94        for (k=j-1; k>=R->real_var_start; k--)
95        {
96          if ((p_GetExp(p,k, R)!=p_GetExp(lcm,k, R))
97          && (p_GetExp(p2,k, R)!=p_GetExp(lcm,k, R)))
98            return TRUE;
99        }
100        return FALSE;
101      }
102    }
103    else if (p_GetExp(p2,j, R)!=p_GetExp(lcm,j, R))
104    {
105      if (p_GetExp(p,j, R)!=p_GetExp(lcm,j, R))
106      {
107        for (k=R->real_var_end; k>j; k--)
108        {
109          if ((p_GetExp(p,k, R)!=p_GetExp(lcm,k, R))
110          && (p_GetExp(p1,k, R)!=p_GetExp(lcm,k, R)))
111            return TRUE;
112        }
113        for (k=j-1; k>=R->real_var_start; k--)
114        {
115          if ((p_GetExp(p,k, R)!=p_GetExp(lcm,k, R))
116          && (p_GetExp(p1,k, R)!=p_GetExp(lcm,k, R)))
117            return TRUE;
118        }
119        return FALSE;
120      }
121    }
122  }
123  return FALSE;
124}
125#endif
126
Note: See TracBrowser for help on using the repository browser.