Rheolef  7.1
an efficient C++ finite element environment
csr_cumul_trans_mult.h
Go to the documentation of this file.
1 # ifndef _SKIT_CSR_CUMUL_TRANS_MULT_H
2 # define _SKIT_CSR_CUMUL_TRANS_MULT_H
3 //
24 // CSR: Compressed Sparse Row format
25 //
26 // algorithm-oriented generic library
27 // inspired from sparskit2 fortran library
28 //
29 // author: Pierre.Saramito@imag.fr
30 //
31 // date: 12 november 1997
32 //
33 //@!\vfill\listofalgorithms
34 /*@!
35  \vfill \pagebreak \mbox{} \vfill \begin{algorithm}[h]
36  \caption{{\tt trans\_mult}: sparse matrix $y += a^T*x$, where $x,y$ are dense vectors.}
37  \begin{algorithmic}
38  \INPUT {sparse matrix a and dense vector x}
39  ia(0:nrowa), ja(0:nnza-1), a(0:nnza-1),
40  x(0:nrowa)
41  \ENDINPUT
42  \OUTPUT {number of non-null elements in $z=x\pm y$}
43  y(0:ncola)
44  \ENDOUTPUT
45  \NOTE {}
46  The $y$ vector may be set to zero before the call in order to
47  compute $y := a^T*x$
48  \ENDNOTE
49  \BEGIN
50  \FORTO {i := 0}{nrowa-1}
51  \FORTO {p := ia(i)}{ia(i+1)-1}
52  y(ja(p)) += a(p) * x(i)
53  \ENDFOR
54  \ENDFOR
55  \END
56  \end{algorithmic} \end{algorithm}
57  \vfill \pagebreak \mbox{} \vfill
58 */
59 namespace rheolef {
60 
61 template <
62  class InputIterator1,
63  class InputIterator3,
64  class SetOperator,
65  class RandomAccessMutableIterator>
66 void
68  InputIterator1 ia,
69  InputIterator1 last_ia,
70  InputIterator3 x,
71  SetOperator set_op, // set_op: += or -= but not = because may cumul
72  RandomAccessMutableIterator y)
73 {
74  typedef typename std::iterator_traits<InputIterator1>::value_type InputIterator2;
75  typedef typename std::iterator_traits<RandomAccessMutableIterator>::value_type T;
76  InputIterator2 a = (*ia++);
77  while (ia != last_ia) {
78  T xi = *x++;
79  InputIterator2 last_a = (*ia++);
80  while (a != last_a) {
81  set_op (y [(*a).first], (*a).second * xi);
82  ++a;
83  }
84  }
85 }
86 //@!\vfill
87 }// namespace rheolef
88 # endif // _SKIT_CSR_CUMUL_TRANS_MULT_H
rheolef::csr_cumul_trans_mult
void csr_cumul_trans_mult(InputIterator1 ia, InputIterator1 last_ia, InputIterator3 x, SetOperator set_op, RandomAccessMutableIterator y)
Definition: csr_cumul_trans_mult.h:67
a
Definition: diffusion_isotropic.h:25
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
mkgeo_ball.a
a
Definition: mkgeo_ball.sh:151
rheolef::set_op
Definition: msg_util.h:56
T
Expr1::float_type T
Definition: field_expr.h:218