Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_BIG_PROD_TRANS_H
00002 #define OPENTISSUE_CORE_MATH_BIG_PROD_TRANS_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 {
00022
00030 template<typename T>
00031 inline void prod_trans(
00032 boost::numeric::ublas::compressed_matrix<T> const & A
00033 , boost::numeric::ublas::vector<T> const & x
00034 , boost::numeric::ublas::vector<T> & y
00035 )
00036 {
00037 typedef boost::numeric::ublas::vector<T> vector_type;
00038 typedef typename vector_type::size_type size_type;
00039 typedef typename vector_type::value_type real_type;
00040
00041 assert(A.size1()>0 || !"prod_trans(): A was empty" );
00042 assert(A.size2()>0 || !"prod_trans(): A was empty" );
00043 assert(A.size1() == x.size() || !"prod_trans(): incompatible dimensions");
00044 assert(A.size2() == y.size() || !"prod_trans(): incompatible dimensions");
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 y.clear();
00069
00070 size_type row_end = A.filled1 () - 1;
00071 for (size_type i = 0; i < row_end; ++ i)
00072 {
00073 size_type begin = A.index1_data()[i];
00074 size_type end = A.index1_data()[i + 1];
00075 for (size_type j = begin; j < end; ++ j)
00076 y( A.index2_data()[j] ) += A.value_data()[j] * x( i );
00077 }
00078 }
00079
00080
00089 template<typename T>
00090 inline void prod_trans(
00091 boost::numeric::ublas::compressed_matrix<T> const & A
00092 , boost::numeric::ublas::vector<T> const & x
00093 , boost::numeric::ublas::vector<T> const & b
00094 , boost::numeric::ublas::vector<T> & y
00095 )
00096 {
00097 typedef boost::numeric::ublas::vector<T> vector_type;
00098 typedef typename vector_type::size_type size_type;
00099 typedef typename vector_type::value_type real_type;
00100
00101 assert(A.size1()>0 || !"prod_trans(): A was empty" );
00102 assert(A.size2()>0 || !"prod_trans(): A was empty" );
00103 assert(A.size1() == x.size() || !"prod_trans(): incompatible dimensions");
00104 assert(A.size2() == y.size() || !"prod_trans(): incompatible dimensions");
00105 assert(b.size() == y.size() || !"prod_trans(): incompatible dimensions");
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 y.assign( b );
00130
00131 size_type row_end = A.filled1 () - 1;
00132 for (size_type i = 0; i < row_end; ++ i)
00133 {
00134 size_type begin = A.index1_data()[i];
00135 size_type end = A.index1_data()[i + 1];
00136 for (size_type j = begin; j < end; ++ j)
00137 y( A.index2_data()[j] ) += A.value_data()[j] * x( i );
00138 }
00139 }
00140
00141 }
00142 }
00143 }
00144
00145 #endif