00001 #ifndef vnl_sparse_matrix_linear_system_h_ 00002 #define vnl_sparse_matrix_linear_system_h_ 00003 // This is vxl/vnl/vnl_sparse_matrix_linear_system.h 00004 00005 //: \file 00006 // \brief vnl_sparse_matrix -> vnl_linear_system adaptor 00007 // \author David Capel, capes@robots, July 2000 00008 // An adaptor that converts a vnl_sparse_matrix<T> to a vnl_linear_system 00009 // 00010 00011 // Modifications 00012 // LSB (Manchester) 19/3/01 Documentation tidied 00013 // 00014 //----------------------------------------------------------------------------- 00015 00016 #include <vnl/vnl_linear_system.h> 00017 #include <vnl/vnl_sparse_matrix.h> 00018 00019 //: vnl_sparse_matrix -> vnl_linear_system adaptor 00020 // An adaptor that converts a vnl_sparse_matrix<T> to a vnl_linear_system 00021 template <class T> 00022 class vnl_sparse_matrix_linear_system : public vnl_linear_system { 00023 public: 00024 //::Constructor from vnl_sparse_matrix<double> for system Ax = b 00025 // Keeps a reference to the original sparse matrix A and vector b so DO NOT DELETE THEM!! 00026 vnl_sparse_matrix_linear_system(vnl_sparse_matrix<T> const& A, vnl_vector<T> const& b) : 00027 vnl_linear_system(A.columns(), A.rows()), A_(A), b_(b) {} 00028 00029 //: Implementations of the vnl_linear_system virtuals. 00030 void multiply(vnl_vector<double> const& x, vnl_vector<double> & b) const; 00031 //: Implementations of the vnl_linear_system virtuals. 00032 void transpose_multiply(vnl_vector<double> const& b, vnl_vector<double> & x) const; 00033 //: Implementations of the vnl_linear_system virtuals. 00034 void get_rhs(vnl_vector<double>& b) const; 00035 //: Implementations of the vnl_linear_system virtuals. 00036 void apply_preconditioner(vnl_vector<double> const& x, vnl_vector<double> & px) const; 00037 00038 protected: 00039 vnl_sparse_matrix<T> const& A_; 00040 vnl_vector<T> const& b_; 00041 vnl_vector<double> jacobi_precond_; 00042 }; 00043 00044 #endif // vnl_sparse_matrix_linear_system_h_