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//---------------------------------------------------------------------------24#ifndef LIST_OPERATIONS_H25#define LIST_OPERATIONS_H262728//---------------------------------------------------------------------------2930#include <vector>31#include <list>32#include <ostream>3334#include "libnormaliz/libnormaliz.h"35#include "libnormaliz/simplex.h"3637namespace libnormaliz {38using std::vector;39using std::list;4041//---------------------------------------------------------------------------42// Data access43//---------------------------------------------------------------------------4445template <typename T>46std::ostream& operator<< (std::ostream& out, const list<T>& l) {47typename list<T>::const_iterator i;48for (i =l.begin(); i != l.end(); i++) {49out << *i << " ";50}51out << std::endl;52return out;53}5455//---------------------------------------------------------------------------56// List operations57//---------------------------------------------------------------------------5859template<typename Integer>60vector<Integer> l_multiplication(const list< vector<Integer> >& l,const vector<Integer>& v);61//the list shall contain only vectors of size=v.size(). Returns a vector62//containing all the scalar products (we see l as as matrix and return l*v).63template<typename Integer>64list< vector<Integer> > l_list_x_matrix(const list< vector<Integer> >& l,const Matrix<Integer>& M);65//the list shall contain only vectors of size=M.nr_of_rows(). Returns a list66//containing the product (we see l as as matrix and return l*M).67template<typename Integer>68void l_cut(list< vector<Integer> >& l,int size );69//cuts all the vectors in l to a given size.70template<typename Integer>71void l_cut_front(list< vector<Integer> >& l,int size );72//cuts all the vectors in l to a given size, maintaining the back7374//---------------------------------------------------------------------------7576template<typename T>77void random_order(list<T>& LL){78vector<typename list<T>::iterator > list_order;79size_t nrLL=LL.size();80list_order.reserve(nrLL);81typename list<T>::iterator p=LL.begin();82for(size_t k=0;k<nrLL;++k,++p){83list_order.push_back(p);84}85for(size_t k=0;k<10*nrLL;++k){86swap(list_order[rand()%nrLL],list_order[rand()%nrLL]);87}88list<T> new_order;89for(size_t k=0;k<nrLL;++k){90new_order.push_back(*list_order[k]);91}92LL.clear();93LL.splice(LL.begin(),new_order);9495}9697//---------------------------------------------------------------------------9899template<typename T>100void random_order(list<T>& LL,typename list<T>::iterator from, typename list<T>::iterator to ){101102list<T> MM;103MM.splice(MM.begin(),LL,from,to);104random_order(MM);105LL.splice(LL.begin(),MM);106}107108109}110111//---------------------------------------------------------------------------112#endif113//---------------------------------------------------------------------------114115116