c++ - CSparse: getting element of sparsed marix -


is possible ask element (i,j) in csparse cs object , value or 0 if not filled? should write function myself or there solution in csparse?

lack of documentation made me sad.

here reference code:

timothy davis, direct methods sparse linear systems, siam, philadelphia, 2006. here source

you're right. documentation poor. let see if cannot generate rough documentation of our own.

copying directory http://www.cise.ufl.edu/research/sparse/csparse/csparse/source/ one's own pc, entering directory, , issuing command sed '/^[^[:space:]#{}]/!d;/^\//!a\\' *.c yields

/* c = alpha*a + beta*b */ cs *cs_add (const cs *a, const cs *b, double alpha, double beta)  /* clear w */ static csi cs_wclear (csi mark, csi lemax, csi *w, csi n)  /* keep off-diagonal entries; drop diagonal entries */ static csi cs_diag (csi i, csi j, double aij, void *other) { return (i != j) ; }  /* p = amd(a+a') if symmetric true, or amd(a'a) otherwise */ csi *cs_amd (csi order, const cs *a)  /* order 0:natural, 1:chol, 2:lu, 3:qr */  /* l = chol (a, [pinv parent cp]), pinv optional */ csn *cs_chol (const cs *a, const css *s)  /* x=a\b symmetric positive definite; b overwritten solution */ csi cs_cholsol (csi order, const cs *a, double *b)  /* c = compressed-column form of triplet matrix t */ cs *cs_compress (const cs *t)  /* column counts of ll'=a or ll'=a'a, given parent & post ordering */ static void init_ata (cs *at, const csi *post, csi *w, csi **head, csi **next)  csi *cs_counts (const cs *a, const csi *parent, const csi *post, csi ata)  /* p [0..n] = cumulative sum of c [0..n-1], , copy p [0..n-1] c */ double cs_cumsum (csi *p, csi *c, csi n)  /* depth-first-search of graph of matrix, starting @ node j */ csi cs_dfs (csi j, cs *g, csi top, csi *xi, csi *pstack, const csi *pinv)  /* breadth-first search coarse decomposition (c0,c1,r1 or r0,r3,c3) */ static csi cs_bfs (const cs *a, csi n, csi *wi, csi *wj, csi *queue,  /* collect matched rows , columns p , q */ static void cs_matched (csi n, const csi *wj, const csi *imatch, csi *p, csi *q,  /* collect unmatched rows permutation vector p */ static void cs_unmatched (csi m, const csi *wi, csi *p, csi *rr, csi set)  /* return 1 if row in r2 */ static csi cs_rprune (csi i, csi j, double aij, void *other)  /* given a, compute coarse , fine dmperm */ csd *cs_dmperm (const cs *a, csi seed)  static csi cs_tol (csi i, csi j, double aij, void *tol)  csi cs_droptol (cs *a, double tol)  static csi cs_nonzero (csi i, csi j, double aij, void *other)  csi cs_dropzeros (cs *a)  /* remove duplicate entries */ csi cs_dupl (cs *a)  /* add entry triplet matrix; return 1 if ok, 0 otherwise */ csi cs_entry (cs *t, csi i, csi j, double x)  /* find nonzero pattern of cholesky l(k,1:k-1) using etree , triu(a(:,k)) */ csi cs_ereach (const cs *a, csi k, const csi *parent, csi *s, csi *w)  /* compute etree of (using triu(a), or a'a without forming a'a */ csi *cs_etree (const cs *a, csi ata)  /* drop entries fkeep(a(i,j)) false; return nz if ok, else -1 */ csi cs_fkeep (cs *a, csi (*fkeep) (csi, csi, double, void *), void *other)  /* y = a*x+y */ csi cs_gaxpy (const cs *a, const double *x, double *y)  /* apply ith householder vector x */ csi cs_happly (const cs *v, csi i, double beta, double *x)  /* create householder reflection [v,beta,s]=house(x), overwrite x v, double cs_house (double *x, double *beta, csi n)  /* x(p) = b, dense vectors x , b; p=null denotes identity */ csi cs_ipvec (const csi *p, const double *b, double *x, csi n)  /* consider a(i,j), node j in ith row subtree , return lca(jprev,j) */ csi cs_leaf (csi i, csi j, const csi *first, csi *maxfirst, csi *prevleaf,  /* load triplet matrix file */ cs *cs_load (file *f)  /* solve lx=b x , b dense.  x=b on input, solution on output. */ csi cs_lsolve (const cs *l, double *x)  /* solve l'x=b x , b dense.  x=b on input, solution on output. */ csi cs_ltsolve (const cs *l, double *x)  /* [l,u,pinv]=lu(a, [q lnz unz]). lnz , unz can guess */ csn *cs_lu (const cs *a, const css *s, double tol)  /* x=a\b unsymmetric; b overwritten solution */ csi cs_lusol (csi order, const cs *a, double *b, double tol)  /* wrapper malloc */ void *cs_malloc (csi n, size_t size)  /* wrapper calloc */ void *cs_calloc (csi n, size_t size)  /* wrapper free */ void *cs_free (void *p)  /* wrapper realloc */ void *cs_realloc (void *p, csi n, size_t size, csi *ok)  /* find augmenting path starting @ column k , extend match if found */ static void cs_augment (csi k, const cs *a, csi *jmatch, csi *cheap, csi *w,  /* find maximum transveral */ csi *cs_maxtrans (const cs *a, csi seed)  /*[jmatch [0..m-1]; imatch [0..n-1]]*/  /* c = a*b */ cs *cs_multiply (const cs *a, const cs *b)  /* 1-norm of sparse matrix = max (sum (abs (a))), largest column sum */ double cs_norm (const cs *a)  /* c = a(p,q) p , q permutations of 0..m-1 , 0..n-1. */ cs *cs_permute (const cs *a, const csi *pinv, const csi *q, csi values)  /* pinv = p', or p = pinv' */ csi *cs_pinv (csi const *p, csi n)  /* post order forest */ csi *cs_post (const csi *parent, csi n)  /* print sparse matrix; use %g integers avoid differences csi */ csi cs_print (const cs *a, csi brief)  /* x = b(p), dense vectors x , b; p=null denotes identity */ csi cs_pvec (const csi *p, const double *b, double *x, csi n)  /* sparse qr factorization [v,beta,pinv,r] = qr (a) */ csn *cs_qr (const cs *a, const css *s)  /* x=a\b can rectangular; b overwritten solution */ csi cs_qrsol (csi order, const cs *a, double *b)  /* return random permutation vector, identity perm, or p = n-1:-1:0. csi *cs_randperm (csi n, csi seed)  /* xi [top...n-1] = nodes reachable graph of g*p' via nodes in b(:,k). csi cs_reach (cs *g, const cs *b, csi k, csi *xi, const csi *pinv)  /* x = x + beta * a(:,j), x dense vector , a(:,j) sparse */ csi cs_scatter (const cs *a, csi j, double beta, csi *w, double *x, csi mark,  /* find connected components of square matrix */ csd *cs_scc (cs *a)     /* matrix temporarily modified, restored */  /* ordering , symbolic analysis cholesky factorization */ css *cs_schol (csi order, const cs *a)  /* solve gx=b(:,k), g either upper (lo=0) or lower (lo=1) triangular */ csi cs_spsolve (cs *g, const cs *b, csi k, csi *xi, double *x, const csi *pinv,  /* compute nnz(v) = s->lnz, s->pinv, s->leftmost, s->m2 , s->parent */ static csi cs_vcount (const cs *a, css *s)  /* symbolic ordering , analysis qr or lu */ css *cs_sqr (csi order, const cs *a, csi qr)  /* c = a(p,p) , c symmetric upper part stored; pinv not p */ cs *cs_symperm (const cs *a, const csi *pinv, csi values)  /* depth-first search , postorder of tree rooted @ node j */ csi cs_tdfs (csi j, csi k, csi *head, const csi *next, csi *post, csi *stack)  /* c = a' */ cs *cs_transpose (const cs *a, csi values)  /* sparse cholesky update/downdate, l*l' + sigma*w*w' (sigma = +1 or -1) */ csi cs_updown (cs *l, csi sigma, const cs *c, const csi *parent)  /* solve ux=b x , b dense.  x=b on input, solution on output. */ csi cs_usolve (const cs *u, double *x)  /* allocate sparse matrix (triplet form or compressed-column form) */ cs *cs_spalloc (csi m, csi n, csi nzmax, csi values, csi triplet)  /* change max # of entries sparse matrix */ csi cs_sprealloc (cs *a, csi nzmax)  /* free sparse matrix */ cs *cs_spfree (cs *a)  /* free numeric factorization */ csn *cs_nfree (csn *n)  /* free symbolic factorization */ css *cs_sfree (css *s)  /* allocate cs_dmperm or cs_scc result */ csd *cs_dalloc (csi m, csi n)  /* free cs_dmperm or cs_scc result */ csd *cs_dfree (csd *d)  /* free workspace , return sparse matrix result */ cs *cs_done (cs *c, void *w, void *x, csi ok)  /* free workspace , return csi array result */ csi *cs_idone (csi *p, cs *c, void *w, csi ok)  /* free workspace , return numeric factorization (cholesky, lu, or qr) */ csn *cs_ndone (csn *n, cs *c, void *w, void *x, csi ok)  /* free workspace , return csd result */ csd *cs_ddone (csd *d, cs *c, void *w, csi ok)  /* solve u'x=b x , b dense.  x=b on input, solution on output. */ csi cs_utsolve (const cs *u, double *x) 

do notice there looks though want? don't. based on above, function cs_print() seems more candidate of others. however, when @ cs_print() source, don't seem see want. instead see routine seems treat nonzero elements only.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -