Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

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

563550 views
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 <stdlib.h>
25
#include <vector>
26
#include <list>
27
#include <string>
28
#include <sstream>
29
#include <algorithm>
30
#include <csignal>
31
using namespace std;
32
33
#include "normaliz.h"
34
#include "libnormaliz/integer.h"
35
#include "libnormaliz/libnormaliz.h"
36
#include "libnormaliz/cone.h"
37
//#include "libnormaliz/libnormaliz.cpp"
38
using namespace libnormaliz;
39
#include "input.cpp"
40
#include "options.cpp"
41
#include "output.cpp"
42
43
44
#ifndef STRINGIFY
45
#define STRINGIFYx(Token) #Token
46
#define STRINGIFY(Token) STRINGIFYx(Token)
47
#endif
48
49
long CCCCCCC=0;
50
51
void printHeader() {
52
cout << " \\.....|"<<endl;
53
cout << " Normaliz " << string( STRINGIFY(NMZ_VERSION) " " ,11)
54
<< " \\....|"<<endl;
55
cout << " \\...|"<<endl;
56
cout << " (C) The Normaliz Team, University of Osnabrueck \\..|"<<endl;
57
cout << " August 2017 \\.|"<<endl;
58
cout << " \\|"<<endl;
59
bool with_optional_packages=false;
60
string optional_packages;
61
#ifdef NMZ_COCOA
62
with_optional_packages=true;
63
optional_packages+=" CoCoALib";
64
#endif
65
#ifdef NMZ_SCIP
66
with_optional_packages=true;
67
optional_packages+=" SCIP";
68
#endif
69
if(with_optional_packages){
70
cout << "------------------------------------------------------------" << endl;
71
cout << "with paackage(s)" << optional_packages << endl;
72
}
73
}
74
75
void printHelp(char* command) {
76
cout << "Usage: "<<command<<" [options] PROJECT"<<endl;
77
cout << " runs normaliz on PROJECT.in"<<endl;
78
cout << "Options:"<<endl;
79
cout << " -S\tcompute sublattice"<<endl;
80
cout << " -s\tcompute support hyperplanes"<<endl;
81
cout << " -t\tcompute triangulation"<<endl;
82
cout << " -v\tcompute volume"<<endl;
83
cout << " -n\tcompute Hilbert basis and volume (needs full triangulation)"<<endl;
84
cout << " -N\tcompute Hilbert basis (with partial triangulation)"<<endl;
85
cout << " -w\tcheck for integrally closed and compute witness if not"<<endl;
86
cout << " -q\tcompute Hilbert (quasi-)polynomial"<<endl;
87
cout << " -p\tcompute Hilbert (quasi-)polynomial and degree 1 elements"<<endl;
88
cout << " -h\tcompute Hilbert basis and Hilbert polynomial (default)"<<endl;
89
cout << " -1\tcompute degree 1 elements"<<endl;
90
cout << " -y\tcompute Stanley decomposition (output in file .dec)"<<endl;
91
cout << " -C\tcompute class group (default)"<<endl;
92
cout << " -T\tcompute triangulation (output in file .tri)"<<endl;
93
cout << " -D\tcompute cone decomposition (includes -T)"<<endl;
94
cout << " -H\tcompute integer hull"<<endl;
95
cout << " -M\tcompute module generators over original monoid"<<endl;
96
cout << " -E\tcompute weighted Ehrhart series"<<endl;
97
cout << " -L\tcompute virtual multiplicity of weighted Ehrhart series"<<endl;
98
cout << " -I\tcompute integral"<<endl;
99
cout << " -G\tcheck Gorenstein"<<endl;
100
101
cout << endl;
102
cout << " -d\tcomputation mode: dual"<<endl;
103
cout << " -P\tcomputation mode: primal"<<endl;
104
cout << " -j\tcomputation mode: project-and-lift"<<endl;
105
cout << " -J\tcomputation mode: project-and-lift with floating point arithmetic"<<endl;
106
cout << " -r\tcomputation mode: approximate"<<endl;
107
cout << " -b\tcomputation mode: bottom decomposition"<<endl;
108
cout << " -o\tcomputation mode: no bottom decomposition"<<endl;
109
cout << " -k\tcomputation mode: keep order"<<endl;
110
cout << " -Y\tcomputation mode: symmetrization"<<endl;
111
112
cout << endl;
113
cout << " --<PROP> compute the ConeProperty <PROP>"<<endl;
114
115
cout << endl;
116
cout << " -f, --files write the files .out .gen .inv .cst"<<endl;
117
cout << " -a, --all-files write all output files (except .dec .tri .typ)"<<endl;
118
cout << " --<SUFFIX> write the file .<SUFFIX> where <SUFFIX> can be one of"<<endl;
119
cout << " cst, egn, esp, ext, gen, ht1, inv, lat, mod, msp, typ"<<endl;
120
121
cout << endl;
122
cout << " -B, --BigInt directly use indefinite precision arithmetic"<<endl;
123
cout << " --LongLong only use long long arithmetic, no conversion possible"<<endl;
124
cout << " -i, --ignore ignore the compute options set in the input file"<<endl;
125
cout << " -x=<T> limit the number of threads to <T>"<<endl;
126
cout << " --OutputDir=<path> set a path for the output files (relative to current directory)"<< endl;
127
cout << " -?, --help print this help text and exit"<<endl;
128
cout << " -c, --verbose verbose (prints control data)"<<endl;
129
cout << " --version print version info and exit"<<endl;
130
cout << endl;
131
cout << "Please report bugs to <[email protected]> or directly to our issue tracker:" << endl;
132
cout << "https://github.com/Normaliz/Normaliz/issues" << endl;
133
}
134
135
void printCopying() {
136
cout<<"Copyright (C) 2007-2017 The Normaliz Team, University of Osnabrueck."<<endl
137
<<"This program comes with ABSOLUTELY NO WARRANTY; This is free software,"<<endl
138
<<"and you are welcome to redistribute it under certain conditions;"<<endl
139
<<"See COPYING for details."<<endl;
140
}
141
142
void printVersion() {
143
cout << "Normaliz " << string(STRINGIFY(NMZ_VERSION)) << endl;
144
printCopying();
145
}
146
147
148
int process_data(OptionsHandler& options, const string& command_line,const string& arg0);
149
150
//---------------------------------------------------------------------------
151
152
int main(int argc, char* argv[])
153
{
154
155
// signal handler for interrupt
156
signal(SIGINT, &interrupt_signal_handler);
157
158
// read command line options
159
160
OptionsHandler options;
161
162
string command_line;
163
for(int i=1; i< argc;++i)
164
command_line=command_line+string(argv[i])+" ";
165
166
bool print_help = options.handle_commandline(argc, argv);
167
168
if (print_help) {
169
//printHeader();
170
printHelp(argv[0]);
171
exit(0);
172
}
173
174
if (verbose) {
175
printHeader();
176
}
177
string arg0(argv[0]);
178
179
process_data(options, command_line,arg0);
180
181
if(nmz_interrupted)
182
exit(10);
183
184
exit(0);
185
}
186
187
//---------------------------------------------------------------------------
188
189
template<typename Integer>
190
void compute_and_output(OptionsHandler& options, const map <Type::InputType,
191
vector< vector<mpq_class> > >& input, const string& polynomial, long nr_coeff_quasipol){
192
193
Output<Integer> Out; //all the information relevant for output is collected in this object
194
195
options.applyOutputOptions(Out);
196
197
options.activateDefaultMode(); // only if no real cone property is given!
198
199
Out.set_lattice_ideal_input(input.count(Type::lattice_ideal)>0);
200
201
Cone<Integer> MyCone = Cone<Integer>(input);
202
/* if (options.isUseBigInteger()) {
203
MyCone.deactivateChangeOfPrecision();
204
} */
205
MyCone.setPolynomial(polynomial);
206
MyCone.setNrCoeffQuasiPol(nr_coeff_quasipol);
207
MyCone.set_project(options.getProjectName());
208
MyCone.set_output_dir(options.getOutputDir());
209
// MyCone.set_nmz_call(arg0);
210
try {
211
MyCone.compute(options.getToCompute());
212
} catch(const NotComputableException& e) {
213
std::cout << "Not all desired properties could be computed." << endl;
214
std::cout << e.what() << endl;
215
std::cout << "Writing only available data." << endl;
216
} catch(const InterruptException& e) {
217
std::cout << endl;
218
std::cout << "Computation was interrupted." << endl;
219
std::cout << "Writing only available data." << endl;
220
}
221
Out.setCone(MyCone);
222
223
signal(SIGINT, SIG_DFL);
224
225
Out.write_files();
226
227
if(MyCone.isComputed(ConeProperty::IntegerHull)){
228
Output<Integer> IntHullOut;
229
options.applyOutputOptions(IntHullOut);
230
IntHullOut.set_name(options.getProjectName()+".IntHull");
231
IntHullOut.setCone(MyCone.getIntegerHullCone());
232
IntHullOut.write_files();
233
}
234
235
#ifdef NMZ_COCOA
236
if(MyCone.isComputed(ConeProperty::Symmetrize)){
237
Output<Integer> SymmOut;
238
options.applyOutputOptions(SymmOut);
239
SymmOut.set_name(options.getProjectName()+".symm");
240
SymmOut.setCone(MyCone.getSymmetrizedCone());
241
SymmOut.write_files();
242
}
243
#endif
244
}
245
246
247
//---------------------------------------------------------------------------
248
249
int process_data(OptionsHandler& options, const string& command_line,const string& arg0) {
250
251
#ifndef NCATCH
252
try {
253
#endif
254
255
256
string name_in=options.getProjectName()+".in";
257
const char* file_in=name_in.c_str();
258
ifstream in;
259
in.open(file_in,ifstream::in);
260
if ( !in.is_open() ) {
261
cerr << "error: Failed to open file "<<name_in<<"."<<endl;
262
exit(1);
263
}
264
265
//read the file
266
string polynomial="";
267
long nr_coeff_quasipol=-1;
268
map <Type::InputType, vector< vector<mpq_class> > > input = readNormalizInput(in, options,polynomial,nr_coeff_quasipol);
269
in.close();
270
271
if (verbose) {
272
cout << "------------------------------------------------------------" << endl;
273
cout << "Command line: " << command_line << endl;
274
cout << "Compute: " << options.getToCompute() << endl;
275
}
276
277
if(options.isUseLongLong())
278
compute_and_output<long long>(options, input, polynomial,nr_coeff_quasipol);
279
else
280
compute_and_output<mpz_class>(options, input, polynomial,nr_coeff_quasipol);
281
282
#ifndef NCATCH
283
} catch(const BadInputException& e) {
284
cerr << e.what() << endl;
285
cerr << "BadInputException caught... exiting." << endl;
286
exit(1);
287
} catch(const FatalException& e) {
288
cerr << e.what() << endl;
289
cerr << "FatalException caught... exiting." << endl;
290
exit(2);
291
} catch(const NmzCoCoAException& e) {
292
cerr << e.what() << endl;
293
cerr << "NmzCoCoAException caught... exiting." << endl;
294
exit(3);
295
} catch(const NormalizException& e) {
296
cerr << e.what() << endl;
297
cerr << "NormalizException caught... exiting." << endl;
298
exit(4);
299
} catch(const std::exception& e) {
300
cerr << "std::exception caught... \""<< e.what()<<"\" ... exiting." << endl;
301
exit(5);
302
}
303
#endif
304
305
return 0;
306
}
307
308