Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57318 - sandbox/statistics/detail/math/boost/statistics/detail/math/function
From: erwann.rogard_at_[hidden]
Date: 2009-11-03 11:35:40


Author: e_r
Date: 2009-11-03 11:35:39 EST (Tue, 03 Nov 2009)
New Revision: 57318
URL: http://svn.boost.org/trac/boost/changeset/57318

Log:
m/a
Added:
   sandbox/statistics/detail/math/boost/statistics/detail/math/function/log_shift.hpp (contents, props changed)
   sandbox/statistics/detail/math/boost/statistics/detail/math/function/logit.hpp (contents, props changed)
   sandbox/statistics/detail/math/boost/statistics/detail/math/function/logit_shift.hpp (contents, props changed)
Text files modified:
   sandbox/statistics/detail/math/boost/statistics/detail/math/function/versatile_equal.hpp | 28 ++++++++++++----------------
   1 files changed, 12 insertions(+), 16 deletions(-)

Added: sandbox/statistics/detail/math/boost/statistics/detail/math/function/log_shift.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/math/boost/statistics/detail/math/function/log_shift.hpp 2009-11-03 11:35:39 EST (Tue, 03 Nov 2009)
@@ -0,0 +1,26 @@
+///////////////////////////////////////////////////////////////////////////////
+// math::log_shift.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_MATH_FUNCTION_LOG_SHIFT_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_MATH_FUNCTION_LOG_SHIFT_HPP_ER_2009
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace math{
+
+ template<typename T>
+ T log_shift(const T& x,const T& t){
+ return log(x+t);
+ }
+
+}// math
+}// detail
+}// statistics
+}// boost
+
+#endif
\ No newline at end of file

Added: sandbox/statistics/detail/math/boost/statistics/detail/math/function/logit.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/math/boost/statistics/detail/math/function/logit.hpp 2009-11-03 11:35:39 EST (Tue, 03 Nov 2009)
@@ -0,0 +1,29 @@
+///////////////////////////////////////////////////////////////////////////////
+// math::logit_shift.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_MATH_FUNCTION_LOGIT_SHIFT_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_MATH_FUNCTION_LOGIT_SHIFT_HPP_ER_2009
+#include <boost/statistics/detail/math/function/logit_shift.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace math{
+
+ template<typename T>
+ T logit(
+ const T& p
+ ){
+ return logit_shift(p,static_cast<T>(0));
+ }
+
+}
+}
+}
+}
+
+#endif
\ No newline at end of file

Added: sandbox/statistics/detail/math/boost/statistics/detail/math/function/logit_shift.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/math/boost/statistics/detail/math/function/logit_shift.hpp 2009-11-03 11:35:39 EST (Tue, 03 Nov 2009)
@@ -0,0 +1,30 @@
+///////////////////////////////////////////////////////////////////////////////
+// math::logit_shift.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_MATH_FUNCTION_LOGIT_SHIFT_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_MATH_FUNCTION_LOGIT_SHIFT_HPP_ER_2009
+#include <boost/statistics/detail/math/function/log_shift.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace math{
+
+ // The t>0 is an adjustment which preventsa numerical error at p = 0 and
+ // p = 1 causes numerical error
+ template<typename T>
+ T logit_shift(const T& p,const T& t){
+ // log(p/(1-p)) = log(p)-log(1-p)
+ return log_shift(p,t) - boost::math::log1p(t - p);
+ }
+
+}// math
+}// detail
+}// statistics
+}// boost
+
+#endif
\ No newline at end of file

Modified: sandbox/statistics/detail/math/boost/statistics/detail/math/function/versatile_equal.hpp
==============================================================================
--- sandbox/statistics/detail/math/boost/statistics/detail/math/function/versatile_equal.hpp (original)
+++ sandbox/statistics/detail/math/boost/statistics/detail/math/function/versatile_equal.hpp 2009-11-03 11:35:39 EST (Tue, 03 Nov 2009)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// math::versatile_equal.hpp //
+// math::function::versatile_equal.hpp //
 // //
 // Copyright 2009 Erwann Rogard. Distributed under the Boost //
 // Software License, Version 1.0. (See accompanying file //
@@ -8,9 +8,9 @@
 #ifndef BOOST_STATISTICS_DETAIL_MATH_FUNCTION_VERSATILE_EQUAL_HPP_ER_2009
 #define BOOST_STATISTICS_DETAIL_MATH_FUNCTION_VERSATILE_EQUAL_HPP_ER_2009
 #include <cmath>
-#include <boost/utility/enable_if.hpp>
 #include <boost/type_traits/is_float.hpp>
 #include <boost/type_traits/is_integral.hpp>
+#include <boost/utility/enable_if.hpp>
 #include <boost/math/tools/precision.hpp>
 
 namespace boost{
@@ -20,24 +20,20 @@
 namespace function{
 
     template<typename T>
- typename boost::enable_if<
- typename is_float<T>::type,
- bool
- >::type
- versatile_equal(const T& a,const T& b){
- static T eps = boost::math::tools::epsilon<T>();
- return fabs(a-b)<eps;
- }
+ typename boost::enable_if<boost::is_float<T>,bool>::type
+ versatile_equal(const T& t1,const T& t2)
+ {
+ static const T eps = boost::math::tools::epsilon<T>();
+ return std::fabs(t1-t2)<eps;
+ } // warning: consider relative difference
 
     template<typename T>
- typename enable_if<
- typename is_integral<T>::type,
- bool
- >::type
- versatile_equal(const T& a,const T& b){
- return (a == b);
+ typename boost::enable_if<boost::is_integral<T>,bool>::type
+ versatile_equal(const T& t1,const T& t2){
+ return (t1 == t2);
     }
 
+
 }// function
 }// math
 }// detail


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