Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

vnl_linear_system.h

Go to the documentation of this file.
00001 #ifndef vnl_linear_system_h_
00002 #define vnl_linear_system_h_
00003 // This is vxl/vnl/vnl_linear_system.h
00004 
00005 //: \file
00006 //  \brief Abstraction for a linear system of equations.
00007 //  \author David Capel, capes@robots, July 2000
00008 
00009 
00010 // Modifications:
00011 // LSB (Manchester) 23/1/01 Documentation tidied
00012 
00013 #include <vcl_string.h>
00014 #include <vnl/vnl_vector.h>
00015 #include <vnl/vnl_matrix.h>
00016 
00017 //: Abstraction for a linear system of equations.
00018 //    vnl_linear_system provides an abstraction for a linear system
00019 //    of equations, Ax = b, to be solved by one of the iterative linear
00020 //    solvers. Access to the systems is via the pure virtual methods
00021 //    multiply() and transpose_multiply(). This procedural access scheme
00022 //    makes it possible to solve very large, sparse systems which it would
00023 //    be inefficient to store in matrix form.
00024 class vnl_linear_system {
00025 public:
00026 
00027   vnl_linear_system(int number_of_unknowns, int number_of_residuals) :
00028     p_(number_of_unknowns), n_(number_of_residuals) {}
00029 
00030   virtual ~vnl_linear_system();
00031 
00032   //: Compute A*x,  putting result in y
00033   virtual void multiply(vnl_vector<double> const& x, vnl_vector<double> &y) const = 0;
00034 
00035   //: Compute A_transpose * y, putting result in x
00036   virtual void transpose_multiply(vnl_vector<double> const& y, vnl_vector<double> &x) const = 0;
00037 
00038   //; Put the right-hand side of the system Ax = b into b
00039   virtual void get_rhs(vnl_vector<double>& b) const = 0;
00040 
00041   //; (Optional) Apply a suitable preconditioner to x.
00042   // A preconditioner is an approximation of the inverse of A.
00043   // Common choices are Jacobi (1/diag(A'A)), Gauss-Seidel,
00044   // and incomplete LU or Cholesky decompositions.
00045   // The default implementation applies the identity.
00046   virtual void apply_preconditioner(vnl_vector<double> const& x, vnl_vector<double> & px) const;
00047 
00048   //: Return the number of unknowns
00049   int get_number_of_unknowns() const { return p_; }
00050 
00051   //: Return the number of residuals.
00052   int get_number_of_residuals() const { return n_; }
00053 
00054   //: Compute rms error for parameter vector x
00055   double get_rms_error(vnl_vector<double> const& x) const;
00056 
00057   //: Compute relative residual (|Ax - b| / |b| )for parameter vector x
00058   double get_relative_residual(vnl_vector<double> const& x) const;
00059 
00060 protected:
00061   int p_;
00062   int n_;
00063 };
00064 
00065 #endif // vnl_linear_system_h_

Generated at Fri May 21 01:15:48 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000