cs.h
Go to the documentation of this file.
00001 #ifndef _CS_H
00002 #define _CS_H
00003 #include <stdlib.h>
00004 #include <math.h>
00005 #include <stdio.h>
00006 
00007 #define CS_VER 2                    /* CSparse Version 2.2.3 */
00008 #define CS_SUBVER 2
00009 #define CS_SUBSUB 3
00010 #define CS_DATE "Jan 20, 2009"     /* CSparse release date */
00011 #define CS_COPYRIGHT "Copyright (c) Timothy A. Davis, 2006-2009"
00012 
00013 
00014 
00015 /* --- primary CSparse routines and data structures ------------------------- */
00016 typedef struct cs_sparse    /* matrix in compressed-column or triplet form */
00017 {
00018     int nzmax ;     /* maximum number of entries */
00019     int m ;         /* number of rows */
00020     int n ;         /* number of columns */
00021     int *p ;        /* column pointers (size n+1) or col indices (size nzmax) */
00022     int *i ;        /* row indices, size nzmax */
00023     double *x ;     /* numerical values, size nzmax */
00024     int nz ;        /* # of entries in triplet matrix, -1 for compressed-col */
00025 } cs ;
00026 
00027 cs *cs_add (const cs *A, const cs *B, double alpha, double beta) ;
00028 int cs_cholsol (int order, const cs *A, double *b) ;
00029 cs *cs_compress (const cs *T) ;
00030 int cs_dupl (cs *A) ;
00031 int cs_entry (cs *T, int i, int j, double x) ;
00032 int cs_gaxpy (const cs *A, const double *x, double *y) ;
00033 cs *cs_load (FILE *f) ;
00034 int cs_lusol (int order, const cs *A, double *b, double tol) ;
00035 cs *cs_multiply (const cs *A, const cs *B) ;
00036 double cs_norm (const cs *A) ;
00037 int cs_print (const cs *A, int brief) ;
00038 int cs_qrsol (int order, const cs *A, double *b) ;
00039 cs *cs_transpose (const cs *A, int values) ;
00040 /* utilities */
00041 void *cs_calloc (int n, size_t size) ;
00042 void *cs_free (void *p) ;
00043 void *cs_realloc (void *p, int n, size_t size, int *ok) ;
00044 cs *cs_spalloc (int m, int n, int nzmax, int values, int triplet) ;
00045 cs *cs_spfree (cs *A) ;
00046 int cs_sprealloc (cs *A, int nzmax) ;
00047 void *cs_malloc (int n, size_t size) ;
00048 
00049 /* --- secondary CSparse routines and data structures ----------------------- */
00050 typedef struct cs_symbolic  /* symbolic Cholesky, LU, or QR analysis */
00051 {
00052     int *pinv ;     /* inverse row perm. for QR, fill red. perm for Chol */
00053     int *q ;        /* fill-reducing column permutation for LU and QR */
00054     int *parent ;   /* elimination tree for Cholesky and QR */
00055     int *cp ;       /* column pointers for Cholesky, row counts for QR */
00056     int *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */
00057     int m2 ;        /* # of rows for QR, after adding fictitious rows */
00058     double lnz ;    /* # entries in L for LU or Cholesky; in V for QR */
00059     double unz ;    /* # entries in U for LU; in R for QR */
00060 } css ;
00061 
00062 typedef struct cs_numeric   /* numeric Cholesky, LU, or QR factorization */
00063 {
00064     cs *L ;         /* L for LU and Cholesky, V for QR */
00065     cs *U ;         /* U for LU, R for QR, not used for Cholesky */
00066     int *pinv ;     /* partial pivoting for LU */
00067     double *B ;     /* beta [0..n-1] for QR */
00068 } csn ;
00069 
00070 typedef struct cs_dmperm_results    /* cs_dmperm or cs_scc output */
00071 {
00072     int *p ;        /* size m, row permutation */
00073     int *q ;        /* size n, column permutation */
00074     int *r ;        /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */
00075     int *s ;        /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */
00076     int nb ;        /* # of blocks in fine dmperm decomposition */
00077     int rr [5] ;    /* coarse row decomposition */
00078     int cc [5] ;    /* coarse column decomposition */
00079 } csd ;
00080 
00081 int *cs_amd (int order, const cs *A) ;
00082 csn *cs_chol (const cs *A, const css *S) ;
00083 csd *cs_dmperm (const cs *A, int seed) ;
00084 int cs_droptol (cs *A, double tol) ;
00085 int cs_dropzeros (cs *A) ;
00086 int cs_happly (const cs *V, int i, double beta, double *x) ;
00087 int cs_ipvec (const int *p, const double *b, double *x, int n) ;
00088 int cs_lsolve (const cs *L, double *x) ;
00089 int cs_ltsolve (const cs *L, double *x) ;
00090 csn *cs_lu (const cs *A, const css *S, double tol) ;
00091 cs *cs_permute (const cs *A, const int *pinv, const int *q, int values) ;
00092 int *cs_pinv (const int *p, int n) ;
00093 int cs_pvec (const int *p, const double *b, double *x, int n) ;
00094 csn *cs_qr (const cs *A, const css *S) ;
00095 css *cs_schol (int order, const cs *A) ;
00096 css *cs_sqr (int order, const cs *A, int qr) ;
00097 cs *cs_symperm (const cs *A, const int *pinv, int values) ;
00098 int cs_updown (cs *L, int sigma, const cs *C, const int *parent) ;
00099 int cs_usolve (const cs *U, double *x) ;
00100 int cs_utsolve (const cs *U, double *x) ;
00101 /* utilities */
00102 css *cs_sfree (css *S) ;
00103 csn *cs_nfree (csn *N) ;
00104 csd *cs_dfree (csd *D) ;
00105 
00106 /* --- tertiary CSparse routines -------------------------------------------- */
00107 int *cs_counts (const cs *A, const int *parent, const int *post, int ata) ;
00108 double cs_cumsum (int *p, int *c, int n) ;
00109 int cs_dfs (int j, cs *G, int top, int *xi, int *pstack, const int *pinv) ;
00110 int cs_ereach (const cs *A, int k, const int *parent, int *s, int *w) ;
00111 int *cs_etree (const cs *A, int ata) ;
00112 int cs_fkeep (cs *A, int (*fkeep) (int, int, double, void *), void *other) ;
00113 double cs_house (double *x, double *beta, int n) ;
00114 int cs_leaf (int i, int j, const int *first, int *maxfirst, int *prevleaf,
00115     int *ancestor, int *jleaf) ;
00116 int *cs_maxtrans (const cs *A, int seed) ;
00117 int *cs_post (const int *parent, int n) ;
00118 int *cs_randperm (int n, int seed) ;
00119 int cs_reach (cs *G, const cs *B, int k, int *xi, const int *pinv) ;
00120 int cs_scatter (const cs *A, int j, double beta, int *w, double *x, int mark,
00121     cs *C, int nz) ;
00122 csd *cs_scc (cs *A) ;
00123 int cs_spsolve (cs *G, const cs *B, int k, int *xi, double *x,
00124     const int *pinv, int lo) ;
00125 int cs_tdfs (int j, int k, int *head, const int *next, int *post,
00126     int *stack) ;
00127 /* utilities */
00128 csd *cs_dalloc (int m, int n) ;
00129 csd *cs_ddone (csd *D, cs *C, void *w, int ok) ;
00130 cs *cs_done (cs *C, void *w, void *x, int ok) ;
00131 int *cs_idone (int *p, cs *C, void *w, int ok) ;
00132 csn *cs_ndone (csn *N, cs *C, void *w, void *x, int ok) ;
00133 
00134 #define CS_MAX(a,b) (((a) > (b)) ? (a) : (b))
00135 #define CS_MIN(a,b) (((a) < (b)) ? (a) : (b))
00136 #define CS_FLIP(i) (-(i)-2)
00137 #define CS_UNFLIP(i) (((i) < 0) ? CS_FLIP(i) : (i))
00138 #define CS_MARKED(w,j) (w [j] < 0)
00139 #define CS_MARK(w,j) { w [j] = CS_FLIP (w [j]) ; }
00140 #define CS_CSC(A) (A && (A->nz == -1))
00141 #define CS_TRIPLET(A) (A && (A->nz >= 0))
00142 #endif


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:04