Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
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
Project: cocalc-sagemath-dev-slelievre
Views: 418346/*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>29using namespace std;3031#include "Qnormaliz.h"32#include "libQnormaliz/Qinteger.h"33#include "libQnormaliz/libQnormaliz.h"34#include "libQnormaliz/Qcone.h"35#include "libQnormaliz/Qmy_omp.h"36//#include "libnormaliz/libnormaliz.cpp"37using namespace libQnormaliz;38#include "Qinput.cpp"39#include "Qoptions.cpp"40#include "Qoutput.cpp"4142#ifndef STRINGIFY43#define STRINGIFYx(Token) #Token44#define STRINGIFY(Token) STRINGIFYx(Token)45#endif4647void printHeader() {48cout << " \\.....|"<<endl;49cout << " QNormaliz " << string( STRINGIFY(QNMZ_VERSION) " " ,11)50<< " \\....|"<<endl;51cout << " \\...|"<<endl;52cout << " (C) The Normaliz Team, University of Osnabrueck \\..|"<<endl;53cout << " November 2016 \\.|"<<endl;54cout << " \\|"<<endl;55}56void printHelp(char* command) {57cout << "Usage: "<<command<<" [options] PROJECT"<<endl;58cout << " runs normaliz on PROJECT.in"<<endl;59cout << "Options:"<<endl;60cout << " -S\tcompute sublattice"<<endl;61cout << " -s\tcompute support hyperplanes"<<endl;62cout << " -T\tcompute triangulation (output in file .tri)"<<endl;63cout << " -D\tcompute cone decomposition (includes -T)"<<endl;64cout << endl;65cout << " -k\tcomputation mode: keep order"<<endl;66cout << endl;67cout << " --<PROP> compute the ConeProperty <PROP>"<<endl;6869cout << endl;70cout << " -f, --files write the files .out .gen .inv .cst .msp"<<endl;71cout << " -a, --all-files write all output files (except .tri)"<<endl;72cout << " --<SUFFIX> write the file .<SUFFIX> where <SUFFIX> can be one of"<<endl;73cout << " cst, esp, ext, inv, lat, msp"<<endl;7475cout << endl;76cout << " -i, --ignore ignore the compute options set in the input file"<<endl;77cout << " -x=<T> limit the number of threads to <T>"<<endl;78cout << " --OutputDir=<path> set a path for the output files (relative to current directory)"<< endl;79cout << " -?, --help print this help text and exit"<<endl;80cout << " -c, --verbose verbose (prints control data)"<<endl;81cout << " --version print version info and exit"<<endl;82cout << endl;83cout << "Please report bugs to <[email protected]> or directly to our issue tracker:" << endl;84cout << "https://github.com/Normaliz/Normaliz/issues" << endl;85}8687void printCopying() {88cout<<"Copyright (C) 2007-2017 The Normaliz Team, University of Osnabrueck."<<endl89<<"This program comes with ABSOLUTELY NO WARRANTY; This is free software,"<<endl90<<"and you are welcome to redistribute it under certain conditions;"<<endl91<<"See COPYING for details."<<endl;92}9394void printVersion() {95cout << "Normaliz " << string(STRINGIFY(QNMZ_VERSION)) << endl;96printCopying();97}9899template<typename Number> int process_data(OptionsHandler& options, const string& command_line);100101//---------------------------------------------------------------------------102103int main(int argc, char* argv[])104{105106// read command line options107108OptionsHandler options;109110string command_line;111for(int i=1; i< argc;++i)112command_line=command_line+string(argv[i])+" ";113114bool print_help = options.handle_commandline(argc, argv);115116if (print_help) {117//printHeader();118printHelp(argv[0]);119exit(0);120}121122if (verbose) {123printHeader();124}125126if (!options.isUseLongLong()) {127process_data<mpq_class>(options, command_line);128}129// the previous process_data might return unsuccessfully if the input file specifies to use long long130131}132133//---------------------------------------------------------------------------134135template<typename Number> int process_data(OptionsHandler& options, const string& command_line) {136137#ifndef NCATCH138try {139#endif140141Output<Number> Out; //all the information relevant for output is collected in this object142143options.applyOutputOptions(Out);144145string name_in=options.getOutputName()+".in";146const char* file_in=name_in.c_str();147ifstream in;148in.open(file_in,ifstream::in);149if ( !in.is_open() ) {150cerr << "error: Failed to open file "<<name_in<<"."<<endl;151exit(1);152}153154//read the file155map <Type::InputType, vector< vector<Number> > > input = readNormalizInput<Number>(in, options);156157options.activateDefaultMode(); // only if no real cone property is given!158159Out.set_lattice_ideal_input(input.count(Type::lattice_ideal)>0);160161in.close();162163164if (verbose) {165cout << "************************************************************" << endl;166cout << "Command line: " << command_line << endl;167cout << "Compute: " << options.getToCompute() << endl;168}169170Cone<Number> MyCone = Cone<Number>(input);171long dim= (long) MyCone.getEmbeddingDim();172#ifdef _OPENMP173long max_threads=omp_get_max_threads();174if(!options.nr_threads_explicitly_set && std::getenv("OMP_NUM_THREADS")==NULL){175max_threads=min(max_threads,4*dim); // we limit the implicit number of threads176omp_set_num_threads(max_threads);177}178#endif179/* if (options.isUseBigNumber()) {180MyCone.deactivateChangeOfPrecision();181} */182try {183MyCone.compute(options.getToCompute());184} catch(const NotComputableException& e) {185std::cout << "Not all desired properties could be computed." << endl;186std::cout << e.what() << endl;187std::cout << "Writing only available data." << endl;188}189Out.setCone(MyCone);190Out.write_files();191192#ifndef NCATCH193} catch(const BadInputException& e) {194cerr << e.what() << endl;195cerr << "BadInputException caught... exiting." << endl;196exit(1);197} catch(const FatalException& e) {198cerr << e.what() << endl;199cerr << "FatalException caught... exiting." << endl;200exit(2);201} catch(const NormalizException& e) {202cerr << e.what() << endl;203cerr << "NormalizException caught... exiting." << endl;204exit(3);205} catch(const std::exception& e) {206cerr << "std::exception caught... \""<< e.what()<<"\" ... exiting." << endl;207exit(4);208}209#endif210211return 0;212}213214215