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