/* Cadabra: a field-theory motivated computer algebra system. Copyright (C) 2001-2014 Kasper Peeters This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "Combinatorics.hh" unsigned long combin::factorial(unsigned int x) { unsigned long ret=1; while(x) { ret*=x--; } return ret; } int combin::determine_intersection_ranges(const combin::range_vector_t& prod, const combin::range_vector_t& indv, combin::range_vector_t& target) { int ret=1; for(unsigned int i=0; i=2) { ret*=factorial(newrange.size()); target.push_back(newrange); } } } return ret; } long combin::vector_sum(const std::vector& v) { long ret=0; for(unsigned int i=0; i& v) { unsigned long ret=1; for(unsigned int i=0; i& v) { unsigned long ret=1; for(unsigned int i=0; i& one, const std::vector& two) { if(one.size()!=two.size()) return false; for(unsigned int k=0; k& one) { long ret=1; for(unsigned int k=0; k