Newer
Older

Mathieu Faverge
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/**
*
* @file z_spm_matrixvector.c
*
* PaStiX csc routines
* PaStiX is a software package provided by Inria Bordeaux - Sud-Ouest,
* LaBRI, University of Bordeaux 1 and IPB.
*
* @version 5.1.0
* @author Mathieu Faverge
* @author Theophile Terraz
* @date 2015-01-01
*
* @precisions normal z -> c d s
**/
#include "common.h"
#include "csc.h"
#include "z_spm.h"
/**
*******************************************************************************
*
* @ingroup pastix_csc
*
* z_spmGeCSCv - compute the matrix-vector product:
* y = alpha * op( A ) + beta * y
*
* A is a PastixGeneral csc, where op( X ) is one of
*
* op( X ) = X or op( X ) = X' or op( X ) = conjg( X' )
*
* alpha and beta are scalars, and x and y are vectors.
*
*******************************************************************************
*
* @param[in] trans
* Specifies whether the matrix spm is transposed, not transposed or
* conjugate transposed:
* = PastixNoTrans: A is not transposed;
* = PastixTrans: A is transposed;
* = PastixConjTrans: A is conjugate transposed.
*
* @param[in] alpha
* alpha specifies the scalar alpha
*
* @param[in] csc
* The PastixGeneral csc.
*
* @param[in] x
* The vector x.
*
* @param[in] beta
* beta specifies the scalar beta
*
* @param[in,out] y
* The vector y.
*
*******************************************************************************
*
* @return
* \retval PASTIX_SUCCESS if the y vector has been computed succesfully,
* \retval PASTIX_ERR_BADPARAMETER otherwise.
*
*******************************************************************************/
int
z_spmGeCSCv( int trans,
pastix_complex64_t alpha,
const pastix_csc_t *csc,
const pastix_complex64_t *x,
pastix_complex64_t beta,
pastix_complex64_t *y )
{
const pastix_complex64_t *valptr = (pastix_complex64_t*)csc->values;
const pastix_complex64_t *xptr = x;
pastix_complex64_t *yptr = y;
pastix_int_t col, row, i, baseval;
if ( (csc == NULL) || (x == NULL) || (y == NULL ) )
{
return PASTIX_ERR_BADPARAMETER;
}
if( csc->mtxtype != PastixGeneral )
{
return PASTIX_ERR_BADPARAMETER;
}
baseval = spmFindBase( csc );
/* first, y = beta*y */
if( beta == 0. ) {
memset( yptr, 0, csc->gN * sizeof(pastix_complex64_t) );
}
else {
for( i=0; i<csc->gN; i++, yptr++ ) {
(*yptr) *= beta;
}
yptr = y;
}
if( alpha != 0. ) {
/**
* PastixNoTrans
*/
if( trans == PastixNoTrans )
{
for( col=0; col < csc->gN; col++ )
{
for( i=csc->colptr[col]; i<csc->colptr[col+1]; i++ )
{
row = csc->rowptr[i-baseval]-baseval;
yptr[row] += alpha * valptr[i-baseval] * xptr[col];
}
}
}
/**
* PastixTrans
*/
else if( trans == PastixTrans )
{
for( col=0; col < csc->gN; col++ )
{
for( i=csc->colptr[col]; i<csc->colptr[col+1]; i++ )
{
row = csc->rowptr[i-baseval]-baseval;
yptr[col] += alpha * valptr[i-baseval] * xptr[row];
}
}
}
#if defined(PRECISION_c) || defined(PRECISION_z)
else if( trans == PastixConjTrans )
{
for( col=0; col < csc->gN; col++ )
{
for( i=csc->colptr[col]; i<csc->colptr[col+1]; i++ )
{
row = csc->rowptr[i-baseval]-baseval;
yptr[col] += alpha * conj( valptr[i-baseval] ) * xptr[row];
}
}
}
#endif
else
{
return PASTIX_ERR_BADPARAMETER;
}
}
return PASTIX_SUCCESS;
}
/**
*******************************************************************************
*
* @ingroup pastix_csc
*
* z_spmSYCSCv - compute the matrix-vector product:
* y = alpha * A + beta * y
*
* A is a PastixSymmetric csc, alpha and beta are scalars, and x and y are
* vectors, and A a symm.
*
*******************************************************************************
*
* @param[in] alpha
* alpha specifies the scalar alpha
*
* @param[in] csc
* The PastixSymmetric csc.
*
* @param[in] x
* The vector x.
*
* @param[in] beta
* beta specifies the scalar beta
*
* @param[in,out] y
* The vector y.
*
*******************************************************************************
*
* @return
* \retval PASTIX_SUCCESS if the y vector has been computed succesfully,
* \retval PASTIX_ERR_BADPARAMETER otherwise.
*
*******************************************************************************/
int
z_spmSyCSCv( pastix_complex64_t alpha,
const pastix_csc_t *csc,
const pastix_complex64_t *x,
pastix_complex64_t beta,
pastix_complex64_t *y )
{
const pastix_complex64_t *valptr = (pastix_complex64_t*)csc->values;
const pastix_complex64_t *xptr = x;
pastix_complex64_t *yptr = y;
pastix_int_t col, row, i, baseval;
if ( (csc == NULL) || (x == NULL) || (y == NULL ) )
{
return PASTIX_ERR_BADPARAMETER;
}
if( csc->mtxtype != PastixSymmetric )
{
return PASTIX_ERR_BADPARAMETER;
}
baseval = spmFindBase( csc );
/* First, y = beta*y */
if( beta == 0. ) {
memset( yptr, 0, csc->gN * sizeof(pastix_complex64_t) );
}
else {
for( i=0; i<csc->gN; i++, yptr++ ) {
(*yptr) *= beta;
}
yptr = y;
}
if( alpha != 0. ) {
for( col=0; col < csc->gN; col++ )
{
for( i=csc->colptr[col]; i < csc->colptr[col+1]; i++ )
{
row = csc->rowptr[i-baseval]-baseval;
yptr[row] += alpha * valptr[i-baseval] * xptr[col];
if( col != row )
{
yptr[col] += alpha * valptr[i-baseval] * xptr[row];
}
}
}
}
return PASTIX_SUCCESS;
}
#if defined(PRECISION_c) || defined(PRECISION_z)
/**
*******************************************************************************
*
* @ingroup pastix_csc
*
* z_spmHeCSCv - compute the matrix-vector product:
* y = alpha * A + beta * y
*
* A is a PastixHermitian csc, alpha and beta are scalars, and x and y are
* vectors, and A a symm.
*
*******************************************************************************
*
* @param[in] alpha
* alpha specifies the scalar alpha
*
* @param[in] csc
* The PastixHermitian csc.
*
* @param[in] x
* The vector x.
*
* @param[in] beta
* beta specifies the scalar beta
*
* @param[in,out] y
* The vector y.
*
*******************************************************************************
*
* @return
* \retval PASTIX_SUCCESS if the y vector has been computed succesfully,
* \retval PASTIX_ERR_BADPARAMETER otherwise.
*
*******************************************************************************/
int
z_spmHeCSCv( pastix_complex64_t alpha,
const pastix_csc_t *csc,
const pastix_complex64_t *x,
pastix_complex64_t beta,
pastix_complex64_t *y )
{
const pastix_complex64_t *valptr = (pastix_complex64_t*)csc->values;
const pastix_complex64_t *xptr = x;
pastix_complex64_t *yptr = y;
pastix_int_t col, row, i, baseval;
if ( (csc == NULL) || (x == NULL) || (y == NULL ) )
{
return PASTIX_ERR_BADPARAMETER;
}
if( csc->mtxtype != PastixHermitian )
{
return PASTIX_ERR_BADPARAMETER;
}
/* First, y = beta*y */
if( beta == 0. ) {
memset( yptr, 0, csc->gN * sizeof(pastix_complex64_t) );
}
else {
for( i=0; i<csc->gN; i++, yptr++ ) {
(*yptr) *= beta;
}
yptr = y;
}
baseval = spmFindBase( csc );
if( alpha != 0. ) {
for( col=0; col < csc->gN; col++ )
{
for( i=csc->colptr[col]; i < csc->colptr[col+1]; i++ )
{
row=csc->rowptr[i-baseval]-baseval;
yptr[row] += alpha * valptr[i-baseval] * xptr[col];
if( col != row )
yptr[col] += alpha * conj( valptr[i-baseval] ) * xptr[row];
}
}
}
return PASTIX_SUCCESS;
}
#endif