Go to the documentation of this file.00001
00002 #ifndef vnl_sparse_lm_h_
00003 #define vnl_sparse_lm_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <vcl_iosfwd.h>
00020 #include <vcl_vector.h>
00021 #include <vnl/vnl_vector.h>
00022 #include <vnl/vnl_matrix.h>
00023 #include <vnl/vnl_nonlinear_minimizer.h>
00024
00025 class vnl_sparse_lst_sqr_function;
00026
00027
00028
00029
00030
00031
00032
00033 class vnl_sparse_lm : public vnl_nonlinear_minimizer
00034 {
00035 public:
00036
00037
00038 vnl_sparse_lm(vnl_sparse_lst_sqr_function& f);
00039
00040
00041 ~vnl_sparse_lm();
00042
00043
00044
00045
00046
00047
00048
00049
00050 bool minimize(vnl_vector<double>& a,
00051 vnl_vector<double>& b,
00052 vnl_vector<double>& c,
00053 bool use_gradient = true,
00054 bool use_weights = true);
00055
00056
00057
00058
00059 void diagnose_outcome() const;
00060 void diagnose_outcome(vcl_ostream&) const;
00061
00062
00063
00064 vnl_matrix<double> const& get_JtJ();
00065
00066
00067 const vnl_vector<double>& get_weights() const { return weights_; }
00068
00069 protected:
00070
00071
00072 double tau_;
00073
00074 vnl_sparse_lst_sqr_function* f_;
00075
00076 vnl_matrix<double> inv_covar_;
00077 bool set_covariance_;
00078
00079 void init(vnl_sparse_lst_sqr_function* f);
00080
00081 private:
00082
00083
00084 void allocate_matrices();
00085
00086
00087 bool check_vector_sizes(vnl_vector<double> const& a,
00088 vnl_vector<double> const& b,
00089 vnl_vector<double> const& c);
00090
00091
00092 void compute_normal_equations();
00093
00094
00095 vnl_vector<double> extract_diagonal() const;
00096
00097
00098 void set_diagonal(const vnl_vector<double>& diag);
00099
00100
00101 void compute_invV_Y();
00102
00103
00104 void compute_Z_Sa(vnl_matrix<double>& Sa);
00105
00106
00107 void compute_Ma(const vnl_matrix<double>& H);
00108
00109
00110 void compute_Mb();
00111
00112
00113 void solve_dc(vnl_vector<double>& dc);
00114
00115
00116 void compute_sea(vnl_vector<double> const& dc,
00117 vnl_vector<double>& sea);
00118
00119
00120
00121 void compute_Sa_sea(vnl_matrix<double>& Sa, vnl_vector<double>& sea);
00122
00123
00124 void backsolve_db(vnl_vector<double> const& da,
00125 vnl_vector<double> const& dc,
00126 vnl_vector<double>& db);
00127
00128 const int num_a_;
00129 const int num_b_;
00130 const int num_e_;
00131 const int num_nz_;
00132
00133 const int size_a_;
00134 const int size_b_;
00135 const int size_c_;
00136 const int size_e_;
00137
00138
00139 vcl_vector<vnl_matrix<double> > A_;
00140 vcl_vector<vnl_matrix<double> > B_;
00141 vcl_vector<vnl_matrix<double> > C_;
00142
00143
00144
00145 vcl_vector<vnl_matrix<double> > U_;
00146 vcl_vector<vnl_matrix<double> > V_;
00147 vnl_matrix<double> T_;
00148
00149 vcl_vector<vnl_matrix<double> > W_;
00150 vcl_vector<vnl_matrix<double> > R_;
00151 vcl_vector<vnl_matrix<double> > Q_;
00152
00153 vnl_vector<double> ea_;
00154 vnl_vector<double> eb_;
00155 vnl_vector<double> ec_;
00156
00157
00158 vnl_vector<double> e_;
00159
00160
00161 vnl_vector<double> weights_;
00162
00163
00164 vcl_vector<vnl_matrix<double> > inv_V_;
00165 vcl_vector<vnl_matrix<double> > Y_;
00166 vcl_vector<vnl_matrix<double> > Z_;
00167 vcl_vector<vnl_matrix<double> > Ma_;
00168 vcl_vector<vnl_matrix<double> > Mb_;
00169
00170 };
00171
00172
00173 #endif // vnl_sparse_lm_h_