Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_BIG_PROD_SUB_RHS_H
00002 #define OPENTISSUE_CORE_MATH_BIG_PROD_SUB_RHS_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/big/big_types.h>
00013
00014 #include <cassert>
00015
00016 namespace OpenTissue
00017 {
00018 namespace math
00019 {
00020 namespace big
00021 {
00030 template<typename T>
00031 inline void prod_sub_rhs(
00032 boost::numeric::ublas::compressed_matrix<T> const & A
00033 , boost::numeric::ublas::vector<T> const & x
00034 , boost::numeric::ublas::vector<T> const & b
00035 , boost::numeric::ublas::vector<T> & y
00036 )
00037 {
00038 typedef boost::numeric::ublas::vector<T> vector_type;
00039 typedef typename vector_type::size_type size_type;
00040 typedef typename vector_type::value_type real_type;
00041
00042 assert(A.size1()>0 || !"prod_sub_rhs(): A was empty" );
00043 assert(A.size2()>0 || !"prod_sub_rhs(): A was empty" );
00044 assert(A.size2() == x.size() || !"prod_sub_rhs(): incompatible dimensions");
00045 assert(A.size1() == b.size() || !"prod_sub_rhs(): incompatible dimensions");
00046
00047 if(y.size() != b.size())
00048 y.resize(b.size(), false );
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 size_type row_end = A.filled1() - 1;
00073 for (size_type i = 0; i < row_end; ++ i)
00074 {
00075 size_type begin = A.index1_data()[i];
00076 size_type end = A.index1_data()[i + 1];
00077 real_type t = - b(i);
00078 for (size_type j = begin; j < end; ++ j)
00079 t += A.value_data()[j] * x( A.index2_data()[j] );
00080 y (i) = t;
00081 }
00082 }
00083
00084 }
00085 }
00086 }
00087
00088
00089 #endif