EVSL  1.1.0
EigenValues Slicing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
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 CS_INT cs_lusol (CS_INT order, const cs *A, CS_ENTRY *b, double tol)
4 {
5  CS_ENTRY *x ;
6  css *S ;
7  csn *N ;
8  CS_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 = cs_malloc (n, sizeof (CS_ENTRY)) ; /* 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 }
CS_INT cs_lsolve(const cs *L, CS_ENTRY *x)
Definition: cs_lsolve.c:3
void * cs_free(void *p)
Definition: cs_malloc.c:22
css * cs_sfree(css *S)
Definition: cs_util.c:54
#define cs
Definition: cs.h:637
#define css
Definition: cs.h:688
#define CS_ENTRY
Definition: cs.h:635
CS_INT cs_ipvec(const CS_INT *p, const CS_ENTRY *b, CS_ENTRY *x, CS_INT n)
Definition: cs_ipvec.c:3
#define csn
Definition: cs.h:689
#define CS_CSC(A)
Definition: cs.h:659
css * cs_sqr(CS_INT order, const cs *A, CS_INT qr)
Definition: cs_sqr.c:60
#define CS_INT
Definition: cs.h:627
csn * cs_nfree(csn *N)
Definition: cs_util.c:43
void * cs_malloc(CS_INT n, size_t size)
Definition: cs_malloc.c:10
csn * cs_lu(const cs *A, const css *S, double tol)
Definition: cs_lu.c:3
CS_INT cs_lusol(CS_INT order, const cs *A, CS_ENTRY *b, double tol)
Definition: cs_lusol.c:3
CS_INT cs_usolve(const cs *U, CS_ENTRY *x)
Definition: cs_usolve.c:3