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: 418384
1
/*
2
* Normaliz
3
* Copyright (C) 2007-2014 Winfried Bruns, Bogdan Ichim, 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
#include "libQnormaliz/libQnormaliz.h"
25
#include "libQnormaliz/Qgeneral.h"
26
27
namespace libQnormaliz {
28
29
bool verbose = false;
30
31
// bool test_arithmetic_overflow = false;
32
// long overflow_test_modulus = 15401;
33
34
size_t GMP_mat=0;
35
size_t GMP_hyp=0;
36
size_t GMP_scal_prod=0;
37
size_t TotDet=0;
38
39
40
namespace {
41
std::ostream* verbose_ostream_ptr = &std::cout;
42
std::ostream* error_ostream_ptr = &std::cerr;
43
} // end anonymous namespace, only accessible in this file (and when it is included)
44
45
bool setVerboseDefault(bool v) {
46
//we want to return the old value
47
bool old = verbose;
48
verbose = v;
49
return old;
50
}
51
52
void setVerboseOutput(std::ostream& v_out) {
53
verbose_ostream_ptr = &v_out;
54
}
55
56
void setErrorOutput(std::ostream& e_out) {
57
error_ostream_ptr = &e_out;
58
}
59
60
std::ostream& verboseOutput() {
61
return *verbose_ostream_ptr;
62
}
63
64
std::ostream& errorOutput() {
65
return *error_ostream_ptr;
66
}
67
68
InputType to_type(const std::string& type_string) {
69
70
if ( type_string=="0" || type_string=="1" || type_string=="2" || type_string=="3"
71
|| type_string=="4" || type_string=="5" || type_string=="6"
72
|| type_string=="hyperplanes"
73
|| type_string=="10") {
74
throw BadInputException("Error: deprecated type \"" + type_string
75
+ "\", please use new type string!");
76
}
77
78
if (type_string=="0"||type_string=="integral_closure") {
79
return Type::integral_closure;
80
}
81
if (type_string=="polyhedron") {
82
return Type::polyhedron;
83
}
84
if (type_string=="1"||type_string=="normalization") {
85
return Type::normalization;
86
}
87
if (type_string=="2"||type_string=="polytope") {
88
return Type::polytope;
89
}
90
if (type_string=="3"||type_string=="rees_algebra") {
91
return Type::rees_algebra;
92
}
93
if (type_string=="4"||type_string=="hyperplanes" ||type_string=="inequalities") {
94
return Type::inequalities;
95
}
96
if (type_string=="strict_inequalities") {
97
return Type::strict_inequalities;
98
}
99
if (type_string=="strict_signs") {
100
return Type::strict_signs;
101
}
102
if (type_string=="inhom_inequalities") {
103
return Type::inhom_inequalities;
104
}
105
if (type_string=="dehomogenization") {
106
return Type::dehomogenization;
107
}
108
if (type_string=="5"||type_string=="equations") {
109
return Type::equations;
110
}
111
if (type_string=="inhom_equations") {
112
return Type::inhom_equations;
113
}
114
if (type_string=="6"||type_string=="congruences") {
115
return Type::congruences;
116
}
117
if (type_string=="inhom_congruences") {
118
return Type::inhom_congruences;
119
}
120
if (type_string=="signs") {
121
return Type::signs;
122
}
123
if (type_string=="10"||type_string=="lattice_ideal") {
124
return Type::lattice_ideal;
125
}
126
if (type_string=="grading") {
127
return Type::grading;
128
}
129
if (type_string=="excluded_faces") {
130
return Type::excluded_faces;
131
}
132
if (type_string=="lattice") {
133
return Type::lattice;
134
}
135
if (type_string=="saturation") {
136
return Type::saturation;
137
}
138
if (type_string=="cone") {
139
return Type::cone;
140
}
141
if (type_string=="offset") {
142
return Type::offset;
143
}
144
if (type_string=="vertices") {
145
return Type::vertices;
146
}
147
if (type_string=="support_hyperplanes") {
148
return Type::support_hyperplanes;
149
}
150
if (type_string=="cone_and_lattice") {
151
return Type::cone_and_lattice;
152
}
153
if (type_string=="subspace") {
154
return Type::subspace;
155
}
156
157
throw BadInputException("Unknown type \"" + type_string + "\"!");
158
return Type::integral_closure;
159
}
160
161
long type_nr_columns_correction(InputType t) {
162
if (t == Type::polytope || t == Type::rees_algebra)
163
return -1;
164
if (t == Type::congruences || t == Type::vertices || t == Type::polyhedron
165
|| t == Type::inhom_inequalities || t == Type::inhom_equations)
166
return 1;
167
if (t == Type::inhom_congruences)
168
return 2;
169
return 0;
170
}
171
172
/* returns true if the input of this type is a vector */
173
bool type_is_vector(InputType type){
174
if (type == Type::grading || type == Type::signs || type == Type::strict_signs
175
|| type == Type::dehomogenization || type == Type::offset) {
176
return true;
177
}
178
return false;
179
}
180
181
} /* end namespace libQnormaliz */
182
183