Go to the documentation of this file.00001 #include "cs.h"
00002
00003 int cs_fkeep (cs *A, int (*fkeep) (int, int, double, void *), void *other)
00004 {
00005 int j, p, nz = 0, n, *Ap, *Ai ;
00006 double *Ax ;
00007 if (!CS_CSC (A) || !fkeep) return (-1) ;
00008 n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ;
00009 for (j = 0 ; j < n ; j++)
00010 {
00011 p = Ap [j] ;
00012 Ap [j] = nz ;
00013 for ( ; p < Ap [j+1] ; p++)
00014 {
00015 if (fkeep (Ai [p], j, Ax ? Ax [p] : 1, other))
00016 {
00017 if (Ax) Ax [nz] = Ax [p] ;
00018 Ai [nz++] = Ai [p] ;
00019 }
00020 }
00021 }
00022 Ap [n] = nz ;
00023 cs_sprealloc (A, 0) ;
00024 return (nz) ;
00025 }