cs_cholsol.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* x=A\b where A is symmetric positive definite; b overwritten with solution */
3 int cs_cholsol (int order, const cs *A, double *b)
4 {
5  double *x ;
6  css *S ;
7  csn *N ;
8  int n, ok ;
9  if (!CS_CSC (A) || !b) return (0) ; /* check inputs */
10  n = A->n ;
11  S = cs_schol (order, A) ; /* ordering and symbolic analysis */
12  N = cs_chol (A, S) ; /* numeric Cholesky factorization */
13  x = (double*) cs_malloc (n, sizeof (double)) ; /* get workspace */
14  ok = (S && N && x) ;
15  if (ok)
16  {
17  cs_ipvec (S->pinv, b, x, n) ; /* x = P*b */
18  cs_lsolve (N->L, x) ; /* x = L\x */
19  cs_ltsolve (N->L, x) ; /* x = L'\x */
20  cs_pvec (S->pinv, x, b, n) ; /* b = P'*x */
21  }
22  cs_free (x) ;
23  cs_sfree (S) ;
24  cs_nfree (N) ;
25  return (ok) ;
26 }
#define N
csn * cs_chol(const cs *A, const css *S)
Definition: cs_chol.c:3
int cs_lsolve(const cs *L, double *x)
Definition: cs_lsolve.c:3
csn * cs_nfree(csn *N)
Definition: cs_util.c:42
int cs_ltsolve(const cs *L, double *x)
Definition: cs_ltsolve.c:3
int n
Definition: cs.h:20
int cs_cholsol(int order, const cs *A, double *b)
Definition: cs_cholsol.c:3
void * cs_free(void *p)
Definition: cs_malloc.c:22
Definition: cs.h:62
int cs_ipvec(const int *p, const double *b, double *x, int n)
Definition: cs_ipvec.c:3
#define CS_CSC(A)
Definition: cs.h:140
Definition: cs.h:16
int cs_pvec(const int *p, const double *b, double *x, int n)
Definition: cs_pvec.c:3
int * pinv
Definition: cs.h:52
void * cs_malloc(int n, size_t size)
Definition: cs_malloc.c:10
css * cs_sfree(css *S)
Definition: cs_util.c:53
css * cs_schol(int order, const cs *A)
Definition: cs_schol.c:3
cs * L
Definition: cs.h:64
Definition: cs.h:50


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