00001
00002
00003 #ifndef JMATH_LINEAR_LEAST_SQUARES_HPP
00004 #define JMATH_LINEAR_LEAST_SQUARES_HPP
00005
00006 #include "jafarConfig.h"
00007
00008 #ifdef HAVE_BOOST_SANDBOX
00009 #ifdef HAVE_LAPACK
00010
00011 #include "jmath/jblas.hpp"
00012
00013 namespace jafar {
00014 namespace jmath {
00015
00028 class LinearLeastSquares {
00029
00030 private:
00031
00032 std::size_t m_sizeModel;
00033 std::size_t m_sizeDataSet;
00034
00036 jblas::mat_column_major m_A;
00037
00039 jblas::vec m_b;
00040
00042 jblas::vec m_x;
00043
00045 jblas::sym_mat m_xCov;
00046
00047 public:
00048
00049 LinearLeastSquares() {};
00050
00051 std::size_t sizeModel() const {return m_sizeModel;}
00052 std::size_t sizeDataSet() const {return m_sizeDataSet;}
00053
00054 jblas::mat_column_major const& A() const {return m_A;}
00055 jblas::mat_column_major& A() {return m_A;}
00056
00057 jblas::vec const& b() const {return m_b;}
00058 jblas::vec& b() {return m_b;}
00059
00060 jblas::vec const& x() const {return m_x;}
00061 jblas::sym_mat const& xCov() const {return m_xCov;}
00062
00064 void setSize(std::size_t sizeModel, std::size_t sizeDataSet, bool preserve=false);
00066 void setDataSetSize(std::size_t sizeDataSet, bool preserve=false);
00067
00071 void setData(std::size_t index, jblas::vec const& A_row, double b_val);
00072
00076 void setData(std::size_t index, jblas::vec const& A_row, double b_val, double weight);
00077
00078 void solve();
00079
00080 };
00081
00082 }
00083 }
00084
00085
00086 #endif // HAVE_LAPACK
00087 #endif // HAVE_BOOST_SANDBOX
00088
00089 #endif // JMATH_LINEAR_LEAST_SQUARES_HPP