Changeset 37643
- Timestamp:
- Nov 19, 2014, 7:57:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140904/Ohana/src/libohana/src/gaussj.c
r37632 r37643 1 1 # include <ohana.h> 2 # define GROWTHTEST 1 3 # define MAX_RANGE 1.0e9 2 # define GROWTHTEST 0 3 # define VERY_VERBOSE 0 4 # define MAX_RANGE 1.0e16 5 # define MIN_PIVOT 1.0e-7 4 6 5 7 // Gauss-Jordan elimination using full pivots based on Press et al's description. Substantially … … 68 70 # if (GROWTHTEST) 69 71 fprintf (stderr, "maxcol: %d\n", maxcol); 70 // fprintf (stderr, "full A matrix:\n"); 71 // for (row = 0; row < N; row++) { 72 // for (col = 0; col < N; col++) { 73 // fprintf (stderr, "%10.3e ", A[row][col]); 74 // } 75 // fprintf (stderr, "\n"); 76 // } 77 // fprintf (stderr, "\n"); 72 # if (VERY_VERBOSE) 73 fprintf (stderr, "full A matrix:\n"); 74 for (row = 0; row < N; row++) { 75 for (col = 0; col < N; col++) { 76 fprintf (stderr, "%10.3e ", A[row][col]); 77 } 78 fprintf (stderr, "\n"); 79 } 80 fprintf (stderr, "\n"); 81 # endif 78 82 # endif 79 83 … … 101 105 /* rescale by pivot reciprocal */ 102 106 double tmpval = 1.0 / A[maxcol][maxcol]; 107 108 if (fabs(A[maxcol][maxcol]) < MIN_PIVOT) { 109 // we are ill-conditioned. set this row & col to 0.0, 1.0 on pivot 110 fprintf (stderr, "WARNING: elliminating degenerate pivot %lf @ A[%d][%d]\n", A[maxcol][maxcol], maxcol, maxcol); 111 for (col = 0; col < N; col++) A[maxcol][col] = 0.0; 112 for (col = 0; col < M; col++) B[maxcol][col] = 0.0; 113 for (row = 0; row < N; row++) A[row][maxcol] = 0.0; 114 A[maxcol][maxcol] = 1.0; 115 continue; 116 } 117 118 103 119 // XXX why is this here (don't I double count this element?) A[maxcol][maxcol] = 1.0; 104 120 A[maxcol][maxcol] = 1.0; … … 112 128 # if (GROWTHTEST) 113 129 fprintf (stderr, "column: %d, maxval : %f, growth: %e, epsilon: %e\n", maxcol, tmpval, growth, epsilon); 114 // fprintf (stderr, "A diagonal: "); 115 // for (col = 0; col < N; col++) fprintf (stderr, "%f ", A[col][col]); 116 // fprintf (stderr, "\n"); 130 # if (VERY_VERBOSE) 131 fprintf (stderr, "A diagonal: "); 132 for (col = 0; col < N; col++) fprintf (stderr, "%f ", A[col][col]); 133 fprintf (stderr, "\n"); 134 # endif 117 135 # endif 118 136 … … 132 150 } 133 151 134 # if (GROWTHTEST )152 # if (GROWTHTEST && VERY_VERBOSE) 135 153 fprintf (stderr, "final A matrix:\n"); 136 //for (row = 0; row < N; row++) {137 //for (col = 0; col < N; col++) {138 //fprintf (stderr, "%10.3e ", A[row][col]);139 //}140 //fprintf (stderr, "\n");141 //}142 //fprintf (stderr, "\n");154 for (row = 0; row < N; row++) { 155 for (col = 0; col < N; col++) { 156 fprintf (stderr, "%10.3e ", A[row][col]); 157 } 158 fprintf (stderr, "\n"); 159 } 160 fprintf (stderr, "\n"); 143 161 # endif 144 162
Note:
See TracChangeset
for help on using the changeset viewer.
