My Project
cfCharSetsUtil.cc
Go to the documentation of this file.
1/*****************************************************************************\
2 * Computer Algebra System SINGULAR
3\*****************************************************************************/
4/** @file cfCharSetsUtil.cc
5 *
6 * This file provides utility functions to compute characteristic sets
7 *
8 * @note some of the code is code from libfac or derived from code from libfac.
9 * Libfac is written by M. Messollen. See also COPYING for license information
10 * and README for general information on characteristic sets.
11 *
12 * @authors Martin Lee
13 *
14 **/
15/*****************************************************************************/
16
17#include "config.h"
18
19#include "canonicalform.h"
20#include "cf_algorithm.h"
21#include "cfCharSetsUtil.h"
22
23#define __ARRAY_INIT__ -1
24
25// the maximal degree of polys in PS wrt. variable x
26int
27degpsmax (const CFList & PS, const Variable & x,
28 Intarray & A, Intarray & C)
29{
30 int varlevel= level(x);
31 if (A[varlevel] != __ARRAY_INIT__)
32 return A[varlevel];
33 int max= 0, temp, count= 0;
34
35 for (CFListIterator i= PS; i.hasItem(); i++)
36 {
37 temp= degree (i.getItem(), x);
38 if (temp > max)
39 {
40 max= temp;
41 count = 0;
42 }
43 if (temp == max)
44 count += max; // we count the number of polys
45 }
46 A[varlevel]= max;
47 C[varlevel]= count;
48 return max;
49}
50
51// the minimal non-zero degree of polys in PS wrt. x
52// returns 0 if variable x doesn't occure in any of the polys
53int
54degpsmin (const CFList & PS, const Variable & x, Intarray & A, Intarray & B,
55 Intarray & C, Intarray & D)
56{
57 int varlevel= level(x);
58 if (B[varlevel] != __ARRAY_INIT__ )
59 return B[varlevel];
60 int min= degpsmax (PS, x, A, C), temp, count= 0;
61
62 if (min == 0)
63 {
64 B[varlevel]= min;
65 D[varlevel]= min;
66 return min;
67 }
68 else
69 {
70 for (CFListIterator i= PS; i.hasItem(); i++)
71 {
72 temp= degree (i.getItem(), x);
73 if (temp < min && temp != 0)
74 {
75 min= temp;
76 count= 0;
77 }
78 if (temp == min)
79 count += min; // we count the number of polys
80 }
81 }
82 B[varlevel]= min;
83 D[varlevel]= count;