This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "roboptim-core".
The branch, master has been updated via dc6ae48bef8d7a68df404f4eabc24bd82a26a640 (commit) via a84e158a8e722d36c5cfafdeba3fb051611c6933 (commit) from 7943b4f0089d67ad40cb7a8887e0e2e20fccedfd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit dc6ae48bef8d7a68df404f4eabc24bd82a26a640 Author: Thomas Moulard <thomas.moul...@gmail.com> Date: Wed Mar 3 13:34:59 2010 +0100 Add Split filter. * include/Makefile.am: Distribute new headers. * include/roboptim/core/filter/split.hh: New. * include/roboptim/core/filter/split.hxx: New. * tests/Makefile.am: Compile new test case. * tests/split.cc: New. * tests/split.stdout: New. * tests/testsuite.at: Add new test case. Signed-off-by: Thomas Moulard <thomas.moul...@gmail.com> diff --git a/ChangeLog b/ChangeLog index 4ce911b..53104e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2010-03-03 Thomas Moulard <thomas.moul...@gmail.com> + Add Split filter. + * include/Makefile.am: Distribute new headers. + * include/roboptim/core/filter/split.hh: New. + * include/roboptim/core/filter/split.hxx: New. + * tests/Makefile.am: Compile new test case. + * tests/split.cc: New. + * tests/split.stdout: New. + * tests/testsuite.at: Add new test case. + +2010-03-03 Thomas Moulard <thomas.moul...@gmail.com> + Clean filter. * include/roboptim/core/derivative-size.hh: New. * include/roboptim/core/filter/cached-function.hh, diff --git a/include/Makefile.am b/include/Makefile.am index de2cb13..e4e3dd2 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,14 +2,18 @@ include $(top_srcdir)/build-aux/init.mk # --- Distribute and install headers. nobase_include_HEADERS = \ + roboptim/core.hh + +nobase_include_HEADERS += \ roboptim/core/constant-function.hh \ roboptim/core/debug.hh \ roboptim/core/derivable-function.hh \ roboptim/core/derivable-parametrized-function.hh\ - roboptim/core/function.hh \ - roboptim/core/fwd.hh \ + roboptim/core/derivative-size.hh \ roboptim/core/finite-difference-gradient.hh \ roboptim/core/finite-difference-gradient.hxx \ + roboptim/core/function.hh \ + roboptim/core/fwd.hh \ roboptim/core/generic-solver.hh \ roboptim/core/identity-function.hh \ roboptim/core/indent.hh \ @@ -17,16 +21,16 @@ nobase_include_HEADERS = \ roboptim/core/linear-function.hh \ roboptim/core/n-times-derivable-function.hh \ roboptim/core/n-times-derivable-function.hxx \ - roboptim/core/numeric-quadratic-function.hh \ roboptim/core/numeric-linear-function.hh \ + roboptim/core/numeric-quadratic-function.hh \ roboptim/core/parametrized-function.hh \ roboptim/core/parametrized-function.hxx \ roboptim/core/portability.hh \ roboptim/core/problem.hh \ roboptim/core/problem.hxx \ roboptim/core/quadratic-function.hh \ - roboptim/core/result.hh \ roboptim/core/result-with-warnings.hh \ + roboptim/core/result.hh \ roboptim/core/solver-error.hh \ roboptim/core/solver-factory.hh \ roboptim/core/solver-factory.hxx \ @@ -41,7 +45,9 @@ nobase_include_HEADERS = \ # Function filters. nobase_include_HEADERS += \ roboptim/core/filter/cached-function.hh \ - roboptim/core/filter/cached-function.hxx + roboptim/core/filter/cached-function.hxx \ + roboptim/core/filter/split.hh \ + roboptim/core/filter/split.hxx # Built-in plug-in. diff --git a/include/roboptim/core/filter/split.hh b/include/roboptim/core/filter/split.hh new file mode 100644 index 0000000..27045fb --- /dev/null +++ b/include/roboptim/core/filter/split.hh @@ -0,0 +1,97 @@ +// Copyright (C) 2010 by Thomas Moulard, AIST, CNRS, INRIA. +// +// This file is part of the roboptim. +// +// roboptim is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// roboptim 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with roboptim. If not, see <http://www.gnu.org/licenses/>. + +#ifndef ROBOPTIM_CORE_FILTER_SPLIT_HH +# define ROBOPTIM_CORE_FILTER_SPLIT_HH +# include <roboptim/core/sys.hh> +# include <roboptim/core/debug.hh> + +# include <boost/shared_ptr.hpp> + +# include <roboptim/core/n-times-derivable-function.hh> + +namespace roboptim +{ + /// \addtogroup roboptim_filter + /// @{ + + + template <typename T> + class ROBOPTIM_DLLAPI Split : public T + { + public: + /// \brief Import value type. + typedef typename DerivableFunction::value_type value_type; + /// \brief Import size type. + typedef typename DerivableFunction::size_type size_type; + /// \brief Import vector type. + typedef typename DerivableFunction::vector_t vector_t; + /// \brief Import result type. + typedef typename DerivableFunction::result_t result_t; + /// \brief Import argument type. + typedef typename DerivableFunction::argument_t argument_t; + /// \brief Import gradient type. + typedef typename DerivableFunction::gradient_t gradient_t; + /// \brief Import hessian type. + typedef typename TwiceDerivableFunction::hessian_t hessian_t; + /// \brief Import jacobian type. + typedef typename DerivableFunction::jacobian_t jacobian_t; + /// \brief Import interval type. + typedef typename DerivableFunction::interval_t interval_t; + + explicit Split (boost::shared_ptr<const T> fct, unsigned functionId) throw (); + ~Split () throw (); + + protected: + virtual void impl_compute (result_t& result, const argument_t& argument) + const throw (); + + + virtual void impl_gradient (gradient_t& gradient, + const argument_t& argument, + size_type functionId = 0) + const throw (); + + virtual void impl_hessian (hessian_t& hessian, + const argument_t& argument, + size_type functionId = 0) const throw (); + + virtual void impl_derivative (gradient_t& derivative, + double argument, + size_type order = 1) const throw (); + + private: + boost::shared_ptr<const T> function_; + unsigned functionId_; + }; + + template <typename P, typename C> + void addNonScalarConstraint + (P& problem, + boost::shared_ptr<C> constraint, + std::vector<Function::interval_t> interval, + std::vector<Function::value_type> scale + = std::vector<Function::value_type> ()) + throw (std::runtime_error); + + + /// @} + +} // end of namespace roboptim + +# include <roboptim/core/filter/split.hxx> +#endif //! ROBOPTIM_CORE_FILTER_SPLIT_HH diff --git a/include/roboptim/core/filter/split.hxx b/include/roboptim/core/filter/split.hxx new file mode 100644 index 0000000..b6cb7c0 --- /dev/null +++ b/include/roboptim/core/filter/split.hxx @@ -0,0 +1,183 @@ +// Copyright (C) 2010 by Thomas Moulard, AIST, CNRS, INRIA. +// +// This file is part of the roboptim. +// +// roboptim is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// roboptim 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with roboptim. If not, see <http://www.gnu.org/licenses/>. + +#ifndef ROBOPTIM_CORE_FILTER_SPLIT_HXX +# define ROBOPTIM_CORE_FILTER_SPLIT_HXX +# include <boost/format.hpp> + +# include <roboptim/core/derivative-size.hh> + +namespace roboptim +{ + namespace + { + template <typename T> + std::string splitName (const T& fct); + + template <typename T> + std::string splitName (const T& fct, unsigned functionId) + { + boost::format fmt ("%1% (split, function Id = %2%)"); + fmt % fct.getName () % functionId; + return fmt.str (); + } + } // end of anonymous namespace. + + template <typename T> + Split<T>::Split (boost::shared_ptr<const T> fct, unsigned functionId) throw () + : T (fct->inputSize (), 1, splitName (*fct, functionId)), + function_ (fct), + functionId_ (functionId) + { + assert (functionId < fct->outputSize ()); + } + + template <typename T> + Split<T>::~Split () throw () + { + } + + template <typename T> + void + Split<T>::impl_compute (result_t& result, + const argument_t& argument) + const throw () + { + result_t res (function_->outputSize ()); + (*function_) (res, argument); + result[0] = res[functionId_]; + } + + + template <> + void + Split<Function>::impl_gradient (gradient_t&, const argument_t&, size_type) + const throw () + { + assert (0); + } + + template <typename T> + void + Split<T>::impl_gradient (gradient_t& gradient, + const argument_t& argument, + size_type functionId) + const throw () + { + assert (functionId == 0); + function_->gradient (gradient, argument, functionId_); + } + + + + + template <> + void + Split<Function>::impl_hessian + (hessian_t&, const argument_t&, size_type) const throw () + { + assert (0); + } + + template <> + void + Split<DerivableFunction>::impl_hessian + (hessian_t&, const argument_t&, size_type) const throw () + { + assert (0); + } + + + + template <typename T> + void + Split<T>::impl_hessian (hessian_t& hessian, + const argument_t& argument, + size_type functionId) + const throw () + { + assert (functionId == 0); + function_->hessian (hessian, argument, functionId_); + } + + + template <> + void + Split<Function>::impl_derivative + (gradient_t&, double, size_type) const throw () + { + assert (0); + } + + template <> + void + Split<DerivableFunction>::impl_derivative + (gradient_t&, double, size_type) const throw () + { + assert (0); + } + + template <> + void + Split<TwiceDerivableFunction>::impl_derivative + (gradient_t&, double, size_type) const throw () + { + assert (0); + } + + template <typename T> + void + Split<T>::impl_derivative (gradient_t& derivative, + double argument, + size_type order) + const throw () + { + function_->derivative (derivative, argument, order); + } + + template <typename P, typename C> + void addNonScalarConstraint + (P& problem, + boost::shared_ptr<C> constraint, + std::vector<Function::interval_t> interval, + std::vector<Function::value_type> scale) + throw (std::runtime_error) + { + assert (constraint); + assert (interval.size () == constraint->outputSize ()); + assert (scale.empty () || scale.size () == constraint->outputSize ()); + + if (constraint->outputSize () == 1) + { + if (scale.empty ()) + problem.addConstraint (constraint, interval[0]); + else + problem.addConstraint (constraint, interval[0], scale[0]); + return; + } + for (unsigned i = 0; i < constraint->outputSize (); ++i) + { + boost::shared_ptr<Split<C> > split = new Split<C> (constraint, i); + if (scale.empty ()) + problem.addConstraint (split, interval[i]); + else + problem.addConstraint (split, interval[i], scale[i]); + } + } +} // end of namespace roboptim + +#endif //! ROBOPTIM_CORE_FILTER_SPLIT_HXX diff --git a/tests/Makefile.am b/tests/Makefile.am index 96a6157..f84cef2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -97,11 +97,6 @@ derivable_parametrized_function_SOURCES = derivable-parametrized-function.cc \ $(COMMON_SOURCES) derivable_parametrized_function_LDADD = $(top_builddir)/src/libroboptim-core.la -# cached-function -check_PROGRAMS += cached-function -cached_function_SOURCES = cached-function.cc $(COMMON_SOURCES) -cached_function_LDADD = $(top_builddir)/src/libroboptim-core.la - # plugin check_PROGRAMS += plugin plugin_SOURCES = plugin.cc $(COMMON_SOURCES) @@ -123,6 +118,20 @@ check_PROGRAMS += constant-function constant_function_SOURCES = constant-function.cc $(COMMON_SOURCES) constant_function_LDADD = $(top_builddir)/src/libroboptim-core.la + + +# cached-function +check_PROGRAMS += cached-function +cached_function_SOURCES = cached-function.cc $(COMMON_SOURCES) +cached_function_LDADD = $(top_builddir)/src/libroboptim-core.la + +# split +check_PROGRAMS += split +split_SOURCES = split.cc $(COMMON_SOURCES) +split_LDADD = $(top_builddir)/src/libroboptim-core.la + + + # visualization-gnuplot-simple check_PROGRAMS += visualization-gnuplot-simple visualization_gnuplot_simple_SOURCES = visualization-gnuplot-simple.cc \ @@ -176,6 +185,7 @@ EXTRA_DIST += \ problem-cc.stdout \ result.stdout \ simple.stdout \ + split.stdout \ twice-derivable-function.stdout \ util.stdout \ visualization-gnuplot-function.stdout \ diff --git a/tests/split.cc b/tests/split.cc new file mode 100644 index 0000000..c34509b --- /dev/null +++ b/tests/split.cc @@ -0,0 +1,75 @@ +// Copyright (C) 2010 by Thomas Moulard, AIST, CNRS, INRIA. +// +// This file is part of the roboptim. +// +// roboptim is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// roboptim 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with roboptim. If not, see <http://www.gnu.org/licenses/>. + +#include "common.hh" + +#include <iostream> + +#include <roboptim/core/io.hh> +#include <roboptim/core/derivable-function.hh> +#include <roboptim/core/util.hh> +#include <roboptim/core/filter/split.hh> + +using namespace roboptim; + +struct F : public DerivableFunction +{ + F () : DerivableFunction (1, 10, "f_n (x) = n * x") + {} + + void impl_compute (result_t& res, const argument_t& argument) const throw () + { + res.clear (); + for (size_type i = 0; i < outputSize (); ++i) + res[i] = i * argument[0]; + } + + void impl_gradient (gradient_t& grad, const argument_t& argument, + size_type functionId) const throw () + { + grad.clear (); + grad[0] = functionId; + } +}; + +int run_test () +{ + boost::shared_ptr<F> f (new F ()); + + for (unsigned id = 0; id < 10; ++id) + { + Split<DerivableFunction> splitF (f, id); + + std::cout << splitF << ":" << std::endl + << std::endl; + + Function::vector_t x (1); + for (double i = 0.; i < 10.; i += 0.5) + { + x[0] = i; + std::cout << splitF (x) << std::endl; + std::cout << splitF (x) << std::endl; + //assert ((*f) (x)[0] == splitF (x)[id]); + + std::cout << splitF.gradient (x) << std::endl; + std::cout << splitF.gradient (x) << std::endl; + } + } + return 0; +} + +GENERATE_TEST () diff --git a/tests/split.stdout b/tests/split.stdout new file mode 100644 index 0000000..f0227c7 --- /dev/null +++ b/tests/split.stdout @@ -0,0 +1,820 @@ +f_n (x) = n * x (split, function Id = 0) (derivable function): + +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +[1](0) +f_n (x) = n * x (split, function Id = 1) (derivable function): + +[1](0) +[1](0) +[1](1) +[1](1) +[1](0.5) +[1](0.5) +[1](1) +[1](1) +[1](1) +[1](1) +[1](1) +[1](1) +[1](1.5) +[1](1.5) +[1](1) +[1](1) +[1](2) +[1](2) +[1](1) +[1](1) +[1](2.5) +[1](2.5) +[1](1) +[1](1) +[1](3) +[1](3) +[1](1) +[1](1) +[1](3.5) +[1](3.5) +[1](1) +[1](1) +[1](4) +[1](4) +[1](1) +[1](1) +[1](4.5) +[1](4.5) +[1](1) +[1](1) +[1](5) +[1](5) +[1](1) +[1](1) +[1](5.5) +[1](5.5) +[1](1) +[1](1) +[1](6) +[1](6) +[1](1) +[1](1) +[1](6.5) +[1](6.5) +[1](1) +[1](1) +[1](7) +[1](7) +[1](1) +[1](1) +[1](7.5) +[1](7.5) +[1](1) +[1](1) +[1](8) +[1](8) +[1](1) +[1](1) +[1](8.5) +[1](8.5) +[1](1) +[1](1) +[1](9) +[1](9) +[1](1) +[1](1) +[1](9.5) +[1](9.5) +[1](1) +[1](1) +f_n (x) = n * x (split, function Id = 2) (derivable function): + +[1](0) +[1](0) +[1](2) +[1](2) +[1](1) +[1](1) +[1](2) +[1](2) +[1](2) +[1](2) +[1](2) +[1](2) +[1](3) +[1](3) +[1](2) +[1](2) +[1](4) +[1](4) +[1](2) +[1](2) +[1](5) +[1](5) +[1](2) +[1](2) +[1](6) +[1](6) +[1](2) +[1](2) +[1](7) +[1](7) +[1](2) +[1](2) +[1](8) +[1](8) +[1](2) +[1](2) +[1](9) +[1](9) +[1](2) +[1](2) +[1](10) +[1](10) +[1](2) +[1](2) +[1](11) +[1](11) +[1](2) +[1](2) +[1](12) +[1](12) +[1](2) +[1](2) +[1](13) +[1](13) +[1](2) +[1](2) +[1](14) +[1](14) +[1](2) +[1](2) +[1](15) +[1](15) +[1](2) +[1](2) +[1](16) +[1](16) +[1](2) +[1](2) +[1](17) +[1](17) +[1](2) +[1](2) +[1](18) +[1](18) +[1](2) +[1](2) +[1](19) +[1](19) +[1](2) +[1](2) +f_n (x) = n * x (split, function Id = 3) (derivable function): + +[1](0) +[1](0) +[1](3) +[1](3) +[1](1.5) +[1](1.5) +[1](3) +[1](3) +[1](3) +[1](3) +[1](3) +[1](3) +[1](4.5) +[1](4.5) +[1](3) +[1](3) +[1](6) +[1](6) +[1](3) +[1](3) +[1](7.5) +[1](7.5) +[1](3) +[1](3) +[1](9) +[1](9) +[1](3) +[1](3) +[1](10.5) +[1](10.5) +[1](3) +[1](3) +[1](12) +[1](12) +[1](3) +[1](3) +[1](13.5) +[1](13.5) +[1](3) +[1](3) +[1](15) +[1](15) +[1](3) +[1](3) +[1](16.5) +[1](16.5) +[1](3) +[1](3) +[1](18) +[1](18) +[1](3) +[1](3) +[1](19.5) +[1](19.5) +[1](3) +[1](3) +[1](21) +[1](21) +[1](3) +[1](3) +[1](22.5) +[1](22.5) +[1](3) +[1](3) +[1](24) +[1](24) +[1](3) +[1](3) +[1](25.5) +[1](25.5) +[1](3) +[1](3) +[1](27) +[1](27) +[1](3) +[1](3) +[1](28.5) +[1](28.5) +[1](3) +[1](3) +f_n (x) = n * x (split, function Id = 4) (derivable function): + +[1](0) +[1](0) +[1](4) +[1](4) +[1](2) +[1](2) +[1](4) +[1](4) +[1](4) +[1](4) +[1](4) +[1](4) +[1](6) +[1](6) +[1](4) +[1](4) +[1](8) +[1](8) +[1](4) +[1](4) +[1](10) +[1](10) +[1](4) +[1](4) +[1](12) +[1](12) +[1](4) +[1](4) +[1](14) +[1](14) +[1](4) +[1](4) +[1](16) +[1](16) +[1](4) +[1](4) +[1](18) +[1](18) +[1](4) +[1](4) +[1](20) +[1](20) +[1](4) +[1](4) +[1](22) +[1](22) +[1](4) +[1](4) +[1](24) +[1](24) +[1](4) +[1](4) +[1](26) +[1](26) +[1](4) +[1](4) +[1](28) +[1](28) +[1](4) +[1](4) +[1](30) +[1](30) +[1](4) +[1](4) +[1](32) +[1](32) +[1](4) +[1](4) +[1](34) +[1](34) +[1](4) +[1](4) +[1](36) +[1](36) +[1](4) +[1](4) +[1](38) +[1](38) +[1](4) +[1](4) +f_n (x) = n * x (split, function Id = 5) (derivable function): + +[1](0) +[1](0) +[1](5) +[1](5) +[1](2.5) +[1](2.5) +[1](5) +[1](5) +[1](5) +[1](5) +[1](5) +[1](5) +[1](7.5) +[1](7.5) +[1](5) +[1](5) +[1](10) +[1](10) +[1](5) +[1](5) +[1](12.5) +[1](12.5) +[1](5) +[1](5) +[1](15) +[1](15) +[1](5) +[1](5) +[1](17.5) +[1](17.5) +[1](5) +[1](5) +[1](20) +[1](20) +[1](5) +[1](5) +[1](22.5) +[1](22.5) +[1](5) +[1](5) +[1](25) +[1](25) +[1](5) +[1](5) +[1](27.5) +[1](27.5) +[1](5) +[1](5) +[1](30) +[1](30) +[1](5) +[1](5) +[1](32.5) +[1](32.5) +[1](5) +[1](5) +[1](35) +[1](35) +[1](5) +[1](5) +[1](37.5) +[1](37.5) +[1](5) +[1](5) +[1](40) +[1](40) +[1](5) +[1](5) +[1](42.5) +[1](42.5) +[1](5) +[1](5) +[1](45) +[1](45) +[1](5) +[1](5) +[1](47.5) +[1](47.5) +[1](5) +[1](5) +f_n (x) = n * x (split, function Id = 6) (derivable function): + +[1](0) +[1](0) +[1](6) +[1](6) +[1](3) +[1](3) +[1](6) +[1](6) +[1](6) +[1](6) +[1](6) +[1](6) +[1](9) +[1](9) +[1](6) +[1](6) +[1](12) +[1](12) +[1](6) +[1](6) +[1](15) +[1](15) +[1](6) +[1](6) +[1](18) +[1](18) +[1](6) +[1](6) +[1](21) +[1](21) +[1](6) +[1](6) +[1](24) +[1](24) +[1](6) +[1](6) +[1](27) +[1](27) +[1](6) +[1](6) +[1](30) +[1](30) +[1](6) +[1](6) +[1](33) +[1](33) +[1](6) +[1](6) +[1](36) +[1](36) +[1](6) +[1](6) +[1](39) +[1](39) +[1](6) +[1](6) +[1](42) +[1](42) +[1](6) +[1](6) +[1](45) +[1](45) +[1](6) +[1](6) +[1](48) +[1](48) +[1](6) +[1](6) +[1](51) +[1](51) +[1](6) +[1](6) +[1](54) +[1](54) +[1](6) +[1](6) +[1](57) +[1](57) +[1](6) +[1](6) +f_n (x) = n * x (split, function Id = 7) (derivable function): + +[1](0) +[1](0) +[1](7) +[1](7) +[1](3.5) +[1](3.5) +[1](7) +[1](7) +[1](7) +[1](7) +[1](7) +[1](7) +[1](10.5) +[1](10.5) +[1](7) +[1](7) +[1](14) +[1](14) +[1](7) +[1](7) +[1](17.5) +[1](17.5) +[1](7) +[1](7) +[1](21) +[1](21) +[1](7) +[1](7) +[1](24.5) +[1](24.5) +[1](7) +[1](7) +[1](28) +[1](28) +[1](7) +[1](7) +[1](31.5) +[1](31.5) +[1](7) +[1](7) +[1](35) +[1](35) +[1](7) +[1](7) +[1](38.5) +[1](38.5) +[1](7) +[1](7) +[1](42) +[1](42) +[1](7) +[1](7) +[1](45.5) +[1](45.5) +[1](7) +[1](7) +[1](49) +[1](49) +[1](7) +[1](7) +[1](52.5) +[1](52.5) +[1](7) +[1](7) +[1](56) +[1](56) +[1](7) +[1](7) +[1](59.5) +[1](59.5) +[1](7) +[1](7) +[1](63) +[1](63) +[1](7) +[1](7) +[1](66.5) +[1](66.5) +[1](7) +[1](7) +f_n (x) = n * x (split, function Id = 8) (derivable function): + +[1](0) +[1](0) +[1](8) +[1](8) +[1](4) +[1](4) +[1](8) +[1](8) +[1](8) +[1](8) +[1](8) +[1](8) +[1](12) +[1](12) +[1](8) +[1](8) +[1](16) +[1](16) +[1](8) +[1](8) +[1](20) +[1](20) +[1](8) +[1](8) +[1](24) +[1](24) +[1](8) +[1](8) +[1](28) +[1](28) +[1](8) +[1](8) +[1](32) +[1](32) +[1](8) +[1](8) +[1](36) +[1](36) +[1](8) +[1](8) +[1](40) +[1](40) +[1](8) +[1](8) +[1](44) +[1](44) +[1](8) +[1](8) +[1](48) +[1](48) +[1](8) +[1](8) +[1](52) +[1](52) +[1](8) +[1](8) +[1](56) +[1](56) +[1](8) +[1](8) +[1](60) +[1](60) +[1](8) +[1](8) +[1](64) +[1](64) +[1](8) +[1](8) +[1](68) +[1](68) +[1](8) +[1](8) +[1](72) +[1](72) +[1](8) +[1](8) +[1](76) +[1](76) +[1](8) +[1](8) +f_n (x) = n * x (split, function Id = 9) (derivable function): + +[1](0) +[1](0) +[1](9) +[1](9) +[1](4.5) +[1](4.5) +[1](9) +[1](9) +[1](9) +[1](9) +[1](9) +[1](9) +[1](13.5) +[1](13.5) +[1](9) +[1](9) +[1](18) +[1](18) +[1](9) +[1](9) +[1](22.5) +[1](22.5) +[1](9) +[1](9) +[1](27) +[1](27) +[1](9) +[1](9) +[1](31.5) +[1](31.5) +[1](9) +[1](9) +[1](36) +[1](36) +[1](9) +[1](9) +[1](40.5) +[1](40.5) +[1](9) +[1](9) +[1](45) +[1](45) +[1](9) +[1](9) +[1](49.5) +[1](49.5) +[1](9) +[1](9) +[1](54) +[1](54) +[1](9) +[1](9) +[1](58.5) +[1](58.5) +[1](9) +[1](9) +[1](63) +[1](63) +[1](9) +[1](9) +[1](67.5) +[1](67.5) +[1](9) +[1](9) +[1](72) +[1](72) +[1](9) +[1](9) +[1](76.5) +[1](76.5) +[1](9) +[1](9) +[1](81) +[1](81) +[1](9) +[1](9) +[1](85.5) +[1](85.5) +[1](9) +[1](9) diff --git a/tests/testsuite.at b/tests/testsuite.at index 7acb59c..7421cc2 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -47,7 +47,6 @@ CHECK_STDOUT([constant-function], [Check constant function class.]) CHECK_STDOUT([parametrized-function], [Check parametrized function class.]) CHECK_STDOUT([derivable-parametrized-function], [Check derivable parametrized function class.]) -CHECK_STDOUT([cached-function], [Check cached-function class.]) AT_BANNER([Problems]) CHECK_STDOUT([problem-cc], [Check problem copy constructor.]) @@ -59,6 +58,10 @@ CHECK_STDOUT([simple], [Check basic features.]) AT_BANNER([Plug-in mechanism]) CHECK_STDOUT([plugin], [Load dummy plug-in dynamically.]) +AT_BANNER([Filter]) +CHECK_STDOUT([cached-function], [Cache function]) +CHECK_STDOUT([split], [Split function]) + AT_BANNER([Visualization (Gnuplot)]) CHECK_STDOUT([visualization-gnuplot-simple], [Check Gnuplot visualization.]) CHECK_STDOUT([visualization-gnuplot-simple], [Check Gnuplot functions visualization.]) commit a84e158a8e722d36c5cfafdeba3fb051611c6933 Author: Thomas Moulard <thomas.moul...@gmail.com> Date: Wed Mar 3 13:34:17 2010 +0100 Clean filter. * include/roboptim/core/derivative-size.hh: New. * include/roboptim/core/filter/cached-function.hh, * include/roboptim/core/filter/cached-function.hxx: Uniformize header guards. * include/roboptim/core/fwd.hh: Pre-declare derivativeSize. * src/doc.hh: Define new group. Signed-off-by: Thomas Moulard <thomas.moul...@gmail.com> diff --git a/ChangeLog b/ChangeLog index 8190bbc..4ce911b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2010-03-03 Thomas Moulard <thomas.moul...@gmail.com> + Clean filter. + * include/roboptim/core/derivative-size.hh: New. + * include/roboptim/core/filter/cached-function.hh, + * include/roboptim/core/filter/cached-function.hxx: + Uniformize header guards. + * include/roboptim/core/fwd.hh: Pre-declare derivativeSize. + * src/doc.hh: Define new group. + +2010-03-03 Thomas Moulard <thomas.moul...@gmail.com> + Add root-level header to easy library use. * include/roboptim/core.hh: New. diff --git a/include/roboptim/core/derivative-size.hh b/include/roboptim/core/derivative-size.hh new file mode 100644 index 0000000..7cca07e --- /dev/null +++ b/include/roboptim/core/derivative-size.hh @@ -0,0 +1,49 @@ +// Copyright (C) 2010 by Thomas Moulard, AIST, CNRS, INRIA. +// +// This file is part of the roboptim. +// +// roboptim is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// roboptim 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with roboptim. If not, see <http://www.gnu.org/licenses/>. + +#ifndef ROBOPTIM_CORE_DERIVATIVE_SIZE_HH +# define ROBOPTIM_CORE_DERIVATIVE_SIZE_HH +# include <roboptim/core/fwd.hh> + +namespace roboptim +{ + template <> + struct derivativeSize<Function> + { + static const unsigned int value = 0; + }; + + template <> + struct derivativeSize<DerivableFunction> + { + static const unsigned int value = 1; + }; + + template <> + struct derivativeSize<TwiceDerivableFunction> + { + static const unsigned int value = 2; + }; + + template <unsigned N> + struct derivativeSize<NTimesDerivableFunction<N> > + { + static const unsigned int value = N; + }; +} // end of namespace roboptim + +#endif //! ROBOPTIM_CORE_DERIVATIVE_SIZE_HH diff --git a/include/roboptim/core/filter/cached-function.hh b/include/roboptim/core/filter/cached-function.hh index 8d50d55..86fe547 100644 --- a/include/roboptim/core/filter/cached-function.hh +++ b/include/roboptim/core/filter/cached-function.hh @@ -15,8 +15,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with roboptim. If not, see <http://www.gnu.org/licenses/>. -#ifndef ROBOPTIM_CORE_CACHED_FUNCTION_HH -# define ROBOPTIM_CORE_CACHED_FUNCTION_HH +#ifndef ROBOPTIM_CORE_FILTER_CACHED_FUNCTION_HH +# define ROBOPTIM_CORE_FILTER_CACHED_FUNCTION_HH # include <roboptim/core/sys.hh> # include <roboptim/core/debug.hh> @@ -28,7 +28,7 @@ namespace roboptim { - /// \addtogroup roboptim_meta_function + /// \addtogroup roboptim_filter /// @{ struct ltvector @@ -111,4 +111,4 @@ namespace roboptim } // end of namespace roboptim # include <roboptim/core/filter/cached-function.hxx> -#endif //! ROBOPTIM_CORE_CACHED_FUNCTION_HH +#endif //! ROBOPTIM_CORE_FILTER_CACHED_FUNCTION_HH diff --git a/include/roboptim/core/filter/cached-function.hxx b/include/roboptim/core/filter/cached-function.hxx index 80d117e..9acb9fc 100644 --- a/include/roboptim/core/filter/cached-function.hxx +++ b/include/roboptim/core/filter/cached-function.hxx @@ -15,10 +15,12 @@ // You should have received a copy of the GNU Lesser General Public License // along with roboptim. If not, see <http://www.gnu.org/licenses/>. -#ifndef ROBOPTIM_CORE_CACHED_FUNCTION_HXX -# define ROBOPTIM_CORE_CACHED_FUNCTION_HXX +#ifndef ROBOPTIM_CORE_FILTER_CACHED_FUNCTION_HXX +# define ROBOPTIM_CORE_FILTER_CACHED_FUNCTION_HXX # include <boost/format.hpp> +# include <roboptim/core/derivative-size.hh> + namespace roboptim { namespace @@ -34,33 +36,6 @@ namespace roboptim return fmt.str (); } - template <typename T> - struct derivativeSize; - - template <> - struct derivativeSize<Function> - { - static const unsigned int value = 0; - }; - - template <> - struct derivativeSize<DerivableFunction> - { - static const unsigned int value = 1; - }; - - template <> - struct derivativeSize<TwiceDerivableFunction> - { - static const unsigned int value = 2; - }; - - template <unsigned N> - struct derivativeSize<NTimesDerivableFunction<N> > - { - static const unsigned int value = 3; - }; - } // end of anonymous namespace. template <typename T> @@ -218,4 +193,4 @@ namespace roboptim } // end of namespace roboptim -#endif //! ROBOPTIM_CORE_CACHED_FUNCTION_HXX +#endif //! ROBOPTIM_CORE_FILTER_CACHED_FUNCTION_HXX diff --git a/include/roboptim/core/fwd.hh b/include/roboptim/core/fwd.hh index 11f3d2d..1012b5d 100644 --- a/include/roboptim/core/fwd.hh +++ b/include/roboptim/core/fwd.hh @@ -60,6 +60,9 @@ namespace roboptim template <typename T> class SolverFactory; template <unsigned DerivabilityOrder> class NTimesDerivableFunction; + template <typename T> + struct derivativeSize; + } // end of namespace roboptim. #endif //! ROBOPTIM_CORE_FWD_HH diff --git a/src/doc.hh b/src/doc.hh index dac74e5..add5243 100644 --- a/src/doc.hh +++ b/src/doc.hh @@ -771,6 +771,7 @@ int run_test () /// \defgroup roboptim_meta_function Mathematical abstract functions /// \defgroup roboptim_function Mathematical functions +/// \defgroup roboptim_filter Function filters /// \defgroup roboptim_problem Optimization problems /// \defgroup roboptim_solver Optimization solvers /// \defgroup roboptim_visualization Visualization ----------------------------------------------------------------------- Summary of changes: ChangeLog | 21 + include/Makefile.am | 16 +- .../roboptim/core/derivative-size.hh | 35 +- include/roboptim/core/filter/cached-function.hh | 8 +- include/roboptim/core/filter/cached-function.hxx | 35 +- .../core/filter/{cached-function.hh => split.hh} | 55 +- include/roboptim/core/filter/split.hxx | 183 +++++ include/roboptim/core/fwd.hh | 3 + src/doc.hh | 1 + tests/Makefile.am | 20 +- tests/{cached-function.cc => split.cc} | 46 +- tests/split.stdout | 820 ++++++++++++++++++++ tests/testsuite.at | 5 +- 13 files changed, 1138 insertions(+), 110 deletions(-) copy src/solver.cc => include/roboptim/core/derivative-size.hh (57%) copy include/roboptim/core/filter/{cached-function.hh => split.hh} (69%) create mode 100644 include/roboptim/core/filter/split.hxx copy tests/{cached-function.cc => split.cc} (60%) create mode 100644 tests/split.stdout hooks/post-receive -- roboptim-core ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ roboptim-commit mailing list roboptim-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/roboptim-commit