CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418425
1
/*
2
* nmzIntegrate
3
* Copyright (C) 2012-2014 Winfried Bruns, Christof Soeger
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*
17
* As an exception, when this program is distributed through (i) the App Store
18
* by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or (iii) Google Play
19
* by Google Inc., then that store may impose any digital rights management,
20
* device limits and/or redistribution restrictions that are required by its
21
* terms of service.
22
*/
23
24
#ifndef NMZ_INTEGRATE_H
25
#define NMZ_INTEGRATE_H
26
27
#ifdef NMZ_COCOA
28
29
#include "CoCoA/library.H"
30
using namespace CoCoA;
31
32
#include <fstream>
33
#include <sstream>
34
#include<string>
35
#include <gmpxx.h>
36
37
#include <boost/dynamic_bitset.hpp>
38
39
#include "libnormaliz/libnormaliz.h"
40
#include "libnormaliz/HilbertSeries.h"
41
#include "libnormaliz/matrix.h"
42
43
#include "libnormaliz/my_omp.h"
44
45
using namespace std;
46
47
namespace libnormaliz {
48
49
typedef unsigned int key_type;
50
51
bool verbose_INT;
52
53
struct SIMPLINEXDATA_INT{ // local data of excluded faces
54
boost::dynamic_bitset<> GenInFace; // indicator for generators of simplex in face
55
long mult; // multiplicity of this face
56
size_t card; // the cardinality of the face
57
bool done; // indicates that this face has been done for a given offset
58
vector<long> denom;
59
vector<long> degrees;
60
vector<long> key;
61
};
62
63
class ourFactorization{
64
public:
65
66
vector<RingElem> myFactors;
67
vector<long> myMultiplicities;
68
RingElem myRemainingFactor;
69
70
ourFactorization(const vector<RingElem>& myFactors,
71
const vector<long>& myMultiplicities, const RingElem& myRemainingFactor);
72
ourFactorization(const factorization<RingElem>& FF);
73
74
};
75
// end class
76
77
class CyclRatFunct {
78
// class for rational functions whose denominator is a product
79
// of cyclotomic polynomials
80
// We work with denominators that are products of factors 1-t^i
81
// which is of course equivalent
82
// the numerator is a polynomial in its ring
83
// the denominator is an integer vector that at index i
84
// gives the multiplicity of 1-t^i in the denominator
85
// (the entry at index 0 is not used and must always be equal to 0)
86
public:
87
88
RingElem num;
89
vector<long> denom;
90
91
void extendDenom(const vector<long>& target);
92
void addCRF(const CyclRatFunct& r);
93
void multCRF(const CyclRatFunct& r);
94
void simplifyCRF();
95
void set2(const RingElem& f, const vector<long>& d);
96
void set2(const RingElem& f);
97
void showCRF();
98
void showCoprimeCRF();
99
CyclRatFunct(const RingElem& c);
100
CyclRatFunct(const RingElem& c,const vector<long>& d);
101
102
};
103
//class end *****************************************************************
104
105
// manipulation of denominators
106
vector<long> lcmDenom(const vector<long>& df, const vector<long>& dg);
107
vector<long> prodDenom(const vector<long>& df, const vector<long>& dg);
108
vector<long> degrees2denom(const vector<long>& d);
109
vector<long> denom2degrees(const vector<long>& d);
110
RingElem denom2poly(const SparsePolyRing& P, const vector<long>& d);
111
vector<long> makeDenom(long k,long n);
112
113
114
RingElem processInputPolynomial(const string& poly_as_string, const SparsePolyRing& R, const SparsePolyRing& RZZ,
115
vector<RingElem>& resPrimeFactors, vector<RingElem>& resPrimeFactorsNonhom, vector<long>& resMultiplicities,
116
RingElem& remainingFactor, bool& homogeneous,const bool& do_leadCoeff);
117
118
// conversion from CoCoA types to GMP
119
mpz_class mpz(const BigInt& B) {
120
return(mpz_class(mpzref(B)));
121
}
122
123
mpq_class mpq(const BigRat& B) {
124
return(mpq_class(mpqref(B)));
125
}
126
127
mpz_class ourFactorial(const long& n){
128
mpz_class fact=1;
129
for(long i=1;i<=n;++i)
130
fact*=i;
131
return(fact);
132
}
133
134
} //end namespace libnormaliz
135
136
#endif //NMZ_COCOA
137
138
#endif // NMZ_INTEGRATE_H
139
140
141