|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56504 - in sandbox/statistics/adaptive_rejection_sampling: boost/ars boost/ars/function boost/ars/functional boost/ars/test libs/ars/doc
From: erwann.rogard_at_[hidden]
Date: 2009-10-01 13:02:50
Author: e_r
Date: 2009-10-01 13:02:48 EDT (Thu, 01 Oct 2009)
New Revision: 56504
URL: http://svn.boost.org/trac/boost/changeset/56504
Log:
m
Added:
sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/
sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/adaptor.hpp (contents, props changed)
sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/concept.hpp (contents, props changed)
sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/signature.hpp (contents, props changed)
Removed:
sandbox/statistics/adaptive_rejection_sampling/boost/ars/functional/
Text files modified:
sandbox/statistics/adaptive_rejection_sampling/boost/ars/proposal_sampler.hpp | 6 +++---
sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/standard_distribution.hpp | 5 +++--
sandbox/statistics/adaptive_rejection_sampling/libs/ars/doc/readme.txt | 1 +
3 files changed, 7 insertions(+), 5 deletions(-)
Added: sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/adaptor.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/adaptor.hpp 2009-10-01 13:02:48 EDT (Thu, 01 Oct 2009)
@@ -0,0 +1,79 @@
+///////////////////////////////////////////////////////////////////////////////
+// ars::function::adaptor.hpp //
+// //
+// Copyright 2009 Erwann Rogard. Distributed under the Boost //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_STATISTICS_DETAIL_ARS_FUNCTION_ADAPTOR_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_ARS_FUNCTION_ADAPTOR_HPP_ER_2009
+#include <boost/type_traits.hpp>
+#include <boost/call_traits.hpp>
+#include <boost/statistics/detail/distribution_toolkit/unscope/log_unnormalized_pdf.hpp>
+#include <boost/statistics/detail/distribution_toolkit/unscope/derivative_log_unnormalized_pdf.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace ars{
+namespace function{
+
+// Adapts a distribution in sandbox/distribution_toolkit/distributions to the
+// required signature.
+template<typename D>
+class adaptor{
+
+ typedef typename remove_const<
+ typename remove_reference<
+ D
+ >::type
+ >::type dist_t;
+
+ public:
+ typedef typename dist_t::value_type value_type;
+ typedef typename dist_t::policy_type policy_type;
+ typedef adaptor<dist_t> base_type;
+
+ adaptor(typename call_traits<D>::param_type d):d_(d){}
+ adaptor(const adaptor& that):d_(that.d_){}
+
+ adaptor&
+ operator=(const adaptor& that){
+ if(&that!=this){
+ d_ = that.d_;
+ }
+ return *this;
+ }
+
+ void operator()(
+ const value_type& x,
+ value_type& log_pdf,
+ value_type& dlog_pdf
+ )const{
+ log_pdf = boost::log_unnormalized_pdf(
+ this->distribution(),
+ x
+ );
+
+ dlog_pdf = boost::derivative_log_unnormalized_pdf(
+ this->distribution(),
+ x
+ );
+ }
+
+ typename call_traits<D>::const_reference distribution()const{
+ return d_;
+ }
+
+ private:
+ typename call_traits<D>::value_type d_;
+
+};
+
+}
+}// ars
+}// detail
+}// statistics
+}// boost
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/concept.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/concept.hpp 2009-10-01 13:02:48 EDT (Thu, 01 Oct 2009)
@@ -0,0 +1,39 @@
+///////////////////////////////////////////////////////////////////////////////
+// ars::function::concept.hpp //
+// //
+// Copyright 2009 Erwann Rogard. Distributed under the Boost //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_STATISTICS_DETAIL_ARS_FUNCTION_CONCEPT_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_ARS_FUNCTION_CONCEPT_HPP_ER_2009
+#include <boost/concept_check.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace ars{
+namespace function{
+
+template<typename F,typename T>
+class concept{
+
+ BOOST_CONCEPT_USAGE((
+ f(x,log_pdf,dlog_pdf)
+ ));
+
+ private:
+ F f;
+ T x;
+ T log_pdf;
+ T dlog_pdf;
+
+};
+
+}
+}// ars
+}// detail
+}// statistics
+}// boost
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/signature.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/signature.hpp 2009-10-01 13:02:48 EDT (Thu, 01 Oct 2009)
@@ -0,0 +1,33 @@
+///////////////////////////////////////////////////////////////////////////////
+// ars::function::signature.hpp //
+// //
+// Copyright 2009 Erwann Rogard. Distributed under the Boost //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_STATISTICS_DETAIL_ARS_FUNCTION_SIGNATURE_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_ARS_FUNCTION_SIGNATURE_HPP_ER_2009
+#include <boost/mpl/identity.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace ars{
+namespace function{
+
+ // This is the function signature required by the ars sampler.
+ //
+ // Given input x, fun(x, y, dy) writes the log unnormalized pdf and its
+ // derivative at x to y and dy, respectively.
+ template<typename T>
+ struct signature : mpl::identity<
+ void(const T&,T&,T&)
+ >{};
+
+}// function
+}// ars
+}// detail
+}// statistics
+}// boost
+
+#endif
\ No newline at end of file
Modified: sandbox/statistics/adaptive_rejection_sampling/boost/ars/proposal_sampler.hpp
==============================================================================
--- sandbox/statistics/adaptive_rejection_sampling/boost/ars/proposal_sampler.hpp (original)
+++ sandbox/statistics/adaptive_rejection_sampling/boost/ars/proposal_sampler.hpp 2009-10-01 13:02:48 EDT (Thu, 01 Oct 2009)
@@ -40,7 +40,7 @@
#include <boost/ars/parameter.hpp>
#include <boost/ars/error.hpp>
#include <boost/ars/point.hpp>
-#include <boost/ars/function_signature.hpp>
+#include <boost/ars/function/signature.hpp>
#include <boost/ars/detail/data.hpp>
#include <boost/ars/detail/area.hpp>
@@ -79,8 +79,8 @@
typedef uniform_real<T> runif_t;
public:
- typedef typename ars::function_signature<T>::type function_signature;
- typedef function<function_signature> delegate_type;
+ typedef typename ars::function::signature<T>::type signature;
+ typedef boost::function<signature> delegate_type;
typedef typename range_size<datas_t>::type size_type;
typedef T result_type;
Modified: sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/standard_distribution.hpp
==============================================================================
--- sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/standard_distribution.hpp (original)
+++ sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/standard_distribution.hpp 2009-10-01 13:02:48 EDT (Thu, 01 Oct 2009)
@@ -29,7 +29,8 @@
#include <boost/random/normal_distribution.hpp>
#include <boost/random/ref_distribution.hpp>
-#include <boost/ars/functional/standard_distribution.hpp>
+//#include <boost/ars/functional/standard_distribution.hpp>
+#include <boost/ars/function/adaptor.hpp>
#include <boost/ars/constant.hpp>
#include <boost/ars/proposal_sampler.hpp>
#include <boost/ars/sampler.hpp>
@@ -71,7 +72,7 @@
typedef typename D::value_type val_;
typedef std::vector<val_> vals_;
- typedef ars::functional::standard_distribution<D> fun_t;
+ typedef ars::function::adaptor<D> fun_t;
typedef ars::proposal_sampler<val_,std::vector> ps_;
typedef ars::sampler<ps_> ars_;
typedef random::ref_distribution<ars_&> ref_ars_;
Modified: sandbox/statistics/adaptive_rejection_sampling/libs/ars/doc/readme.txt
==============================================================================
--- sandbox/statistics/adaptive_rejection_sampling/libs/ars/doc/readme.txt (original)
+++ sandbox/statistics/adaptive_rejection_sampling/libs/ars/doc/readme.txt 2009-10-01 13:02:48 EDT (Thu, 01 Oct 2009)
@@ -26,6 +26,7 @@
[ Dependencies ]
boost_1_39_0
+/sandbox/statistics/distribution_toolkit
[ History ]
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk