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
Path: gap4r8 / pkg / NormalizInterface-1.0.2 / Normaliz.git / Qsource / libQnormaliz / Qlibnormaliz.cpp
Views: 418384/*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 "libQnormaliz/libQnormaliz.h"24#include "libQnormaliz/Qgeneral.h"2526namespace libQnormaliz {2728bool verbose = false;2930// bool test_arithmetic_overflow = false;31// long overflow_test_modulus = 15401;3233size_t GMP_mat=0;34size_t GMP_hyp=0;35size_t GMP_scal_prod=0;36size_t TotDet=0;373839namespace {40std::ostream* verbose_ostream_ptr = &std::cout;41std::ostream* error_ostream_ptr = &std::cerr;42} // end anonymous namespace, only accessible in this file (and when it is included)4344bool setVerboseDefault(bool v) {45//we want to return the old value46bool old = verbose;47verbose = v;48return old;49}5051void setVerboseOutput(std::ostream& v_out) {52verbose_ostream_ptr = &v_out;53}5455void setErrorOutput(std::ostream& e_out) {56error_ostream_ptr = &e_out;57}5859std::ostream& verboseOutput() {60return *verbose_ostream_ptr;61}6263std::ostream& errorOutput() {64return *error_ostream_ptr;65}6667InputType to_type(const std::string& type_string) {6869if ( type_string=="0" || type_string=="1" || type_string=="2" || type_string=="3"70|| type_string=="4" || type_string=="5" || type_string=="6"71|| type_string=="hyperplanes"72|| type_string=="10") {73throw BadInputException("Error: deprecated type \"" + type_string74+ "\", please use new type string!");75}7677if (type_string=="0"||type_string=="integral_closure") {78return Type::integral_closure;79}80if (type_string=="polyhedron") {81return Type::polyhedron;82}83if (type_string=="1"||type_string=="normalization") {84return Type::normalization;85}86if (type_string=="2"||type_string=="polytope") {87return Type::polytope;88}89if (type_string=="3"||type_string=="rees_algebra") {90return Type::rees_algebra;91}92if (type_string=="4"||type_string=="hyperplanes" ||type_string=="inequalities") {93return Type::inequalities;94}95if (type_string=="strict_inequalities") {96return Type::strict_inequalities;97}98if (type_string=="strict_signs") {99return Type::strict_signs;100}101if (type_string=="inhom_inequalities") {102return Type::inhom_inequalities;103}104if (type_string=="dehomogenization") {105return Type::dehomogenization;106}107if (type_string=="5"||type_string=="equations") {108return Type::equations;109}110if (type_string=="inhom_equations") {111return Type::inhom_equations;112}113if (type_string=="6"||type_string=="congruences") {114return Type::congruences;115}116if (type_string=="inhom_congruences") {117return Type::inhom_congruences;118}119if (type_string=="signs") {120return Type::signs;121}122if (type_string=="10"||type_string=="lattice_ideal") {123return Type::lattice_ideal;124}125if (type_string=="grading") {126return Type::grading;127}128if (type_string=="excluded_faces") {129return Type::excluded_faces;130}131if (type_string=="lattice") {132return Type::lattice;133}134if (type_string=="saturation") {135return Type::saturation;136}137if (type_string=="cone") {138return Type::cone;139}140if (type_string=="offset") {141return Type::offset;142}143if (type_string=="vertices") {144return Type::vertices;145}146if (type_string=="support_hyperplanes") {147return Type::support_hyperplanes;148}149if (type_string=="cone_and_lattice") {150return Type::cone_and_lattice;151}152if (type_string=="subspace") {153return Type::subspace;154}155156throw BadInputException("Unknown type \"" + type_string + "\"!");157return Type::integral_closure;158}159160long type_nr_columns_correction(InputType t) {161if (t == Type::polytope || t == Type::rees_algebra)162return -1;163if (t == Type::congruences || t == Type::vertices || t == Type::polyhedron164|| t == Type::inhom_inequalities || t == Type::inhom_equations)165return 1;166if (t == Type::inhom_congruences)167return 2;168return 0;169}170171/* returns true if the input of this type is a vector */172bool type_is_vector(InputType type){173if (type == Type::grading || type == Type::signs || type == Type::strict_signs174|| type == Type::dehomogenization || type == Type::offset) {175return true;176}177return false;178}179180} /* end namespace libQnormaliz */181182183