00001 /* 00002 * ----------------------------------------------------------------- 00003 * $Revision: 1.4 $ 00004 * $Date: 2006/11/29 00:05:07 $ 00005 * ----------------------------------------------------------------- 00006 * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL 00007 * ----------------------------------------------------------------- 00008 * Copyright (c) 2002, The Regents of the University of California. 00009 * Produced at the Lawrence Livermore National Laboratory. 00010 * All rights reserved. 00011 * For details, see the LICENSE file. 00012 * ----------------------------------------------------------------- 00013 * This is the header file for a generic BAND linear solver 00014 * package, based on the DlsMat type defined in sundials_direct.h. 00015 * 00016 * There are two sets of band solver routines listed in 00017 * this file: one set uses type DlsMat defined below and the 00018 * other set uses the type realtype ** for band matrix arguments. 00019 * Routines that work with the type DlsMat begin with "Band". 00020 * Routines that work with realtype ** begin with "band" 00021 * ----------------------------------------------------------------- 00022 */ 00023 00024 #ifndef _SUNDIALS_BAND_H 00025 #define _SUNDIALS_BAND_H 00026 00027 #ifdef __cplusplus /* wrapper to enable C++ usage */ 00028 extern "C" { 00029 #endif 00030 00031 #include <sundials/sundials_direct.h> 00032 00033 /* 00034 * ----------------------------------------------------------------- 00035 * Function : BandGBTRF 00036 * ----------------------------------------------------------------- 00037 * Usage : ier = BandGBTRF(A, p); 00038 * if (ier != 0) ... A is singular 00039 * ----------------------------------------------------------------- 00040 * BandGBTRF performs the LU factorization of the N by N band 00041 * matrix A. This is done using standard Gaussian elimination 00042 * with partial pivoting. 00043 * 00044 * A successful LU factorization leaves the "matrix" A and the 00045 * pivot array p with the following information: 00046 * 00047 * (1) p[k] contains the row number of the pivot element chosen 00048 * at the beginning of elimination step k, k=0, 1, ..., N-1. 00049 * 00050 * (2) If the unique LU factorization of A is given by PA = LU, 00051 * where P is a permutation matrix, L is a lower triangular 00052 * matrix with all 1's on the diagonal, and U is an upper 00053 * triangular matrix, then the upper triangular part of A 00054 * (including its diagonal) contains U and the strictly lower 00055 * triangular part of A contains the multipliers, I-L. 00056 * 00057 * BandGBTRF returns 0 if successful. Otherwise it encountered 00058 * a zero diagonal element during the factorization. In this case 00059 * it returns the column index (numbered from one) at which 00060 * it encountered the zero. 00061 * 00062 * Important Note: A must be allocated to accommodate the increase 00063 * in upper bandwidth that occurs during factorization. If 00064 * mathematically, A is a band matrix with upper bandwidth mu and 00065 * lower bandwidth ml, then the upper triangular factor U can 00066 * have upper bandwidth as big as smu = MIN(n-1,mu+ml). The lower 00067 * triangular factor L has lower bandwidth ml. Allocate A with 00068 * call A = BandAllocMat(N,mu,ml,smu), where mu, ml, and smu are 00069 * as defined above. The user does not have to zero the "extra" 00070 * storage allocated for the purpose of factorization. This will 00071 * handled by the BandGBTRF routine. 00072 * 00073 * BandGBTRF is only a wrapper around bandGBTRF. All work is done 00074 * in bandGBTRF works directly on the data in the DlsMat A (i.e., 00075 * the field cols). 00076 * ----------------------------------------------------------------- 00077 */ 00078 00079 SUNDIALS_EXPORT int BandGBTRF(DlsMat A, int *p); 00080 SUNDIALS_EXPORT int bandGBTRF(realtype **a, int n, int mu, int ml, int smu, int *p); 00081 00082 /* 00083 * ----------------------------------------------------------------- 00084 * Function : BandGBTRS 00085 * ----------------------------------------------------------------- 00086 * Usage : BandGBTRS(A, p, b); 00087 * ----------------------------------------------------------------- 00088 * BandGBTRS solves the N-dimensional system A x = b using 00089 * the LU factorization in A and the pivot information in p 00090 * computed in BandGBTRF. The solution x is returned in b. This 00091 * routine cannot fail if the corresponding call to BandGBTRF 00092 * did not fail. 00093 * 00094 * BandGBTRS is only a wrapper around bandGBTRS which does all the 00095 * work directly on the data in the DlsMat A (i.e., the field cols). 00096 * ----------------------------------------------------------------- 00097 */ 00098 00099 SUNDIALS_EXPORT void BandGBTRS(DlsMat A, int *p, realtype *b); 00100 SUNDIALS_EXPORT void bandGBTRS(realtype **a, int n, int smu, int ml, int *p, realtype *b); 00101 00102 /* 00103 * ----------------------------------------------------------------- 00104 * Function : BandZero 00105 * ----------------------------------------------------------------- 00106 * Usage : BandZero(A); 00107 * ----------------------------------------------------------------- 00108 * A(i,j) <- 0.0, j-(A->mu) <= i <= j+(A->ml). 00109 * 00110 * BandZero is a wrapper around bandZero which accesses the data of 00111 * the DlsMat A (i.e. the field cols) 00112 * ----------------------------------------------------------------- 00113 */ 00114 00115 SUNDIALS_EXPORT void BandZero(DlsMat A); 00116 SUNDIALS_EXPORT void bandZero(realtype **a, int n, int mu, int ml, int smu); 00117 00118 /* 00119 * ----------------------------------------------------------------- 00120 * Function : BandCopy 00121 * ----------------------------------------------------------------- 00122 * Usage : BandCopy(A, B, copymu, copyml); 00123 * ----------------------------------------------------------------- 00124 * BandCopy copies the submatrix with upper and lower bandwidths 00125 * copymu, copyml of the N by N band matrix A into the N by N 00126 * band matrix B. 00127 * 00128 * BandCopy is a wrapper around bandCopy which accesses the data 00129 * in the DlsMat A and B (i.e. the fields cols) 00130 * ----------------------------------------------------------------- 00131 */ 00132 00133 SUNDIALS_EXPORT void BandCopy(DlsMat A, DlsMat B, int copymu, int copyml); 00134 SUNDIALS_EXPORT void bandCopy(realtype **a, realtype **b, int n, int a_smu, int b_smu, 00135 int copymu, int copyml); 00136 00137 /* 00138 * ----------------------------------------------------------------- 00139 * Function: BandScale 00140 * ----------------------------------------------------------------- 00141 * Usage : BandScale(c, A); 00142 * ----------------------------------------------------------------- 00143 * A(i,j) <- c*A(i,j), j-(A->mu) <= i <= j+(A->ml). 00144 * 00145 * BandScale is a wrapper around bandScale which performs the actual 00146 * scaling by accessing the data in the DlsMat A (i.e. the field 00147 * cols). 00148 * ----------------------------------------------------------------- 00149 */ 00150 00151 SUNDIALS_EXPORT void BandScale(realtype c, DlsMat A); 00152 SUNDIALS_EXPORT void bandScale(realtype c, realtype **a, int n, int mu, int ml, int smu); 00153 00154 /* 00155 * ----------------------------------------------------------------- 00156 * Function : BandAddI 00157 * ----------------------------------------------------------------- 00158 * Usage : BandAddI(A); 00159 * ----------------------------------------------------------------- 00160 * A(j,j) <- A(j,j)+1.0, 0 <= j <= (A->size)-1. 00161 * 00162 * BandAddI is a wrapper around bandAddI which performs the actual 00163 * work by accessing the data in the DlsMat A (i.e. the field cols) 00164 * ----------------------------------------------------------------- 00165 */ 00166 00167 SUNDIALS_EXPORT void BandAddI(DlsMat A); 00168 SUNDIALS_EXPORT void bandAddI(realtype **a, int n, int smu); 00169 00170 #ifdef __cplusplus 00171 } 00172 #endif 00173 00174 #endif