Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_BIG_SYMMETRIC_GAUSS_SEIDEL_H
00002 #define OPENTISSUE_CORE_MATH_BIG_SYMMETRIC_GAUSS_SEIDEL_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/big/big_forward_gauss_seidel.h>
00013 #include <OpenTissue/core/math/big/big_backward_gauss_seidel.h>
00014
00015 #include <stdexcept>
00016
00017 namespace OpenTissue
00018 {
00019 namespace math
00020 {
00021 namespace big
00022 {
00023
00035 template<typename T>
00036 inline void symmetric_gauss_seidel(
00037 boost::numeric::ublas::compressed_matrix<T> const & A
00038 , boost::numeric::ublas::vector<T> & x
00039 , boost::numeric::ublas::vector<T> const & b
00040 )
00041 {
00042 forward_gauss_seidel( A, x, b );
00043 backward_gauss_seidel( A, x, b );
00044 }
00045
00057 template<typename T>
00058 inline void symmetric_gauss_seidel(
00059 boost::numeric::ublas::compressed_matrix<T> const & A
00060 , boost::numeric::ublas::vector<T> & x
00061 , boost::numeric::ublas::vector<T> const & b
00062 , size_t const & max_iterations
00063 , size_t & iterations
00064 )
00065 {
00066 if(max_iterations < 1)
00067 throw std::invalid_argument("symmetric_gauss_seidel(): max_iterations must be a positive number");
00068
00069 iterations = 0;
00070 while(iterations<max_iterations)
00071 {
00072 ++iterations;
00073 symmetric_gauss_seidel(A,x,b);
00074 }
00075 }
00076
00086 class SymmetricGaussSeidelFunctor
00087 {
00088 public:
00089
00090 template<typename T>
00091 void operator()(
00092 boost::numeric::ublas::compressed_matrix<T> const & A
00093 , boost::numeric::ublas::vector<T> & x
00094 , boost::numeric::ublas::vector<T> const & b
00095 , size_t const & max_iterations
00096 , size_t & iterations
00097 )
00098 {
00099 symmetric_gauss_seidel(A,x,b,max_iterations,iterations);
00100 }
00101
00102 template<typename T>
00103 void operator()(
00104 boost::numeric::ublas::compressed_matrix<T> const & A
00105 , boost::numeric::ublas::vector<T> & x
00106 , boost::numeric::ublas::vector<T> const & b
00107 )
00108 {
00109 symmetric_gauss_seidel(A,x,b);
00110 }
00111
00112 };
00113
00114 }
00115 }
00116 }
00117
00118
00119 #endif