Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_BIG_PROD_SUB_H
00002 #define OPENTISSUE_CORE_MATH_BIG_PROD_SUB_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 <OpenTissue/core/math/big/io/big_matlab_write.h>
00015
00016 #include <cassert>
00017
00018 namespace OpenTissue
00019 {
00020 namespace math
00021 {
00022 namespace big
00023 {
00024
00034 template<typename T>
00035 inline void prod_sub(
00036 boost::numeric::ublas::compressed_matrix<T> const & A
00037 , boost::numeric::ublas::vector<T> const & x
00038 , boost::numeric::ublas::vector<T> & y
00039 )
00040 {
00041 typedef boost::numeric::ublas::vector<T> vector_type;
00042 typedef typename vector_type::size_type size_type;
00043 typedef typename vector_type::value_type real_type;
00044
00045 assert(A.size1()>0 || !"prod_sub(): A was empty" );
00046 assert(A.size2()>0 || !"prod_sub(): A was empty" );
00047 assert(A.size2() == x.size() || !"prod_sub(): incompatible dimensions");
00048 assert(A.size1() == y.size() || !"prod_sub(): incompatible dimensions");
00049
00050 size_type row_end = A.filled1 () - 1;
00051 for (size_type i = 0; i < row_end; ++ i)
00052 {
00053 size_type begin = A.index1_data () [i];
00054 size_type end = A.index1_data () [i + 1];
00055 real_type t = real_type();
00056 for (size_type j = begin; j < end; ++j)
00057 t += A.value_data()[j] * x( A.index2_data()[j] );
00058 y(i) -= t;
00059 }
00060 }
00061
00062 }
00063 }
00064 }
00065
00066 #endif