Coverage Report

Created: 2023-09-25 06:05

/src/igraph/vendor/cs/cs_fkeep.c
Line
Count
Source (jump to first uncovered line)
1
#include "cs.h"
2
/* drop entries for which fkeep(A(i,j)) is false; return nz if OK, else -1 */
3
CS_INT cs_fkeep (cs *A, CS_INT (*fkeep) (CS_INT, CS_INT, CS_ENTRY, void *), void *other)
4
0
{
5
0
    CS_INT j, p, nz = 0, n, *Ap, *Ai ;
6
0
    CS_ENTRY *Ax ;
7
0
    if (!CS_CSC (A) || !fkeep) return (-1) ;    /* check inputs */
8
0
    n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ;
9
0
    for (j = 0 ; j < n ; j++)
10
0
    {
11
0
        p = Ap [j] ;                        /* get current location of col j */
12
0
        Ap [j] = nz ;                       /* record new location of col j */
13
0
        for ( ; p < Ap [j+1] ; p++)
14
0
        {
15
0
            if (fkeep (Ai [p], j, Ax ? Ax [p] : 1, other))
16
0
            {
17
0
                if (Ax) Ax [nz] = Ax [p] ;  /* keep A(i,j) */
18
0
                Ai [nz++] = Ai [p] ;
19
0
            }
20
0
        }
21
0
    }
22
0
    Ap [n] = nz ;                           /* finalize A */
23
0
    cs_sprealloc (A, 0) ;                   /* remove extra space from A */
24
0
    return (nz) ;
25
0
}