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: 418425/*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#ifndef INTEGER_H_24#define INTEGER_H_2526#include <libQnormaliz/Qgeneral.h>2728#include <list>29#include <vector>30#include <string>31#include <limits.h>3233//---------------------------------------------------------------------------3435namespace libQnormaliz {36using namespace std;3738//---------------------------------------------------------------------------39// Basic functions40//---------------------------------------------------------------------------4142// returns the absolute value of a43template<typename Number> inline Number Iabs(const Number& a) {44return (a>=0) ? (a) : Number(-a);45}4647//---------------------------------------------------------------------------48// Conversions and checks49//---------------------------------------------------------------------------5051// convert val to ret52// does the conversion and returns false if it fails53bool try_convert(long& ret, const long long& val);54inline bool try_convert(long long& ret, const long& val) {assert(false); return true;}55bool try_convert(long& ret, const mpz_class& val);56bool try_convert(long long& ret, const mpz_class& val);57inline bool try_convert(mpz_class& ret, const long& val) {assert(false); return true;}58bool try_convert(mpz_class& ret, const long long& val);5960// template for same typ "conversion"61template<typename Type>62inline bool try_convert(Type& ret, const Type& val) {ret = val; return true;}636465bool fits_long_range(long long a);6667template<typename Number>68inline bool using_GMP() {69return false;70}7172template<>73inline bool using_GMP<mpq_class>() {74return true;75}76//---------------------------------------------------------------------------7778// Should be completely remoced:79template<typename Number>80inline bool check_range(const Number& m) {81return true;82}8384//---------------------------------------------------------------------------85// Special functions86//---------------------------------------------------------------------------8788//return the number of decimals, needed to write the Number a89template<typename Number> size_t decimal_length(Number a);9091//returns b!/a!92template<typename Number> Number permutations(const size_t& a, const size_t& b);93template<typename Number> Number permutations_modulo(const size_t& a, const size_t& b, long m);9495//---------------------------------------------------------------------------96// String conversion functions97//---------------------------------------------------------------------------9899// forward declaration to silence clang error:100// 'operator<<' should be declared prior to the call site or in the global namespace101template <typename T> std::ostream& operator<< (std::ostream& out, const vector<T>& vec);102103template<typename Number> string toString(Number a) {104ostringstream ostream;105ostream << a;106return ostream.str();107}108/* template<> inline string toString(mpz_class a) {109return a.get_str();110}*/111template<> inline string toString(mpq_class a) {112return a.get_str();113}114115} // end libnormaliz116117//---------------------------------------------------------------------------118#endif /* INTEGER_H_ */119//---------------------------------------------------------------------------120121122