LASs - Linear Algebra Routines on OmpSs 1.0.0 LASs

- Main Page
- Files

- File List
- File Members

dspmv.c
Go to the documentation of this file.
1 #include "../include/lass.h"
2
3 /**
4 *
5 * @file dspmv.c
6 *
7 * @brief LASs-DSS dspmv routine.
8 *
9 * LASs-DSSs is a software package provided by:
10 * Barcelona Supercomputing Center - Centro Nacional de Supercomputacion
11 *
12 * @author Sandra Catalán sandra.catalan@bsc.es
13 * @author Pedro Valero-Lara pedro.valero@bsc.es
14 * @date 2018-09-07
15 * @reviewer
16 * @modified
17 *
18 **/
19
20 /**
21 *
22 * @ingroup DSSs
23 *
24 * Performs the sparse matrix-vector operation:
25 *
26 * Y = ALPHA * A * X + BETA * Y
27 *
28 * where ALPHA and BETA are scalars, X and Y are vectors, and
29 * A is a sparse matrix stored in thhe next three vectors VAL_A,
30 * COL_IND_A and ROW_PTR_A according to CSR format.
31 *
32 **/
33
34 /**
35 *
36 * @param[in]
37 * M int.
38 * M specifies the number of rows of A.
39 *
40 * @param[in]
41 * N int.
42 * N specifies the number of columns of A.
43 *
44 * @param[in]
45 * ALPHA double.
46 *
47 * @param[in]
48 * VAL_A double *.
49 * VAL_A is a pointer to a vector which specifies the non-zero
50 * values of the original matrix A.
51 *
52 * @param[in]
53 * COL_IND_A unsigned int *.
54 * COL_IND_A is a pointer to a vector which specifies the column of
55 * each value of A in the original matrix.
56 *
57 * @param[in]
58 * ROW_PTR_A unsigned int *.
59 * ROW_PTR_A is a pointer to a vector which specifies the number of
60 * values that A contains in each row of the original matrix.
61 *
62 * @param[in]
63 * X double *.
64 * X is a pointer to a vector of dimension N.
65 *
66 * @param[in]
67 * BETA double .
68 *
69 * @param[in, out]
70 * Y double *.
71 * Y is a pointer to a vector of dimension M.
72 * On exit, Y is overwritten by the sparse matrix-vector result.
73 *
74 *
75 **/
76
77 /**
78 *
79 * @retval Success sucessful exit
80 * @retval NoSuccess unsucessful exit
81 *
82 **/
83
84 void dspmvseq( int M, int N,
85 double ALPHA,
86 const double *VAL_A, const int *ROW_PTR_A, const int *COL_IND_A,
87 const double *X,
88 double BETA,
89 double *Y )
90 {
91
92 // Local variables
93 double svalue = 0.0, value = 0.0;
94 int max = 0, col = 0;
95 int i, x;
96
97 for ( x = 0; x < M; x++ )
98 {
99 svalue = 0.0;
100 max = ROW_PTR_A[x + 1] - ROW_PTR_A[x];
101
102 for( i = 0; i < max; i++ )
103 {
104 value = VAL_A[ROW_PTR_A[x] + i];
105 col = COL_IND_A[ROW_PTR_A[x] + i];
106 svalue += value * X[col] * ALPHA;
107
108
109 }
110
111 Y[x] = svalue + Y[x] * BETA;
112
113 }
114
115 }
dspmvseq
void dspmvseq(int M, int N, double ALPHA, const double *VAL_A, const int *ROW_PTR_A, const int *COL_IND_A, const double *X, double BETA, double *Y)
Definition: dspmv.c:84