EVSL
1.1.0
EigenValues Slicing Library
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
EXTERNAL
CXSparse
Source
cs_cumsum.c
Go to the documentation of this file.
1
#include "
cs.h
"
2
/* p [0..n] = cumulative sum of c [0..n-1], and then copy p [0..n-1] into c */
3
double
cs_cumsum
(
CS_INT
*p,
CS_INT
*c,
CS_INT
n)
4
{
5
CS_INT
i, nz = 0 ;
6
double
nz2 = 0 ;
7
if
(!p || !c)
return
(-1) ;
/* check inputs */
8
for
(i = 0 ; i < n ; i++)
9
{
10
p [i] = nz ;
11
nz += c [i] ;
12
nz2 += c [i] ;
/* also in double to avoid CS_INT overflow */
13
c [i] = p [i] ;
/* also copy p[0..n-1] back into c[0..n-1]*/
14
}
15
p [n] = nz ;
16
return
(nz2) ;
/* return sum (c [0..n-1]) */
17
}
cs_cumsum
double cs_cumsum(CS_INT *p, CS_INT *c, CS_INT n)
Definition:
cs_cumsum.c:3
cs.h
CS_INT
#define CS_INT
Definition:
cs.h:627
Generated by
1.8.6