EVSL  1.1.0
EigenValues Slicing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
cs_scatter.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* x = x + beta * A(:,j), where x is a dense vector and A(:,j) is sparse */
3 CS_INT cs_scatter (const cs *A, CS_INT j, CS_ENTRY beta, CS_INT *w, CS_ENTRY *x, CS_INT mark,
4  cs *C, CS_INT nz)
5 {
6  CS_INT i, p, *Ap, *Ai, *Ci ;
7  CS_ENTRY *Ax ;
8  if (!CS_CSC (A) || !w || !CS_CSC (C)) return (-1) ; /* check inputs */
9  Ap = A->p ; Ai = A->i ; Ax = A->x ; Ci = C->i ;
10  for (p = Ap [j] ; p < Ap [j+1] ; p++)
11  {
12  i = Ai [p] ; /* A(i,j) is nonzero */
13  if (w [i] < mark)
14  {
15  w [i] = mark ; /* i is new entry in column j */
16  Ci [nz++] = i ; /* add i to pattern of C(:,j) */
17  if (x) x [i] = beta * Ax [p] ; /* x(i) = beta*A(i,j) */
18  }
19  else if (x) x [i] += beta * Ax [p] ; /* i exists in C(:,j) already */
20  }
21  return (nz) ;
22 }
#define cs
Definition: cs.h:637
#define CS_ENTRY
Definition: cs.h:635
#define CS_CSC(A)
Definition: cs.h:659
#define CS_INT
Definition: cs.h:627
CS_INT cs_scatter(const cs *A, CS_INT j, CS_ENTRY beta, CS_INT *w, CS_ENTRY *x, CS_INT mark, cs *C, CS_INT nz)
Definition: cs_scatter.c:3