00001 // -*- C++ -*- 00002 #ifndef __LEMGA_PULSE_H__ 00003 #define __LEMGA_PULSE_H__ 00004 00011 #include <vector> 00012 #include "learnmodel.h" 00013 00014 namespace lemga { 00015 00019 class Pulse : public LearnModel { 00020 UINT idx; 00021 std::vector<REAL> th; 00022 bool dir; 00023 UINT max_l; 00024 00025 public: 00026 explicit Pulse (UINT n_in = 0) : LearnModel(n_in, 1), idx(0), max_l(1) {} 00027 explicit Pulse (std::istream& is) { is >> *this; } 00028 00029 virtual const id_t& id () const; 00030 virtual Pulse* create () const { return new Pulse(); } 00031 virtual Pulse* clone () const { return new Pulse(*this); } 00032 00034 UINT index () const { return idx; } 00036 void set_index (UINT i) { assert(i < n_input()); idx = i; } 00038 const std::vector<REAL>& threshold () const { return th; } 00040 void set_threshold (const std::vector<REAL>&); 00042 bool direction () const { return dir; } 00044 void set_direction (bool d) { dir = d; } 00046 UINT max_transitions () { return max_l; } 00048 void set_max_transitions (UINT ml) { max_l = ml; } 00049 // TODO: resize th? 00050 00051 virtual bool support_weighted_data () const { return true; } 00052 00053 virtual REAL train (); 00054 00055 virtual Output operator() (const Input&) const; 00056 00057 protected: 00058 virtual bool serialize (std::ostream&, ver_list&) const; 00059 virtual bool unserialize (std::istream&, ver_list&, 00060 const id_t& = empty_id); 00061 }; 00062 00063 } // namespace lemga 00064 00065 #ifdef __PULSE_H__ 00066 #warning "This header file may conflict with another `pulse.h' file." 00067 #endif 00068 #define __PULSE_H__ 00069 #endif