SparseMatrixVectorOp.h
Go to the documentation of this file.
1 #ifndef _utl_SparseMatrixVectorOp_h_
2 #define _utl_SparseMatrixVectorOp_h_
3 
12 #include <numeric>
13 
14 #include <boost/lambda/lambda.hpp>
15 
16 #include <utl/SparseVector.h>
17 #include <utl/SparseMatrix.h>
18 
19 
20 namespace boost {
21 
22  namespace lambda {
23 
25  template<typename T, typename U>
26  class plain_return_type_2<
27  arithmetic_action<multiply_action>,
28  utl::SparseMatrix<T>,
30  > {
31  private:
32  // delegate to the type of T * U
33  typedef typename
34  return_type_2<
35  arithmetic_action<multiply_action>,
36  T,
37  U
39 
40  public:
42  };
43 
44  }
45 
46 }
47 
48 
49 namespace utl {
50 
51 
52  template<typename T, typename U>
53  typename boost::lambda::return_type_2<
54  boost::lambda::arithmetic_action<boost::lambda::multiply_action>,
55  SparseMatrix<T>,
56  SparseVector<U>
57  >::type
59  {
60  typedef typename boost::lambda::return_type_2<
61  boost::lambda::arithmetic_action<boost::lambda::multiply_action>,
64  >::type ResultType;
65 
66  ResultType result;
67 
68  for (typename SparseMatrix<T>::ConstIterator mIt = m.SparseBegin();
69  mIt != m.SparseEnd(); ++mIt) {
70  const unsigned int j = mIt.GetColumn();
71  typename SparseVector<U>::ConstIterator aj = v.Find(j);
72  if (aj != v.SparseEnd())
73  result(mIt.GetRow()) += mIt() * aj();
74  }
75 
76  return result;
77  }
78 
79 
80 }
81 
82 
83 #endif
Sparse container class for vectorial data.
Definition: SparseVector.h:36
Sparse container class for matrix data.
Definition: SparseMatrix.h:36
Iterator SparseEnd()
Definition: SparseMatrix.h:219
Iterator Find(const IndexType index)
Definition: SparseVector.h:186
#define U
const Data result[]
Vector operator*(const double d, const Vector &v)
Definition: OperationsVV.h:38
Iterator SparseEnd()
Definition: SparseVector.h:182
constexpr double m
Definition: AugerUnits.h:121
Iterator SparseBegin()
Definition: SparseMatrix.h:215

, generated on Tue Sep 26 2023.