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 / Qlist_operations.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*/222324//---------------------------------------------------------------------------2526#include <iostream>27#include <string>2829#include "libQnormaliz/Qinteger.h"30#include "libQnormaliz/Qvector_operations.h"31#include "libQnormaliz/Qmatrix.h"32// #include "libQnormaliz/Qsimplex.h"33#include "libQnormaliz/Qlist_operations.h"3435//---------------------------------------------------------------------------3637namespace libQnormaliz {38using namespace std;3940//---------------------------------------------------------------------------4142template<typename Number>43vector<Number> l_multiplication(const list< vector<Number> >& l,const vector<Number>& v){44int s=l.size();45vector<Number> p(s);46typename list< vector<Number> >::const_iterator i;47s=0;48for (i =l.begin(); i != l.end(); ++i, ++s) {49p[s]=v_scalar_product(*i,v); //maybe we loose time here?50}51return p;52}5354//---------------------------------------------------------------------------5556template<typename Number>57list< vector<Number> > l_list_x_matrix(const list< vector<Number> >& l,const Matrix<Number>& M){58list< vector<Number> > result;59vector<Number> p;60typename list< vector<Number> >::const_iterator i;61for (i =l.begin(); i != l.end(); i++) {62p=M.VxM(*i);63result.push_back(p);64}65return result;66}67//---------------------------------------------------------------------------6869template<typename Number>70void l_cut(list< vector<Number> >& l, int size){71typename list< vector<Number> >::iterator i;72for (i =l.begin(); i != l.end(); i++) {73(*i).resize(size);74}75}7677//---------------------------------------------------------------------------787980template<typename Number>81void l_cut_front(list< vector<Number> >& l, int size){82typename list< vector<Number> >::iterator i;83vector<Number> tmp;84for (i =l.begin(); i != l.end(); ) {85tmp=v_cut_front(*i, size);86i=l.erase(i); //important to decrease memory consumption87l.insert(i,tmp);88}89}9091//---------------------------------------------------------------------------9293}949596