vnl_sparse_matrix_linear_system.h
Go to the documentation of this file.
1 // This is core/vnl/vnl_sparse_matrix_linear_system.h
2 #ifndef vnl_sparse_matrix_linear_system_h_
3 #define vnl_sparse_matrix_linear_system_h_
4 //:
5 // \file
6 // \brief vnl_sparse_matrix -> vnl_linear_system adaptor
7 //
8 // An adaptor that converts a vnl_sparse_matrix<T> to a vnl_linear_system
9 //
10 // \author David Capel, capes@robots
11 // \date July 2000
12 //
13 // \verbatim
14 // Modifications
15 // LSB (Manchester) 19/3/01 Documentation tidied
16 // \endverbatim
17 //
18 //-----------------------------------------------------------------------------
19 
20 #include <vnl/vnl_linear_system.h>
21 #include <vnl/vnl_sparse_matrix.h>
22 #include "vnl/vnl_export.h"
23 
24 //: vnl_sparse_matrix -> vnl_linear_system adaptor
25 // An adaptor that converts a vnl_sparse_matrix<T> to a vnl_linear_system
26 template <class T>
27 class VNL_EXPORT vnl_sparse_matrix_linear_system : public vnl_linear_system
28 {
29  public:
30  //::Constructor from vnl_sparse_matrix<double> for system Ax = b
31  // Keeps a reference to the original sparse matrix A and vector b so DO NOT DELETE THEM!!
33  vnl_linear_system(A.columns(), A.rows()), A_(A), b_(b), jacobi_precond_() {}
34 
35  //: Implementations of the vnl_linear_system virtuals.
36  void multiply(vnl_vector<double> const& x, vnl_vector<double> & b) const override;
37  //: Implementations of the vnl_linear_system virtuals.
38  void transpose_multiply(vnl_vector<double> const& b, vnl_vector<double> & x) const override;
39  //: Implementations of the vnl_linear_system virtuals.
40  void get_rhs(vnl_vector<double>& b) const override;
41  //: Implementations of the vnl_linear_system virtuals.
42  void apply_preconditioner(vnl_vector<double> const& x, vnl_vector<double> & px) const override;
43 
44  protected:
46  vnl_vector<T> const& b_;
47  vnl_vector<double> jacobi_precond_;
48 };
49 
50 template <>
52 template <>
54 template <>
56 template <>
58 template <>
60 template <>
62 
63 #endif // vnl_sparse_matrix_linear_system_h_
virtual void multiply(vnl_vector< double > const &x, vnl_vector< double > &y) const =0
Compute A*x, putting result in y.
virtual void get_rhs(vnl_vector< double > &b) const =0
void get_rhs(vnl_vector< double > &b) const override
Implementations of the vnl_linear_system virtuals.
Simple sparse matrix.
Abstraction for a linear system of equations.
virtual void apply_preconditioner(vnl_vector< double > const &x, vnl_vector< double > &px) const
virtual void transpose_multiply(vnl_vector< double > const &y, vnl_vector< double > &x) const =0
Compute A_transpose * y, putting result in x.
Mathematical vector class, templated by type of element.
Definition: vnl_fwd.h:16
Simple sparse matrix.
vnl_sparse_matrix -> vnl_linear_system adaptor.
Abstraction for a linear system of equations.
void transpose_multiply(vnl_vector< double > const &b, vnl_vector< double > &x) const override
Implementations of the vnl_linear_system virtuals.
void multiply(vnl_vector< double > const &x, vnl_vector< double > &b) const override
Implementations of the vnl_linear_system virtuals.