Amesos Package Browser (Single Doxygen Collection) Development
amesos_klu_internal.h
Go to the documentation of this file.
00001 /* ========================================================================== */
00002 /* === KLU/Include/klu_internal.h =========================================== */
00003 /* ========================================================================== */
00004 
00005 /* For internal use in KLU routines only, not for user programs */
00006 
00007 #ifndef AMESOS_KLU_INTERNAL_H
00008 #define AMESOS_KLU_INTERNAL_H
00009 
00010 #include "amesos_klu_decl.h" 
00011 #include "amesos_btf_decl.h"
00012 #include "amesos_klu_version.h"
00013 
00014 /* ========================================================================== */
00015 /* make sure debugging and printing is turned off */
00016 
00017 #ifndef NDEBUG
00018 #define NDEBUG
00019 #endif
00020 #ifndef NPRINT
00021 #define NPRINT
00022 #endif
00023 
00024 /* To enable debugging and assertions, uncomment this line:
00025  #undef NDEBUG
00026  */
00027 
00028 /* To enable diagnostic printing, uncomment this line:
00029  #undef NPRINT
00030  */
00031 
00032 /* ========================================================================== */
00033 
00034 #include <stdio.h>
00035 #include <assert.h>
00036 #include <limits.h>
00037 #include <stdlib.h>
00038 #include <math.h>
00039 
00040 #undef ASSERT
00041 #ifndef NDEBUG
00042 #define ASSERT(a) assert(a)
00043 #else
00044 #define ASSERT(a)
00045 #endif
00046 
00047 #define SCALAR_IS_NAN(x) ((x) != (x))
00048 
00049 /* true if an integer (stored in double x) would overflow (or if x is NaN) */
00050 #define INT_OVERFLOW(x) ((!((x) * (1.0+1e-8) <= (double) INT_MAX)) \
00051       || SCALAR_IS_NAN (x))
00052 
00053 #undef TRUE
00054 #undef FALSE
00055 #undef MAX
00056 #undef MIN
00057 #undef PRINTF
00058 #undef FLIP
00059 
00060 #ifndef NPRINT
00061 #define PRINTF(s) { printf s ; } ;
00062 #else
00063 #define PRINTF(s)
00064 #endif
00065 
00066 #define TRUE 1
00067 #define FALSE 0
00068 #define MAX(a,b) (((a) > (b)) ?  (a) : (b))
00069 #define MIN(a,b) (((a) < (b)) ?  (a) : (b))
00070 
00071 /* FLIP is a "negation about -1", and is used to mark an integer i that is
00072  * normally non-negative.  FLIP (EMPTY) is EMPTY.  FLIP of a number > EMPTY
00073  * is negative, and FLIP of a number < EMTPY is positive.  FLIP (FLIP (i)) = i
00074  * for all integers i.  UNFLIP (i) is >= EMPTY. */
00075 #define EMPTY (-1)
00076 #define FLIP(i) (-(i)-2)
00077 #define UNFLIP(i) (((i) < EMPTY) ? FLIP (i) : (i))
00078 
00079 
00080 size_t KLU_kernel   /* final size of LU on output */
00081 (
00082     /* input, not modified */
00083     Int n,    /* A is n-by-n */
00084     Int Ap [ ],   /* size n+1, column pointers for A */
00085     Int Ai [ ],   /* size nz = Ap [n], row indices for A */
00086     Entry Ax [ ], /* size nz, values of A */
00087     Int Q [ ],    /* size n, optional input permutation */
00088     size_t lusize,  /* initial size of LU */
00089 
00090     /* output, not defined on input */
00091     Int Pinv [ ], /* size n */
00092     Int P [ ],    /* size n */
00093     Unit **p_LU,  /* size lusize on input, size Uxp[n] on output*/
00094     Entry Udiag [ ],  /* size n, diagonal of U */
00095     Int Llen [ ], /* size n, column length of L */
00096     Int Ulen [ ], /* size n, column length of U */
00097     Int Lip [ ],  /* size n+1 */
00098     Int Uip [ ],  /* size n+1 */
00099     Int *lnz,   /* size of L */
00100     Int *unz,   /* size of U */
00101 
00102     /* workspace, not defined on input */
00103     Entry X [ ],   /* size n, zero on output */
00104 
00105     /* workspace, not defined on input or output */
00106     Int Stack [ ],  /* size n */
00107     Int Flag [ ],   /* size n */
00108     Int adj_pos [ ],  /* size n */
00109     
00110     /* workspace for pruning only */
00111     Int Lpend [ ],  /* size n workspace */
00112 
00113     /* inputs, not modified on output */
00114     Int k1,       /* the block of A is from k1 to k2-1 */
00115     Int PSinv [ ],    /* inverse of P from symbolic factorization */
00116     double Rs [ ],    /* scale factors for A */
00117 
00118     /* inputs, modified on output */
00119     Int Offp [ ],   /* off-diagonal matrix (modified by this routine) */
00120     Int Offi [ ],
00121     Entry Offx [ ],
00122     KLU_common *Common  /* the control input/output structure */
00123 ) ;
00124 
00125 
00126 size_t KLU_kernel_factor      /* 0 if failure, size of LU if OK */
00127 (
00128     /* inputs, not modified */
00129     Int n,      /* A is n-by-n. n must be > 0. */
00130     Int Ap [ ],     /* size n+1, column pointers for A */
00131     Int Ai [ ],     /* size nz = Ap [n], row indices for A */
00132     Entry Ax [ ],   /* size nz, values of A */
00133     Int Q [ ],      /* size n, optional column permutation */
00134     double Lsize,   /* initial size of L and U */
00135 
00136     /* outputs, not defined on input */
00137     Unit **p_LU,  /* row indices and values of L and U */
00138     Entry Udiag [ ],  /* size n, diagonal of U */
00139     Int Llen [ ], /* size n, column length of L */
00140     Int Ulen [ ], /* size n, column length of U */
00141     Int Lip [ ],  /* size n+1, column pointers of L */
00142     Int Uip [ ],  /* size n+1, column pointers of U */
00143     Int P [ ],          /* row permutation, size n */
00144     Int *lnz,     /* size of L */
00145     Int *unz,       /* size of U */
00146 
00147     /* workspace, undefined on input */
00148     Entry *X,     /* size n entries.  Zero on output */
00149     Int *Work,      /* size 5n Int's */
00150 
00151     /* inputs, not modified on output */
00152     Int k1,       /* the block of A is from k1 to k2-1 */
00153     Int PSinv [ ],    /* inverse of P from symbolic factorization */
00154     double Rs [ ],    /* scale factors for A */
00155 
00156     /* inputs, modified on output */
00157     Int Offp [ ],   /* off-diagonal matrix (modified by this routine) */
00158     Int Offi [ ],
00159     Entry Offx [ ],
00160     KLU_common *Common  /* the control input/output structure */
00161 ) ;
00162 
00163 void KLU_lsolve
00164 (
00165     /* inputs, not modified: */
00166     Int n,
00167     Int Lp [ ],
00168     Int Li [ ],
00169     Unit LU [ ],
00170     Int nrhs,
00171     /* right-hand-side on input, solution to Lx=b on output */
00172     Entry X [ ]
00173 ) ;
00174 
00175 void KLU_ltsolve
00176 (
00177     /* inputs, not modified: */
00178     Int n,
00179     Int Lp [ ],
00180     Int Li [ ],
00181     Unit LU [ ],
00182     Int nrhs,
00183 #ifdef COMPLEX
00184     Int conj_solve,
00185 #endif
00186     /* right-hand-side on input, solution to L'x=b on output */
00187     Entry X [ ]
00188 ) ;
00189 
00190 
00191 void KLU_usolve
00192 (
00193     /* inputs, not modified: */
00194     Int n,
00195     Int Up [ ],
00196     Int Ui [ ],
00197     Unit LU [ ],
00198     Entry Udiag [ ],
00199     Int nrhs,
00200     /* right-hand-side on input, solution to Ux=b on output */
00201     Entry X [ ]
00202 ) ;
00203 
00204 void KLU_utsolve
00205 (
00206     /* inputs, not modified: */
00207     Int n,
00208     Int Up [ ],
00209     Int Ui [ ],
00210     Unit LU [ ],
00211     Entry Udiag [ ],
00212     Int nrhs,
00213 #ifdef COMPLEX
00214     Int conj_solve,
00215 #endif
00216     /* right-hand-side on input, solution to U'x=b on output */
00217     Entry X [ ]
00218 ) ;
00219 
00220 Int KLU_valid 
00221 (
00222     Int n, 
00223     Int Ap [ ], 
00224     Int Ai [ ], 
00225     Entry Ax [ ]
00226 ) ;
00227 
00228 Int KLU_valid_LU 
00229 (
00230     Int n, 
00231     Int flag_test_start_ptr, 
00232     Int Xip [ ],
00233     Int Xlen [ ],  
00234     Unit LU [ ]
00235 );
00236 
00237 size_t KLU_add_size_t (size_t a, size_t b, Int *ok) ;
00238 
00239 size_t KLU_mult_size_t (size_t a, size_t k, Int *ok) ;
00240 
00241 KLU_symbolic *KLU_alloc_symbolic (Int n, Int *Ap, Int *Ai, KLU_common *Common) ;
00242 
00243 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines