GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/*1* Normaliz2* Copyright (C) 2007-2014 Winfried Bruns, Bogdan Ichim, Christof Soeger3* This program is free software: you can redistribute it and/or modify4* it under the terms of the GNU General Public License as published by5* the Free Software Foundation, either version 3 of the License, or6* (at your option) any later version.7*8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License14* along with this program. If not, see <http://www.gnu.org/licenses/>.15*16* As an exception, when this program is distributed through (i) the App Store17* by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or (iii) Google Play18* by Google Inc., then that store may impose any digital rights management,19* device limits and/or redistribution restrictions that are required by its20* terms of service.21*/2223#include <stdlib.h>24#include <vector>25#include <list>26#include <string>27#include <sstream>28#include <algorithm>29#include <csignal>30using namespace std;3132#include "normaliz.h"33#include "libnormaliz/integer.h"34#include "libnormaliz/libnormaliz.h"35#include "libnormaliz/cone.h"36//#include "libnormaliz/libnormaliz.cpp"37using namespace libnormaliz;38#include "input.cpp"39#include "options.cpp"40#include "output.cpp"414243#ifndef STRINGIFY44#define STRINGIFYx(Token) #Token45#define STRINGIFY(Token) STRINGIFYx(Token)46#endif4748long CCCCCCC=0;4950void printHeader() {51cout << " \\.....|"<<endl;52cout << " Normaliz " << string( STRINGIFY(NMZ_VERSION) " " ,11)53<< " \\....|"<<endl;54cout << " \\...|"<<endl;55cout << " (C) The Normaliz Team, University of Osnabrueck \\..|"<<endl;56cout << " August 2017 \\.|"<<endl;57cout << " \\|"<<endl;58bool with_optional_packages=false;59string optional_packages;60#ifdef NMZ_COCOA61with_optional_packages=true;62optional_packages+=" CoCoALib";63#endif64#ifdef NMZ_SCIP65with_optional_packages=true;66optional_packages+=" SCIP";67#endif68if(with_optional_packages){69cout << "------------------------------------------------------------" << endl;70cout << "with paackage(s)" << optional_packages << endl;71}72}7374void printHelp(char* command) {75cout << "Usage: "<<command<<" [options] PROJECT"<<endl;76cout << " runs normaliz on PROJECT.in"<<endl;77cout << "Options:"<<endl;78cout << " -S\tcompute sublattice"<<endl;79cout << " -s\tcompute support hyperplanes"<<endl;80cout << " -t\tcompute triangulation"<<endl;81cout << " -v\tcompute volume"<<endl;82cout << " -n\tcompute Hilbert basis and volume (needs full triangulation)"<<endl;83cout << " -N\tcompute Hilbert basis (with partial triangulation)"<<endl;84cout << " -w\tcheck for integrally closed and compute witness if not"<<endl;85cout << " -q\tcompute Hilbert (quasi-)polynomial"<<endl;86cout << " -p\tcompute Hilbert (quasi-)polynomial and degree 1 elements"<<endl;87cout << " -h\tcompute Hilbert basis and Hilbert polynomial (default)"<<endl;88cout << " -1\tcompute degree 1 elements"<<endl;89cout << " -y\tcompute Stanley decomposition (output in file .dec)"<<endl;90cout << " -C\tcompute class group (default)"<<endl;91cout << " -T\tcompute triangulation (output in file .tri)"<<endl;92cout << " -D\tcompute cone decomposition (includes -T)"<<endl;93cout << " -H\tcompute integer hull"<<endl;94cout << " -M\tcompute module generators over original monoid"<<endl;95cout << " -E\tcompute weighted Ehrhart series"<<endl;96cout << " -L\tcompute virtual multiplicity of weighted Ehrhart series"<<endl;97cout << " -I\tcompute integral"<<endl;98cout << " -G\tcheck Gorenstein"<<endl;99100cout << endl;101cout << " -d\tcomputation mode: dual"<<endl;102cout << " -P\tcomputation mode: primal"<<endl;103cout << " -j\tcomputation mode: project-and-lift"<<endl;104cout << " -J\tcomputation mode: project-and-lift with floating point arithmetic"<<endl;105cout << " -r\tcomputation mode: approximate"<<endl;106cout << " -b\tcomputation mode: bottom decomposition"<<endl;107cout << " -o\tcomputation mode: no bottom decomposition"<<endl;108cout << " -k\tcomputation mode: keep order"<<endl;109cout << " -Y\tcomputation mode: symmetrization"<<endl;110111cout << endl;112cout << " --<PROP> compute the ConeProperty <PROP>"<<endl;113114cout << endl;115cout << " -f, --files write the files .out .gen .inv .cst"<<endl;116cout << " -a, --all-files write all output files (except .dec .tri .typ)"<<endl;117cout << " --<SUFFIX> write the file .<SUFFIX> where <SUFFIX> can be one of"<<endl;118cout << " cst, egn, esp, ext, gen, ht1, inv, lat, mod, msp, typ"<<endl;119120cout << endl;121cout << " -B, --BigInt directly use indefinite precision arithmetic"<<endl;122cout << " --LongLong only use long long arithmetic, no conversion possible"<<endl;123cout << " -i, --ignore ignore the compute options set in the input file"<<endl;124cout << " -x=<T> limit the number of threads to <T>"<<endl;125cout << " --OutputDir=<path> set a path for the output files (relative to current directory)"<< endl;126cout << " -?, --help print this help text and exit"<<endl;127cout << " -c, --verbose verbose (prints control data)"<<endl;128cout << " --version print version info and exit"<<endl;129cout << endl;130cout << "Please report bugs to <[email protected]> or directly to our issue tracker:" << endl;131cout << "https://github.com/Normaliz/Normaliz/issues" << endl;132}133134void printCopying() {135cout<<"Copyright (C) 2007-2017 The Normaliz Team, University of Osnabrueck."<<endl136<<"This program comes with ABSOLUTELY NO WARRANTY; This is free software,"<<endl137<<"and you are welcome to redistribute it under certain conditions;"<<endl138<<"See COPYING for details."<<endl;139}140141void printVersion() {142cout << "Normaliz " << string(STRINGIFY(NMZ_VERSION)) << endl;143printCopying();144}145146147int process_data(OptionsHandler& options, const string& command_line,const string& arg0);148149//---------------------------------------------------------------------------150151int main(int argc, char* argv[])152{153154// signal handler for interrupt155signal(SIGINT, &interrupt_signal_handler);156157// read command line options158159OptionsHandler options;160161string command_line;162for(int i=1; i< argc;++i)163command_line=command_line+string(argv[i])+" ";164165bool print_help = options.handle_commandline(argc, argv);166167if (print_help) {168//printHeader();169printHelp(argv[0]);170exit(0);171}172173if (verbose) {174printHeader();175}176string arg0(argv[0]);177178process_data(options, command_line,arg0);179180if(nmz_interrupted)181exit(10);182183exit(0);184}185186//---------------------------------------------------------------------------187188template<typename Integer>189void compute_and_output(OptionsHandler& options, const map <Type::InputType,190vector< vector<mpq_class> > >& input, const string& polynomial, long nr_coeff_quasipol){191192Output<Integer> Out; //all the information relevant for output is collected in this object193194options.applyOutputOptions(Out);195196options.activateDefaultMode(); // only if no real cone property is given!197198Out.set_lattice_ideal_input(input.count(Type::lattice_ideal)>0);199200Cone<Integer> MyCone = Cone<Integer>(input);201/* if (options.isUseBigInteger()) {202MyCone.deactivateChangeOfPrecision();203} */204MyCone.setPolynomial(polynomial);205MyCone.setNrCoeffQuasiPol(nr_coeff_quasipol);206MyCone.set_project(options.getProjectName());207MyCone.set_output_dir(options.getOutputDir());208// MyCone.set_nmz_call(arg0);209try {210MyCone.compute(options.getToCompute());211} catch(const NotComputableException& e) {212std::cout << "Not all desired properties could be computed." << endl;213std::cout << e.what() << endl;214std::cout << "Writing only available data." << endl;215} catch(const InterruptException& e) {216std::cout << endl;217std::cout << "Computation was interrupted." << endl;218std::cout << "Writing only available data." << endl;219}220Out.setCone(MyCone);221222signal(SIGINT, SIG_DFL);223224Out.write_files();225226if(MyCone.isComputed(ConeProperty::IntegerHull)){227Output<Integer> IntHullOut;228options.applyOutputOptions(IntHullOut);229IntHullOut.set_name(options.getProjectName()+".IntHull");230IntHullOut.setCone(MyCone.getIntegerHullCone());231IntHullOut.write_files();232}233234#ifdef NMZ_COCOA235if(MyCone.isComputed(ConeProperty::Symmetrize)){236Output<Integer> SymmOut;237options.applyOutputOptions(SymmOut);238SymmOut.set_name(options.getProjectName()+".symm");239SymmOut.setCone(MyCone.getSymmetrizedCone());240SymmOut.write_files();241}242#endif243}244245246//---------------------------------------------------------------------------247248int process_data(OptionsHandler& options, const string& command_line,const string& arg0) {249250#ifndef NCATCH251try {252#endif253254255string name_in=options.getProjectName()+".in";256const char* file_in=name_in.c_str();257ifstream in;258in.open(file_in,ifstream::in);259if ( !in.is_open() ) {260cerr << "error: Failed to open file "<<name_in<<"."<<endl;261exit(1);262}263264//read the file265string polynomial="";266long nr_coeff_quasipol=-1;267map <Type::InputType, vector< vector<mpq_class> > > input = readNormalizInput(in, options,polynomial,nr_coeff_quasipol);268in.close();269270if (verbose) {271cout << "------------------------------------------------------------" << endl;272cout << "Command line: " << command_line << endl;273cout << "Compute: " << options.getToCompute() << endl;274}275276if(options.isUseLongLong())277compute_and_output<long long>(options, input, polynomial,nr_coeff_quasipol);278else279compute_and_output<mpz_class>(options, input, polynomial,nr_coeff_quasipol);280281#ifndef NCATCH282} catch(const BadInputException& e) {283cerr << e.what() << endl;284cerr << "BadInputException caught... exiting." << endl;285exit(1);286} catch(const FatalException& e) {287cerr << e.what() << endl;288cerr << "FatalException caught... exiting." << endl;289exit(2);290} catch(const NmzCoCoAException& e) {291cerr << e.what() << endl;292cerr << "NmzCoCoAException caught... exiting." << endl;293exit(3);294} catch(const NormalizException& e) {295cerr << e.what() << endl;296cerr << "NormalizException caught... exiting." << endl;297exit(4);298} catch(const std::exception& e) {299cerr << "std::exception caught... \""<< e.what()<<"\" ... exiting." << endl;300exit(5);301}302#endif303304return 0;305}306307308