cs_lusol.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* x=A\b where A is unsymmetric; b overwritten with solution */
3 int cs_lusol (int order, const cs *A, double *b, double tol)
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_sqr (order, A, 0) ; /* ordering and symbolic analysis */
12  N = cs_lu (A, S, tol) ; /* numeric LU factorization */
13  x = (double*) cs_malloc (n, sizeof (double)) ; /* get workspace */
14  ok = (S && N && x) ;
15  if (ok)
16  {
17  cs_ipvec (N->pinv, b, x, n) ; /* x = b(p) */
18  cs_lsolve (N->L, x) ; /* x = L\x */
19  cs_usolve (N->U, x) ; /* x = U\x */
20  cs_ipvec (S->q, x, b, n) ; /* b(q) = x */
21  }
22  cs_free (x) ;
23  cs_sfree (S) ;
24  cs_nfree (N) ;
25  return (ok) ;
26 }
#define N
css * cs_sqr(int order, const cs *A, int qr)
Definition: cs_sqr.c:60
int * pinv
Definition: cs.h:66
int cs_lsolve(const cs *L, double *x)
Definition: cs_lsolve.c:3
int cs_lusol(int order, const cs *A, double *b, double tol)
Definition: cs_lusol.c:3
csn * cs_nfree(csn *N)
Definition: cs_util.c:42
int n
Definition: cs.h:20
cs * U
Definition: cs.h:65
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
int cs_usolve(const cs *U, double *x)
Definition: cs_usolve.c:3
#define CS_CSC(A)
Definition: cs.h:140
Definition: cs.h:16
int * q
Definition: cs.h:53
void * cs_malloc(int n, size_t size)
Definition: cs_malloc.c:10
css * cs_sfree(css *S)
Definition: cs_util.c:53
csn * cs_lu(const cs *A, const css *S, double tol)
Definition: cs_lu.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