csr_cumul_trans_mult.h
Go to the documentation of this file.
# ifndef _SKIT_CSR_CUMUL_TRANS_MULT_H
# define _SKIT_CSR_CUMUL_TRANS_MULT_H
//
// CSR: Compressed Sparse Row format
//
// algorithm-oriented generic library
// inspired from sparskit2 fortran library
//
// author: Pierre.Saramito@imag.fr
//
// date: 12 november 1997
//
//@!\vfill\listofalgorithms
/*@!
\vfill \pagebreak \mbox{} \vfill \begin{algorithm}[h]
\caption{{\tt trans\_mult}: sparse matrix $y += a^T*x$, where $x,y$ are dense vectors.}
\begin{algorithmic}
\INPUT {sparse matrix a and dense vector x}
ia(0:nrowa), ja(0:nnza-1), a(0:nnza-1),
x(0:nrowa)
\ENDINPUT
\OUTPUT {number of non-null elements in $z=x\pm y$}
y(0:ncola)
\ENDOUTPUT
\NOTE {}
The $y$ vector may be set to zero before the call in order to
compute $y := a^T*x$
\ENDNOTE
\BEGIN
\FORTO {i := 0}{nrowa-1}
\FORTO {p := ia(i)}{ia(i+1)-1}
y(ja(p)) += a(p) * x(i)
\ENDFOR
\ENDFOR
\END
\end{algorithmic} \end{algorithm}
\vfill \pagebreak \mbox{} \vfill
*/
namespace rheolef {
template <
class InputIterator1,
class InputIterator3,
class SetOperator,
class RandomAccessMutableIterator>
void
csr_cumul_trans_mult (
InputIterator1 ia,
InputIterator1 last_ia,
InputIterator3 x,
SetOperator set_op, // set_op: += or -= but not = because may cumul
RandomAccessMutableIterator y)
{
typedef typename std::iterator_traits<InputIterator1>::value_type InputIterator2;
typedef typename std::iterator_traits<RandomAccessMutableIterator>::value_type T;
InputIterator2 a = (*ia++);
while (ia != last_ia) {
T xi = *x++;
InputIterator2 last_a = (*ia++);
while (a != last_a) {
set_op (y [(*a).first], (*a).second * xi);
++a;
}
}
}
//@!\vfill
}// namespace rheolef
# endif // _SKIT_CSR_CUMUL_TRANS_MULT_H
T
Expr1::float_type T
Definition: field_expr.h:261
mkgeo_ball.a
int a
Definition: mkgeo_ball.sh:151
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
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::set_op
Definition: msg_util.h:56