contrib/mul/mbl/mbl_ar_process.h
Go to the documentation of this file.
00001 // This is mul/mbl/mbl_ar_process.h
00002 #ifndef mbl_ar_process_h_
00003 #define mbl_ar_process_h_
00004 //:
00005 // \file
00006 // \brief Compute the parameters of a second order autoregressive process.
00007 // \author Franck Bettinger
00008 
00009 #include <vnl/vnl_matrix.h>
00010 #include <vnl/vnl_vector.h>
00011 #include <vsl/vsl_binary_io.h>
00012 
00013 #include <vcl_vector.h>
00014 #include <vcl_string.h>
00015 #include <vcl_iosfwd.h>
00016 
00017 class vnl_random;
00018 
00019 //: Compute the parameters of a second order autoregressive process.
00020 template<class T>
00021 class mbl_ar_process
00022 {
00023   vnl_matrix<T> A_2,A_1,B_0;
00024   vnl_vector<T> Xm; // mean
00025 
00026  public:
00027 
00028   //: Constructor
00029   mbl_ar_process();
00030 
00031   //: Destructor
00032   ~mbl_ar_process();
00033 
00034   //: Version number for I/O
00035   short version_no() const;
00036 
00037   //: Name of the class
00038   vcl_string is_a() const;
00039 
00040   //: Does the name of the class match the argument?
00041   bool is_class(vcl_string const& s) const;
00042 
00043   //: Print class to os
00044   void print_summary(vcl_ostream& os) const;
00045 
00046   //: Save class to binary file stream
00047   void b_write(vsl_b_ostream& bfs) const;
00048 
00049   //: Load class from binary file stream
00050   void b_read(vsl_b_istream& bfs);
00051 
00052   //: Dynamic learning
00053   void learn(vcl_vector<vnl_vector<T> >& data);
00054 
00055   //: Learning using Burg's algorithm
00056   void learn_burg(vcl_vector<vnl_vector<T> >& data);
00057 
00058   //: Prediction
00059   // of a vector given the two previous vectors
00060   // \param rng Use an externally provided random number generator,
00061   // rather than one statically local to the function.
00062   vnl_vector<T> predict(vnl_vector<T>& Xm1, vnl_vector<T>& Xm2, vnl_random *rng=0);
00063 };
00064 
00065 //: Write  to binary stream
00066 template<class T>
00067 void vsl_b_write(vsl_b_ostream& s, const mbl_ar_process<T>* p);
00068 
00069 //: Read data from binary stream
00070 template<class T>
00071 void vsl_b_read(vsl_b_istream& s, mbl_ar_process<T>* & v);
00072 
00073 //: Print class to os
00074 template<class T>
00075 void vsl_print_summary(vcl_ostream& os, const mbl_ar_process<T>* p);
00076 
00077 #endif // mbl_ar_process_h_