|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55746 - in sandbox/statistics/survival_data: boost/survival/data/algorithm boost/survival/data/algorithm/detail boost/survival/data/data libs/survival/data/example libs/survival/data/src
From: erwann.rogard_at_[hidden]
Date: 2009-08-23 20:46:32
Author: e_r
Date: 2009-08-23 20:46:31 EDT (Sun, 23 Aug 2009)
New Revision: 55746
URL: http://svn.boost.org/trac/boost/changeset/55746
Log:
sd update
Text files modified:
sandbox/statistics/survival_data/boost/survival/data/algorithm/detail/log_shift.hpp | 2
sandbox/statistics/survival_data/boost/survival/data/algorithm/logit_log.hpp | 4 +-
sandbox/statistics/survival_data/boost/survival/data/data/event.hpp | 2
sandbox/statistics/survival_data/boost/survival/data/data/mean_event.hpp | 43 +++++++++++++++++++++++++++++----------
sandbox/statistics/survival_data/libs/survival/data/example/data.cpp | 39 +++++++++++++++++------------------
sandbox/statistics/survival_data/libs/survival/data/src/main.cpp | 2
6 files changed, 56 insertions(+), 36 deletions(-)
Modified: sandbox/statistics/survival_data/boost/survival/data/algorithm/detail/log_shift.hpp
==============================================================================
--- sandbox/statistics/survival_data/boost/survival/data/algorithm/detail/log_shift.hpp (original)
+++ sandbox/statistics/survival_data/boost/survival/data/algorithm/detail/log_shift.hpp 2009-08-23 20:46:31 EDT (Sun, 23 Aug 2009)
@@ -6,7 +6,7 @@
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_SURVIVAL_DATA_ALGORITHM_DETAIL_LOG_SHIFT_HPP_ER_2009
-#define BOOST_SURVIVAL_DATA_ALGORITHM_LOG_SHIFT_HPP_ER_2009
+#define BOOST_SURVIVAL_DATA_ALGORITHM_DETAIL_LOG_SHIFT_HPP_ER_2009
#include <boost/math/special_functions/log1p.hpp>
namespace boost{
Modified: sandbox/statistics/survival_data/boost/survival/data/algorithm/logit_log.hpp
==============================================================================
--- sandbox/statistics/survival_data/boost/survival/data/algorithm/logit_log.hpp (original)
+++ sandbox/statistics/survival_data/boost/survival/data/algorithm/logit_log.hpp 2009-08-23 20:46:31 EDT (Sun, 23 Aug 2009)
@@ -35,8 +35,8 @@
throw std::runtime_error(f.str());
}
while(b!=e){
- (*o) = detail::logit_shift((*b),t0); ++b;
- (*o) = detail::log_shift((*b),t1); ++b;
+ (*o++) = detail::logit_shift((*b++),t0);
+ (*o++) = detail::log_shift((*b++),t1);
}
return o;
}
Modified: sandbox/statistics/survival_data/boost/survival/data/data/event.hpp
==============================================================================
--- sandbox/statistics/survival_data/boost/survival/data/data/event.hpp (original)
+++ sandbox/statistics/survival_data/boost/survival/data/data/event.hpp 2009-08-23 20:46:31 EDT (Sun, 23 Aug 2009)
@@ -31,7 +31,7 @@
typedef T value_type;
typedef B failure_type;
// Construction
- event();
+ event(); // (f = false, t = infinity)
explicit event(B isf,value_type rt);
event(const event&);
event& operator=(const event&);
Modified: sandbox/statistics/survival_data/boost/survival/data/data/mean_event.hpp
==============================================================================
--- sandbox/statistics/survival_data/boost/survival/data/data/mean_event.hpp (original)
+++ sandbox/statistics/survival_data/boost/survival/data/data/mean_event.hpp 2009-08-23 20:46:31 EDT (Sun, 23 Aug 2009)
@@ -7,6 +7,7 @@
///////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_SURVIVAL_DATA_DATA_MEAN_EVENT_HPP_ER_2009
#define BOOST_SURVIVAL_DATA_DATA_MEAN_EVENT_HPP_ER_2009
+#include <stdexcept>
#include <boost/type_traits.hpp>
#include <boost/range.hpp>
#include <boost/format.hpp>
@@ -14,6 +15,7 @@
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/survival/constant.hpp>
+#include <boost/math/special_functions/fpclassify.hpp>
namespace boost{
namespace survival{
@@ -39,7 +41,10 @@
template<typename T,typename B = bool>
class mean_event :
public event<T,T>,
- boost::addable<mean_event<T,B>, addable<event<T,B> > >
+ boost::addable<
+ mean_event<T,B>,
+ addable<event<T,B> >
+ >
// TODO equality_comparable<mean_event<T,B> >
{
public:
@@ -58,12 +63,12 @@
size_type count()const;
// Operators
- mean_event& operator+=(const mean_event& e);
- mean_event& operator+=(const event_& e);
- mean_event& operator()(const event_& e); //same as +=
+ mean_event& operator+=( const mean_event& e );
+ mean_event& operator+=( const event_& e );
+ mean_event& operator()( const event_& e ); //same as +=
// I/O
- template<class Archive>
+ template<class Archive>
void serialize(Archive & ar, const unsigned int version);
private:
@@ -86,10 +91,22 @@
// Constructor
template<typename T,typename B>
- mean_event<T,B>::mean_event():super_(),count_(0){}
+ mean_event<T,B>::mean_event()
+ :super_(static_cast<T>(false),static_cast<T>(0)),
+ count_(0){
+ // Using super_() instead, would initialize time to inf.
+ }
template<typename T,typename B>
- mean_event<T,B>::mean_event(const event_& e):super_(convert(e)),count_(1){}
+ mean_event<T,B>::mean_event(const event_& e)
+ :super_(convert(e)),count_(1){
+ const char* msg = "mean_event::mean_event(e), isinf(e.time())";
+ if(math::isinf(this->time())){
+ throw std::runtime_error(
+ msg
+ );
+ }
+ }
template<typename T,typename B>
mean_event<T,B>::mean_event(const mean_event& that)
@@ -99,7 +116,7 @@
mean_event<T,B>&
mean_event<T,B>::operator=(const mean_event& that){
if(&that!=this){
- super_::operator=(that);
+ super_::operator=( that );
count_ = that.count_;
}
return *this;
@@ -149,7 +166,11 @@
template<typename T,typename B>
typename mean_event<T,B>::value_type
mean_event<T,B>::impl(
- size_type n_a,value_type a,size_type n_b,value_type b){
+ size_type n_a,
+ value_type a,
+ size_type n_b,
+ value_type b
+ ){
return ( (n_a * a) + (n_b * b) ) / (n_a + n_b);
}
@@ -171,9 +192,9 @@
static value_type one = static_cast<value_type>(1);
value_type t = e.time();
if(e.failure()){
- return super_(one,t);
+ return super_( one, t );
}else{
- return super_(zero,t);
+ return super_( zero, t );
}
}
Modified: sandbox/statistics/survival_data/libs/survival/data/example/data.cpp
==============================================================================
--- sandbox/statistics/survival_data/libs/survival/data/example/data.cpp (original)
+++ sandbox/statistics/survival_data/libs/survival/data/example/data.cpp 2009-08-23 20:46:31 EDT (Sun, 23 Aug 2009)
@@ -34,19 +34,19 @@
// Statistics
using namespace boost;
- namespace surv = survival::data;
+ namespace surv = survival;
// [ Types ]
typedef unsigned val_; // do not modify
typedef std::vector<val_> vals_;
// Records
- typedef surv::record<val_> record_;
+ typedef surv::data::record<val_> record_;
typedef std::vector<record_> records_;
typedef range_iterator<records_>::type it_record_;
// Events
- typedef surv::event<val_> event_;
+ typedef surv::data::event<val_> event_;
typedef std::vector<event_> events_;
typedef range_iterator<events_>::type it_event_;
@@ -61,9 +61,9 @@
typedef range_cycle_::apply<r_x_>::type x_cycle_;
// Statistics
- typedef surv::mean_event<val_> me_;
+ typedef surv::data::mean_event<val_> me_;
typedef std::vector<me_> mes_;
- typedef surv::mean_events_by_covariate<val_,x_> mes_by_x_;
+ typedef surv::data::mean_events_by_covariate<val_,x_> mes_by_x_;
// [ Constants ]
const unsigned n_record = 4;
@@ -86,7 +86,7 @@
// [ Events ]
- surv::events(
+ surv::data::events(
begin(records),
end(records),
entry_bound,
@@ -187,31 +187,30 @@
out << "mean_events : ";
std::copy(
- boost::begin(mes),
- boost::end(mes),
+ boost::begin( mes ),
+ boost::end( mes ),
std::ostream_iterator<me_>(out," ")
);
vals_ flat_mes;
- surv::vectorize_events(
- boost::begin(mes),
- boost::end(mes),
- std::back_inserter(flat_mes)
+ surv::data::vectorize_events(
+ boost::begin( mes ),
+ boost::end( mes ),
+ std::back_inserter( flat_mes )
);
out << "flattened mean_events : ";
std::copy(
- boost::begin(flat_mes),
- boost::end(flat_mes),
+ boost::begin( flat_mes ),
+ boost::end( flat_mes ),
std::ostream_iterator<val_>(out," ")
);
-// TODO put elsewhere in example/
-// Dont try this here because val_ = unsigned, but you get the idea
-// surv::algorithm::logit_log(
-// boost::begin(flat_mean_events),
-// boost::end(flat_mean_events),
-// std::back_inserter(flat_mean_events),
+// // Dont try this here because val_ = unsigned, but you get the idea
+// surv::data::logit_log(
+// boost::begin(flat_mes),
+// boost::end(flat_mes),
+// std::back_inserter(flat_mes),
// 0.01,
// 0.01
// );
Modified: sandbox/statistics/survival_data/libs/survival/data/src/main.cpp
==============================================================================
--- sandbox/statistics/survival_data/libs/survival/data/src/main.cpp (original)
+++ sandbox/statistics/survival_data/libs/survival/data/src/main.cpp 2009-08-23 20:46:31 EDT (Sun, 23 Aug 2009)
@@ -13,7 +13,7 @@
int main(){
example_data(std::cout);
- example_random(std::cout);
+ //example_random(std::cout);
return 0;
}
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