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_dupl.c
Go to the documentation of this file.
1
#include "
cs.h
"
2
/* remove duplicate entries from A */
3
CS_INT
cs_dupl
(
cs
*A)
4
{
5
CS_INT
i, j, p, q, nz = 0, n, m, *Ap, *Ai, *w ;
6
CS_ENTRY
*Ax ;
7
if
(!
CS_CSC
(A))
return
(0) ;
/* check inputs */
8
m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ;
9
w =
cs_malloc
(m,
sizeof
(
CS_INT
)) ;
/* get workspace */
10
if
(!w)
return
(0) ;
/* out of memory */
11
for
(i = 0 ; i < m ; i++) w [i] = -1 ;
/* row i not yet seen */
12
for
(j = 0 ; j < n ; j++)
13
{
14
q = nz ;
/* column j will start at q */
15
for
(p = Ap [j] ; p < Ap [j+1] ; p++)
16
{
17
i = Ai [p] ;
/* A(i,j) is nonzero */
18
if
(w [i] >= q)
19
{
20
Ax [w [i]] += Ax [p] ;
/* A(i,j) is a duplicate */
21
}
22
else
23
{
24
w [i] = nz ;
/* record where row i occurs */
25
Ai [nz] = i ;
/* keep A(i,j) */
26
Ax [nz++] = Ax [p] ;
27
}
28
}
29
Ap [j] = q ;
/* record start of column j */
30
}
31
Ap [n] = nz ;
/* finalize A */
32
cs_free
(w) ;
/* free workspace */
33
return
(
cs_sprealloc
(A, 0)) ;
/* remove extra space from A */
34
}
cs_free
void * cs_free(void *p)
Definition:
cs_malloc.c:22
cs
#define cs
Definition:
cs.h:637
CS_ENTRY
#define CS_ENTRY
Definition:
cs.h:635
cs.h
cs_dupl
CS_INT cs_dupl(cs *A)
Definition:
cs_dupl.c:3
CS_CSC
#define CS_CSC(A)
Definition:
cs.h:659
CS_INT
#define CS_INT
Definition:
cs.h:627
cs_sprealloc
CS_INT cs_sprealloc(cs *A, CS_INT nzmax)
Definition:
cs_util.c:18
cs_malloc
void * cs_malloc(CS_INT n, size_t size)
Definition:
cs_malloc.c:10
Generated by
1.8.6