From b704e66d3d8a6f1e0bc09354492ac312b4c1a836 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 29 Jan 2015 15:35:41 +1100 Subject: [PATCH] maths: remove now redundant polynomial code --- Makefile.am | 2 - maths/polynomial.hpp | 37 ------------ maths/polynomial.ipp | 131 ------------------------------------------- 3 files changed, 170 deletions(-) delete mode 100644 maths/polynomial.hpp delete mode 100644 maths/polynomial.ipp diff --git a/Makefile.am b/Makefile.am index b8a4166a..4e20a0fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -83,8 +83,6 @@ UTIL_FILES = \ maths.ipp \ maths/matrix.cpp \ maths/matrix.hpp \ - maths/polynomial.ipp\ - maths/polynomial.hpp\ maths/vector.cpp \ maths/vector.hpp \ matrix.cpp \ diff --git a/maths/polynomial.hpp b/maths/polynomial.hpp deleted file mode 100644 index b85bc094..00000000 --- a/maths/polynomial.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of libgim. - * - * libgim 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. - * - * libgim 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 libgim. If not, see . - * - * Copyright 2010 Danny Robson - */ - -#ifndef __UTIL_MATHS_POLYNOMIAL_HPP -#define __UTIL_MATHS_POLYNOMIAL_HPP - -#include -#include - -namespace maths { - template - struct polynomial { - std::array coefficients; - - T eval (T x) const; - }; -} - -#include "polynomial.ipp" - -#endif diff --git a/maths/polynomial.ipp b/maths/polynomial.ipp deleted file mode 100644 index 37ccb23a..00000000 --- a/maths/polynomial.ipp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file is part of libgim. - * - * libgim 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. - * - * libgim 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 libgim. If not, see . - * - * Copyright 2010 Danny Robson - */ - -#ifdef __UTIL_MATHS_POLYNOMIAL_IPP -#error Double includion of util/maths/polynomial.hpp -#endif - -#define __UTIL_MATHS_POLYNOMIAL_IPP - - -//----------------------------------------------------------------------------- -template -T -maths::polynomial::eval (T x) const { - T val = 0; - T exp = 1; - - for (const T &i: coefficients) { - val += i * exp; - exp *= x; - } - - return val; -} - - -//----------------------------------------------------------------------------- -#include "../json.hpp" -#include "../types.hpp" - -namespace json { - template - struct io> { - typedef maths::polynomial type; - - static type - deserialise (const json::node &node) { - const json::array &source = node.as_array (); - type dest; - - if (source.size () != N) - throw std::runtime_error ("Polynomial size mismatch in json serialisation"); - - for (size_t i = 0; i < N; ++i) - dest.coefficients[i] = source[i].as_number (); - return dest; - } - - static std::unique_ptr - serialise (type src) { - auto dst = make_unique (); - - for (const auto &i: src.coefficients) - dst->insert (i); - - return std::unique_ptr (dst.release ()); - } - }; -} - - -namespace json { - //template - //std::unique_ptr - //io>::serialise (const maths::polynomial&); - - //template - //maths::polynomial - //io>::deserialise(const json::node &node); - /*{ - typedef maths::polynomial type; - - json::array &source = node.as_array (); - type dest; - - if (source.size () != N) - throw std::runtime_error ("Polynomial size mismatch in json serialisation"); - - for (size_t i = 0; i < N; ++i) - dest.coefficients[i] = source[i].as_number (); - return dest; - }*/ -} - - -/*namespace json { - template - struct io > { - static std::unique_ptr serialise (const maths::polynomial&); - static maths::polynomial deserialise (const json::node&); - }; - - template - std::unique_ptr - node::serialise> (const maths::polynomial &poly) { - std::unique_ptr val (new array); - - for (const double &i: poly.coefficients) - val->insert (node::serialise (i)); - - std::unique_ptr ret (val.release ()); - return ret; - } -}*/ - - -/*from_json> (const json::node &node) { - maths::polynomial val; - - const json::array &source = node.as_array (); - for (size_t i = 0; i < N; ++i) - val.coefficients[i] = source[i].as_number (); - - return val; -}*/