cs_schol.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* ordering and symbolic analysis for a Cholesky factorization */
3 css *cs_schol (int order, const cs *A)
4 {
5  int n, *c, *post, *P ;
6  cs *C ;
7  css *S ;
8  if (!CS_CSC (A)) return (NULL) ; /* check inputs */
9  n = A->n ;
10  S = (css*) cs_calloc (1, sizeof (css)) ; /* allocate result S */
11  if (!S) return (NULL) ; /* out of memory */
12  P = cs_amd (order, A) ; /* P = amd(A+A'), or natural */
13  S->pinv = cs_pinv (P, n) ; /* find inverse permutation */
14  cs_free (P) ;
15  if (order && !S->pinv) return (cs_sfree (S)) ;
16  C = cs_symperm (A, S->pinv, 0) ; /* C = spones(triu(A(P,P))) */
17  S->parent = cs_etree (C, 0) ; /* find etree of C */
18  post = cs_post (S->parent, n) ; /* postorder the etree */
19  c = cs_counts (C, S->parent, post, 0) ; /* find column counts of chol(C) */
20  cs_free (post) ;
21  cs_spfree (C) ;
22  S->cp = (int*)cs_malloc (n+1, sizeof (int)) ; /* allocate result S->cp */
23  S->unz = S->lnz = cs_cumsum (S->cp, c, n) ; /* find column pointers for L */
24  cs_free (c) ;
25  return ((S->lnz >= 0) ? S : cs_sfree (S)) ;
26 }
cs * cs_spfree(cs *A)
Definition: cs_util.c:32
cs * cs_symperm(const cs *A, const int *pinv, int values)
Definition: cs_symperm.c:3
int n
Definition: cs.h:20
void * cs_free(void *p)
Definition: cs_malloc.c:22
int * cs_post(const int *parent, int n)
Definition: cs_post.c:3
double lnz
Definition: cs.h:58
double unz
Definition: cs.h:59
int * cs_etree(const cs *A, int ata)
Definition: cs_etree.c:3
#define CS_CSC(A)
Definition: cs.h:140
Definition: cs.h:16
int * cp
Definition: cs.h:55
void * cs_calloc(int n, size_t size)
Definition: cs_malloc.c:16
int * pinv
Definition: cs.h:52
double cs_cumsum(int *p, int *c, int n)
Definition: cs_cumsum.c:3
void * cs_malloc(int n, size_t size)
Definition: cs_malloc.c:10
int * cs_amd(int order, const cs *A)
Definition: cs_amd.c:18
int * cs_pinv(const int *p, int n)
Definition: cs_pinv.c:3
css * cs_schol(int order, const cs *A)
Definition: cs_schol.c:3
css * cs_sfree(css *S)
Definition: cs_util.c:53
int * parent
Definition: cs.h:54
int * cs_counts(const cs *A, const int *parent, const int *post, int ata)
Definition: cs_counts.c:17
Definition: cs.h:50


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:31