1 //   Copyright (c)  2008-2009  Anna Bigatti and Eduardo Saenz-de-Cabezon
2 
3 //   This file is part of the source of CoCoALib, the CoCoA Library.
4 
5 //   CoCoALib is free software: you can redistribute it and/or modify
6 //   it under the terms of the GNU General Public License as published by
7 //   the Free Software Foundation, either version 3 of the License, or
8 //   (at your option) any later version.
9 
10 //   CoCoALib is distributed in the hope that it will be useful,
11 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //   GNU General Public License for more details.
14 
15 //   You should have received a copy of the GNU General Public License
16 //   along with CoCoALib.  If not, see <http://www.gnu.org/licenses/>.
17 
18 #include "CoCoA/TmpMonomialFunctions.H"
19 
20 #include "CoCoA/PPMonoid.H"  // for MultidegreeMap
21 #include "CoCoA/TmpPPVector.H"
22 #include "CoCoA/BigInt.H"  // for position_t
23 
24 using std::vector;
25 
26 /**********************************************************/
27 
28 namespace CoCoA
29 {
30 
support(std::vector<long> & sup,const PPMonoidElem & monomial)31   void support(std::vector<long>& sup, const PPMonoidElem& monomial)
32   {
33     std::vector<long> expv;
34     exponents(expv,monomial);
35     sup.clear();
36     const long size=len(expv);
37     for (long i=0; i<size; ++i)
38       if (expv[i]!=0)
39         sup.push_back(i);
40   }
41 
IsIrreducible(const PPVector & ideal)42   bool IsIrreducible(const PPVector& ideal)
43   {
44     long numgens=len(ideal);
45     for (long cont=0; cont<numgens; ++cont)
46       if (!IsIndetPosPower(PP(ideal[cont])))
47         return false;
48     return true;
49   }
50 
IsPrime(const PPVector & ideal)51   bool IsPrime(const PPVector& ideal)
52   {
53     long numgens=len(ideal);
54     long var;
55     for (long cont=0; cont<numgens; ++cont)
56       if (!IsIndet(var, PP(ideal[cont])))
57         return false;
58     return true;
59   }
60 
IsPrimary(const PPVector & ideal)61   bool IsPrimary(const PPVector& ideal)
62   {
63     long numgens=len(ideal);
64     long var;
65     BigInt expo;
66     long N=NumIndets(PPM(ideal));
67     vector<bool> pures(N,false);
68     vector<bool> other(N,false);
69     for(long cont=0; cont<numgens; ++cont)
70     {
71       if (IsIndetPosPower(var, expo, PP(ideal[cont])))
72         pures[var] = true;
73       else //I copied part of "support"
74       {
75         std::vector<long> expv;
76         exponents(expv, PP(ideal[cont]));
77         for (long i=0; i<N; ++i)
78           if (expv[i]!=0)
79             other[i]=true;
80       }
81     }
82     for (long conta=0; conta<N; ++conta)
83       if (pures[conta]==false && other[conta]==true)
84         return false;
85     return true;
86   }
87 
88 
89   // done! 2011-07-04
90 //   void ColonIdeal(PPVector& PPs, const PPVector& PPs1, const PPVector& PPs2)
91 //   {
92 //     //is it relevant which one has more generators?
93 //     PushBack(PPs,one(PPM(PPs)));
94 //     for(long i=0; i<len(PPs2); ++i)
95 //     {
96 //       PPVector current(PPM(PPs),DMR(PPs));
97 //       for (long j=0; j<len(PPs1); ++j)
98 //         PushBack(current, colon(PP(PPs1[j]),PP(PPs2[i])));
99 //       interreduce(current); //is it better to just add and then interreduce at the end?
100 //       lcms(PPs, PPs, current);
101 //     }
102 //     interreduce(PPs);
103 //   }
104 
105 
106 
107 }  // end of namespace CoCoA
108 
109 // RCS header/log in the next few lines
110 // $Header: /Volumes/Home_1/cocoa/cvs-repository/CoCoALib-0.99/src/AlgebraicCore/TmpMonomialFunctions.C,v 1.12 2014/04/30 16:24:27 abbott Exp $
111 // $Log: TmpMonomialFunctions.C,v $
112 // Revision 1.12  2014/04/30 16:24:27  abbott
113 // Summary: Replaced X.size() by len(X)
114 // Author: JAA
115 //
116 // Revision 1.11  2012/02/01 13:31:39  abbott
117 // Removed several unnecessary includes.
118 //
119 // Revision 1.10  2011/12/23 14:57:11  bigatti
120 // -- changed and --> && , or --> ||
121 //
122 // Revision 1.9  2011/08/14 15:52:16  abbott
123 // Changed ZZ into BigInt (phase 1: just the library sources).
124 //
125 // Revision 1.8  2011/07/05 15:02:17  bigatti
126 // -- added AlexanderDual
127 // -- added ad-hoc functions for colon, elim on monomial ideals
128 //
129 // Revision 1.7  2011/03/22 15:30:07  bigatti
130 // -- added cvs log
131 //
132