jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
jubatus::core::burst::intersection_helper Class Reference

#include <window_intersection.hpp>

Collaboration diagram for jubatus::core::burst::intersection_helper:
Collaboration graph

Public Member Functions

int adjust_index (int index) const
 
int get_index_ (double pos) const
 
int get_index_for_boundary (double boundary_pos) const
 
template<class Window >
std::pair< int, int > get_intersection (const Window &w) const
 
bool has_batch_interval_equals_to (double interval1) const
 
 intersection_helper (double start_pos=0, double batch_interval=1, int batch_size=0)
 
template<class Window >
 intersection_helper (const Window &w)
 
bool position_near (double pos0, double pos1) const
 

Static Public Member Functions

static int no_index ()
 

Private Attributes

double batch_interval_
 
int batch_size_
 
double start_pos_
 

Detailed Description

Definition at line 40 of file window_intersection.hpp.

Constructor & Destructor Documentation

jubatus::core::burst::intersection_helper::intersection_helper ( double  start_pos = 0,
double  batch_interval = 1,
int  batch_size = 0 
)
inlineexplicit
template<class Window >
jubatus::core::burst::intersection_helper::intersection_helper ( const Window &  w)
inlineexplicit

Definition at line 51 of file window_intersection.hpp.

52  : start_pos_(w.get_start_pos()),
53  batch_interval_(w.get_batch_interval()),
54  batch_size_(w.get_batch_size()) {
55  }

Member Function Documentation

int jubatus::core::burst::intersection_helper::adjust_index ( int  index) const
inline

Definition at line 97 of file window_intersection.hpp.

References batch_size_.

Referenced by get_intersection().

97  {
98  if (index < 0) {
99  return 0;
100  } else if (index > batch_size_) {
101  return batch_size_;
102  } else {
103  return index;
104  }
105  }

Here is the caller graph for this function:

int jubatus::core::burst::intersection_helper::get_index_ ( double  pos) const
inline

Definition at line 107 of file window_intersection.hpp.

References batch_interval_, and start_pos_.

Referenced by get_index_for_boundary().

107  {
108  return static_cast<int>(std::floor((pos - start_pos_) / batch_interval_));
109  }

Here is the caller graph for this function:

int jubatus::core::burst::intersection_helper::get_index_for_boundary ( double  boundary_pos) const
inline

Definition at line 73 of file window_intersection.hpp.

References batch_interval_, get_index_(), no_index(), position_near(), and start_pos_.

Referenced by get_intersection().

73  {
74  int candidate = get_index_(boundary_pos + batch_interval_/2);
75  double candidate_pos = start_pos_ + candidate * batch_interval_;
76  if (!position_near(boundary_pos, candidate_pos)) {
77  return no_index();
78  }
79  return candidate;
80  }
bool position_near(double pos0, double pos1) const

Here is the call graph for this function:

Here is the caller graph for this function:

template<class Window >
std::pair<int, int> jubatus::core::burst::intersection_helper::get_intersection ( const Window &  w) const
inline

Definition at line 58 of file window_intersection.hpp.

References adjust_index(), get_index_for_boundary(), has_batch_interval_equals_to(), and no_index().

Referenced by jubatus::core::burst::get_intersection().

58  {
59  int begin = get_index_for_boundary(w.get_start_pos());
60  int end = get_index_for_boundary(w.get_end_pos());
61 
62  if (begin == no_index() ||
63  end == no_index() ||
64  !has_batch_interval_equals_to(w.get_batch_interval())) {
65  // nonsense data is given (should throw an exception?)
66  return std::make_pair(no_index(), no_index());
67  }
68 
69  return std::make_pair(adjust_index(begin),
70  adjust_index(end));
71  }
int get_index_for_boundary(double boundary_pos) const
bool has_batch_interval_equals_to(double interval1) const

Here is the call graph for this function:

Here is the caller graph for this function:

bool jubatus::core::burst::intersection_helper::has_batch_interval_equals_to ( double  interval1) const
inline

Definition at line 91 of file window_intersection.hpp.

References batch_interval_, batch_size_, and position_near().

Referenced by get_intersection(), and jubatus::core::burst::burst_result::has_same_batch_interval().

91  {
92  // comparing end_pos
93  size_t n = (std::max)(batch_size_, 1);
94  return position_near(n * interval1, n * batch_interval_);
95  }
bool position_near(double pos0, double pos1) const

Here is the call graph for this function:

Here is the caller graph for this function:

static int jubatus::core::burst::intersection_helper::no_index ( )
inlinestatic

Definition at line 83 of file window_intersection.hpp.

Referenced by get_index_for_boundary(), and get_intersection().

83  { // constexpr is needed
84  return std::numeric_limits<int>::min();
85  }

Here is the caller graph for this function:

bool jubatus::core::burst::intersection_helper::position_near ( double  pos0,
double  pos1 
) const
inline

Definition at line 87 of file window_intersection.hpp.

References batch_interval_, and jubatus::core::burst::window_position_near().

Referenced by get_index_for_boundary(), and has_batch_interval_equals_to().

87  {
88  return window_position_near(pos0, pos1, batch_interval_);
89  }
bool window_position_near(double pos0, double pos1, double batch_interval)

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

double jubatus::core::burst::intersection_helper::batch_interval_
private
int jubatus::core::burst::intersection_helper::batch_size_
private

Definition at line 114 of file window_intersection.hpp.

Referenced by adjust_index(), and has_batch_interval_equals_to().

double jubatus::core::burst::intersection_helper::start_pos_
private

Definition at line 112 of file window_intersection.hpp.

Referenced by get_index_(), and get_index_for_boundary().


The documentation for this class was generated from the following file: