core/vnl/vnl_sparse_matrix_linear_system.h
Go to the documentation of this file.
00001 // This is core/vnl/vnl_sparse_matrix_linear_system.h
00002 #ifndef vnl_sparse_matrix_linear_system_h_
00003 #define vnl_sparse_matrix_linear_system_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 //  \file
00009 //  \brief vnl_sparse_matrix -> vnl_linear_system adaptor
00010 //
00011 //  An adaptor that converts a vnl_sparse_matrix<T> to a vnl_linear_system
00012 //
00013 //  \author David Capel, capes@robots
00014 //  \date   July 2000
00015 //
00016 // \verbatim
00017 //  Modifications
00018 //  LSB (Manchester) 19/3/01 Documentation tidied
00019 // \endverbatim
00020 //
00021 //-----------------------------------------------------------------------------
00022 
00023 #include <vnl/vnl_linear_system.h>
00024 #include <vnl/vnl_sparse_matrix.h>
00025 
00026 //: vnl_sparse_matrix -> vnl_linear_system adaptor
00027 //  An adaptor that converts a vnl_sparse_matrix<T> to a vnl_linear_system
00028 template <class T>
00029 class vnl_sparse_matrix_linear_system : public vnl_linear_system
00030 {
00031  public:
00032   //::Constructor from vnl_sparse_matrix<double> for system Ax = b
00033   // Keeps a reference to the original sparse matrix A and vector b so DO NOT DELETE THEM!!
00034   vnl_sparse_matrix_linear_system(vnl_sparse_matrix<T> const& A, vnl_vector<T> const& b) :
00035     vnl_linear_system(A.columns(), A.rows()), A_(A), b_(b), jacobi_precond_() {}
00036 
00037   //:  Implementations of the vnl_linear_system virtuals.
00038   void multiply(vnl_vector<double> const& x, vnl_vector<double> & b) const;
00039   //:  Implementations of the vnl_linear_system virtuals.
00040   void transpose_multiply(vnl_vector<double> const& b, vnl_vector<double> & x) const;
00041   //:  Implementations of the vnl_linear_system virtuals.
00042   void get_rhs(vnl_vector<double>& b) const;
00043   //:  Implementations of the vnl_linear_system virtuals.
00044   void apply_preconditioner(vnl_vector<double> const& x, vnl_vector<double> & px) const;
00045 
00046  protected:
00047   vnl_sparse_matrix<T> const& A_;
00048   vnl_vector<T> const& b_;
00049   vnl_vector<double> jacobi_precond_;
00050 };
00051 
00052 #if !defined(VCL_VC_7)
00053 VCL_DEFINE_SPECIALIZATION
00054 void vnl_sparse_matrix_linear_system<double>::get_rhs(vnl_vector<double>& b) const;
00055 VCL_DEFINE_SPECIALIZATION
00056 void vnl_sparse_matrix_linear_system<double>::transpose_multiply(vnl_vector<double> const& b, vnl_vector<double> & x) const;
00057 VCL_DEFINE_SPECIALIZATION
00058 void vnl_sparse_matrix_linear_system<float>::get_rhs(vnl_vector<double>& b) const;
00059 VCL_DEFINE_SPECIALIZATION
00060 void vnl_sparse_matrix_linear_system<float>::transpose_multiply(vnl_vector<double> const& b, vnl_vector<double> & x) const;
00061 VCL_DEFINE_SPECIALIZATION
00062 void vnl_sparse_matrix_linear_system<double>::multiply(vnl_vector<double> const& x, vnl_vector<double> & b) const;
00063 VCL_DEFINE_SPECIALIZATION
00064 void vnl_sparse_matrix_linear_system<float>::multiply(vnl_vector<double> const& x, vnl_vector<double> & b) const;
00065 #endif
00066 
00067 #endif // vnl_sparse_matrix_linear_system_h_