DSDP
|
00001 #include <stdio.h> 00002 #include <stdlib.h> 00003 #include <math.h> 00004 #include <string.h> 00005 00006 typedef enum { 00007 CfcOk=0, 00008 CfcSpace, /* fail to allocate required space */ 00009 CfcIndef /* indefinity is detected */ 00010 } cfc_sta; 00011 00012 typedef struct { 00013 int mrow; /* number of rows allocated */ 00014 int nrow; /* number of rows used */ 00015 00016 int snnz; /* number of indices for nonzeros in S */ 00017 int *shead; /* position of first nonzero in row i of S */ 00018 int *ssize; /* number of non-zeros in row i of S below */ 00019 /* the diagonal */ 00020 int *ssub; /* column index buffer for non-zeros in S */ 00021 double *diag; /* diagonal matrix D in the factorization */ 00022 double *sqrtdiag;/* sqrt o diagonal matrix D in the factorization */ 00023 00024 int unnz; /* number of nonzeros in the upper factor */ 00025 int ujnz; /* number of column indices in the compressed */ 00026 /* indices buffer ujsub */ 00027 int *ujbeg; /* beginning position of indices in row i of U */ 00028 int *uhead; /* position of first nonzero in row i of U */ 00029 int *ujsze; /* number of indices in row i of U */ 00030 int *usub; /* compressed column index buffer of U */ 00031 double *uval; /* nonzero values in factor U */ 00032 00033 int *perm; /* permutation order */ 00034 int *invp; /* inverse order of perm */ 00035 00036 int nsnds; /* number of supernodes */ 00037 int *subg; /* index of the first column in supernode i */ 00038 int ndens; /* numer of dense rows */ 00039 int nsndn; /* number supernodes in dense rows */ 00040 int *dhead; /* pointer first column in each dense row */ 00041 int *dsub; /* indices in dense rows */ 00042 int *dbeg; /* beginning of column index */ 00043 int sdens; /* separate dense row */ 00044 00045 int alldense; 00046 00047 double tolpiv; 00048 int cachesize; 00049 int cacheunit; 00050 00051 /* New */ 00052 int n; 00053 int *iw; 00054 double *rw; 00055 int factor; 00056 } chfac; 00057 00058 00059 typedef struct { 00060 int idep; 00061 int last; 00062 int most; 00063 int cure; 00064 int loca; 00065 int lowp; 00066 int ntot; 00067 00068 int *head; 00069 int *port; 00070 int *fwrd; 00071 int *bwrd; 00072 } xlist; 00073 00074 typedef struct { 00075 int nnod; 00076 int nn0; 00077 int raft; 00078 int head; 00079 int last; 00080 int ntot; 00081 00082 int *adjn; 00083 int *rbeg; 00084 int *rexs; 00085 int *rlen; 00086 int *rend; 00087 int *pres; 00088 int *succ; 00089 } order; 00090 00091 typedef enum { 00092 OptFound=0, 00093 SysError=100, 00094 OutOfSpc,CholErr 00095 } xcode; 00096 00097 #if !defined (min) 00098 #define min(a,b) ((a <= b)? (a) : (b)) 00099 #endif 00100 #if !defined (max) 00101 #define max(a,b) ((a >= b)? (a) : (b)) 00102 #endif 00103 #if !defined (sign) 00104 #define sign(a) ((a<0)? (-1) : (1)) 00105 #endif 00106 #if !defined (TRUE) 00107 #define TRUE 1 00108 #endif 00109 #if !defined (FALSE) 00110 #define FALSE 0 00111 #endif 00112 00113 #include "sdpfun.h"