1
# ifndef _SKIT_CSR_ALGO_TRANS_MULT_H
2
# define _SKIT_CSR_ALGO_TRANS_MULT_H
4
/// This file is part of Rheolef.
6
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
8
/// Rheolef is free software; you can redistribute it and/or modify
9
/// it under the terms of the GNU General Public License as published by
10
/// the Free Software Foundation; either version 2 of the License, or
11
/// (at your option) any later version.
13
/// Rheolef is distributed in the hope that it will be useful,
14
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
/// GNU General Public License for more details.
18
/// You should have received a copy of the GNU General Public License
19
/// along with Rheolef; if not, write to the Free Software
20
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
/// =========================================================================
24
// CSR: Compressed Sparse Row format
26
// algorithm-oriented generic library
27
// inspired from sparskit2 fortran library
29
// author: Pierre.Saramito@imag.fr
31
// date: 12 november 1997
33
//@!\vfill\listofalgorithms
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.}
38
\INPUT {sparse matrix a and dense vector x}
39
ia(0:nrowa), ja(0:nnza-1), a(0:nnza-1),
42
\OUTPUT {number of non-null elements in $z=x\pm y$}
46
The $y$ vector may be set to zero before the call in order to
50
\FORTO {i := 0}{nrowa-1}
51
\FORTO {p := ia(i)}{ia(i+1)-1}
52
y(ja(p)) += a(p) * x(i)
56
\end{algorithmic} \end{algorithm}
57
\vfill \pagebreak \mbox{} \vfill
64
class RandomAccessMutableIterator,
67
csr_cumul_trans_mult (
69
InputIterator1 last_ia,
70
InputIterator2 first_ja,
73
RandomAccessMutableIterator y,
76
InputIterator2 ja = first_ja + (*ia++);
77
while (ia != last_ia) {
80
InputIterator2 last_ja = first_ja + (*ia++);
83
y [(*ja++)] += (*a++) * lambda;
87
# endif // _SKIT_CSR_ALGO_TRANS_MULT_H