Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
external_packages
csparse
cs_dupl.c
Go to the documentation of this file.
1
#include "
cs.h
"
2
/* remove duplicate entries from A */
3
int
cs_dupl
(
cs
*
A
)
4
{
5
int
i, j, p, q, nz = 0, n, m, *Ap, *Ai, *w ;
6
double
*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 = (
int
*)
cs_malloc
(m,
sizeof
(
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
}
example1.A
A
Definition:
example1.py:34
cs_sparse::n
int n
Definition:
cs.h:20
cs_dupl
int cs_dupl(cs *A)
Definition:
cs_dupl.c:3
cs_free
void * cs_free(void *p)
Definition:
cs_malloc.c:22
cs_sprealloc
int cs_sprealloc(cs *A, int nzmax)
Definition:
cs_util.c:18
cs.h
CS_CSC
#define CS_CSC(A)
Definition:
cs.h:140
cs_sparse::p
int * p
Definition:
cs.h:21
cs_sparse
Definition:
cs.h:16
cs_sparse::i
int * i
Definition:
cs.h:22
cs_malloc
void * cs_malloc(int n, size_t size)
Definition:
cs_malloc.c:10
cs_sparse::x
double * x
Definition:
cs.h:23
cs_sparse::m
int m
Definition:
cs.h:19
acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:31