core/vnl/vnl_linear_system.cxx
Go to the documentation of this file.
00001 // This is core/vnl/vnl_linear_system.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author David Capel, capes@robots
00008 // \date   July 2000
00009 
00010 #include "vnl_linear_system.h"
00011 #include <vcl_cassert.h>
00012 
00013 vnl_linear_system::~vnl_linear_system()
00014 {
00015 }
00016 
00017 void vnl_linear_system::apply_preconditioner(vnl_vector<double> const& x, vnl_vector<double> & px) const
00018 {
00019   assert(px.size() == x.size());
00020 
00021   px = x;
00022 }
00023 
00024 double vnl_linear_system::get_rms_error(vnl_vector<double> const& x) const
00025 {
00026   vnl_vector<double> resid(n_);
00027   vnl_vector<double> b(n_);
00028 
00029   multiply(x, resid);
00030   get_rhs(b);
00031 
00032   resid -= b;
00033 
00034   return resid.rms();
00035 }
00036 
00037 double vnl_linear_system::get_relative_residual(vnl_vector<double> const& x) const
00038 {
00039   vnl_vector<double> resid(n_);
00040   vnl_vector<double> b(n_);
00041 
00042   multiply(x, resid);
00043   get_rhs(b);
00044 
00045   resid -= b;
00046 
00047   return resid.rms() / b.rms();
00048 }