00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef IFPACK_IKLU_UTILS_H
00031 #define IFPACK_IKLU_UTILS_H
00032
00033 #include <stdlib.h>
00034 #include <limits.h>
00035 #include <math.h>
00036 #include <stdio.h>
00037
00038
00039
00040
00041
00042
00043
00044 typedef struct row_matrix
00045 {
00046 int nzmax ;
00047 int m ;
00048 int n ;
00049 int *p ;
00050 int *j ;
00051 double *x ;
00052 int nz ;
00053 } csr ;
00054
00055 csr *csr_add (const csr *A, const csr *B, double alpha, double beta) ;
00056 csr *csr_multiply (const csr *A, const csr *B) ;
00057 double csr_norm (const csr *A) ;
00058 int csr_print (const csr *A, int brief) ;
00059 csr *csr_transpose (const csr *A, int values) ;
00060
00061
00062 void *csr_realloc (void *p, int n, size_t size, int *ok) ;
00063
00064
00065 csr *csr_spalloc (int m, int n, int nzmax, int values, int triplet) ;
00066 csr *csr_spfree (csr *A) ;
00067 int csr_sprealloc (csr *A, int nzmax) ;
00068
00069
00070
00071
00072 typedef struct cs_symbolic
00073 {
00074 int *pinv ;
00075 int *q ;
00076 int *parent ;
00077 int *cp ;
00078 int *leftmost ;
00079 int m2 ;
00080 double lnz ;
00081 double unz ;
00082 } css ;
00083
00084 typedef struct csr_numeric
00085 {
00086 csr *L ;
00087 csr *U ;
00088 int *pinv ;
00089 int *perm ;
00090 double *B ;
00091 } csrn ;
00092
00093 typedef struct csr_dmperm_results
00094 {
00095 int *p ;
00096 int *q ;
00097 int *r ;
00098 int *s ;
00099 int nb ;
00100 int rr [5] ;
00101 int cc [5] ;
00102 } csrd ;
00103
00104 int *csr_amd (int order, const csr *A) ;
00105
00106 int csr_droptol (csr *A, double tol);
00107 int csr_dropzeros (csr *A);
00108 int csr_lsolve (const csr *L, double *x);
00109 csrn *csr_lu (const csr *A, const css *S, double tol);
00110 csr *csr_permute (const csr *A, const int *pinv, const int *q, int values);
00111 css *csr_sqr (int order, const csr *A);
00112 int csr_usolve (const csr *U, double *x);
00113
00114
00115 css *csr_sfree (css *S) ;
00116 csrd *csr_dfree (csrd *D);
00117 csrn *csr_nfree (csrn *N);
00118
00119
00120
00121
00122 double csr_cumsum (int *p, int *c, int n) ;
00123 int csr_dfs (int j, csr *G, int top, int *xi, int *pstack, const int *pinv);
00124 int csr_reach (csr *G, const csr *B, int k, int *xi, const int *pinv);
00125 int csr_scatter (const csr *A, int j, double beta, int *w, double *x, int mark,
00126 csr *C, int nz) ;
00127 csrd *csr_scc (csr *A);
00128 int csr_spsolve (csr *G, const csr *B, int k, int *xi,
00129 double *x, const int *pinv, int up);
00130 int csr_tdfs (int j, int k, int *head, const int *next, int *post,
00131 int *stack) ;
00132
00133 csrd *csr_dalloc (int m, int n);
00134
00135 csrd *csr_ddone (csrd *D, csr *C, void *w, int ok) ;
00136 csr *csr_done (csr *C, void *w, void *x, int ok) ;
00137 int *csr_idone (int *p, csr *C, void *w, int ok) ;
00138 csrn *csr_ndone (csrn *N, csr *C, void *w, void *x, int ok) ;
00139
00140 int csr_fkeep (csr *A, int (*fkeep) (int, int, double, void *), void *other);
00141
00142 #define CS_MAX(a,b) (((a) > (b)) ? (a) : (b))
00143 #define CS_MIN(a,b) (((a) < (b)) ? (a) : (b))
00144 #define CS_FLIP(i) (-(i)-2)
00145 #define CS_UNFLIP(i) (((i) < 0) ? CS_FLIP(i) : (i))
00146 #define CS_MARKED(w,j) (w [j] < 0)
00147 #define CS_MARK(w,j) { w [j] = CS_FLIP (w [j]) ; }
00148 #define CS_CSC(A) (A && (A->nz == -1))
00149 #define CS_TRIPLET(A) (A && (A->nz >= 0))
00150
00151 #endif // IFPACK_IKLU_UTILS_H