Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int dgtsv_(integer *n, integer *nrhs, doublereal *dl,
00017 doublereal *d__, doublereal *du, doublereal *b, integer *ldb, integer
00018 *info)
00019 {
00020
00021 integer b_dim1, b_offset, i__1, i__2;
00022 doublereal d__1, d__2;
00023
00024
00025 integer i__, j;
00026 doublereal fact, temp;
00027 extern int xerbla_(char *, integer *);
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 --dl;
00110 --d__;
00111 --du;
00112 b_dim1 = *ldb;
00113 b_offset = 1 + b_dim1;
00114 b -= b_offset;
00115
00116
00117 *info = 0;
00118 if (*n < 0) {
00119 *info = -1;
00120 } else if (*nrhs < 0) {
00121 *info = -2;
00122 } else if (*ldb < max(1,*n)) {
00123 *info = -7;
00124 }
00125 if (*info != 0) {
00126 i__1 = -(*info);
00127 xerbla_("DGTSV ", &i__1);
00128 return 0;
00129 }
00130
00131 if (*n == 0) {
00132 return 0;
00133 }
00134
00135 if (*nrhs == 1) {
00136 i__1 = *n - 2;
00137 for (i__ = 1; i__ <= i__1; ++i__) {
00138 if ((d__1 = d__[i__], abs(d__1)) >= (d__2 = dl[i__], abs(d__2))) {
00139
00140
00141
00142 if (d__[i__] != 0.) {
00143 fact = dl[i__] / d__[i__];
00144 d__[i__ + 1] -= fact * du[i__];
00145 b[i__ + 1 + b_dim1] -= fact * b[i__ + b_dim1];
00146 } else {
00147 *info = i__;
00148 return 0;
00149 }
00150 dl[i__] = 0.;
00151 } else {
00152
00153
00154
00155 fact = d__[i__] / dl[i__];
00156 d__[i__] = dl[i__];
00157 temp = d__[i__ + 1];
00158 d__[i__ + 1] = du[i__] - fact * temp;
00159 dl[i__] = du[i__ + 1];
00160 du[i__ + 1] = -fact * dl[i__];
00161 du[i__] = temp;
00162 temp = b[i__ + b_dim1];
00163 b[i__ + b_dim1] = b[i__ + 1 + b_dim1];
00164 b[i__ + 1 + b_dim1] = temp - fact * b[i__ + 1 + b_dim1];
00165 }
00166
00167 }
00168 if (*n > 1) {
00169 i__ = *n - 1;
00170 if ((d__1 = d__[i__], abs(d__1)) >= (d__2 = dl[i__], abs(d__2))) {
00171 if (d__[i__] != 0.) {
00172 fact = dl[i__] / d__[i__];
00173 d__[i__ + 1] -= fact * du[i__];
00174 b[i__ + 1 + b_dim1] -= fact * b[i__ + b_dim1];
00175 } else {
00176 *info = i__;
00177 return 0;
00178 }
00179 } else {
00180 fact = d__[i__] / dl[i__];
00181 d__[i__] = dl[i__];
00182 temp = d__[i__ + 1];
00183 d__[i__ + 1] = du[i__] - fact * temp;
00184 du[i__] = temp;
00185 temp = b[i__ + b_dim1];
00186 b[i__ + b_dim1] = b[i__ + 1 + b_dim1];
00187 b[i__ + 1 + b_dim1] = temp - fact * b[i__ + 1 + b_dim1];
00188 }
00189 }
00190 if (d__[*n] == 0.) {
00191 *info = *n;
00192 return 0;
00193 }
00194 } else {
00195 i__1 = *n - 2;
00196 for (i__ = 1; i__ <= i__1; ++i__) {
00197 if ((d__1 = d__[i__], abs(d__1)) >= (d__2 = dl[i__], abs(d__2))) {
00198
00199
00200
00201 if (d__[i__] != 0.) {
00202 fact = dl[i__] / d__[i__];
00203 d__[i__ + 1] -= fact * du[i__];
00204 i__2 = *nrhs;
00205 for (j = 1; j <= i__2; ++j) {
00206 b[i__ + 1 + j * b_dim1] -= fact * b[i__ + j * b_dim1];
00207
00208 }
00209 } else {
00210 *info = i__;
00211 return 0;
00212 }
00213 dl[i__] = 0.;
00214 } else {
00215
00216
00217
00218 fact = d__[i__] / dl[i__];
00219 d__[i__] = dl[i__];
00220 temp = d__[i__ + 1];
00221 d__[i__ + 1] = du[i__] - fact * temp;
00222 dl[i__] = du[i__ + 1];
00223 du[i__ + 1] = -fact * dl[i__];
00224 du[i__] = temp;
00225 i__2 = *nrhs;
00226 for (j = 1; j <= i__2; ++j) {
00227 temp = b[i__ + j * b_dim1];
00228 b[i__ + j * b_dim1] = b[i__ + 1 + j * b_dim1];
00229 b[i__ + 1 + j * b_dim1] = temp - fact * b[i__ + 1 + j *
00230 b_dim1];
00231
00232 }
00233 }
00234
00235 }
00236 if (*n > 1) {
00237 i__ = *n - 1;
00238 if ((d__1 = d__[i__], abs(d__1)) >= (d__2 = dl[i__], abs(d__2))) {
00239 if (d__[i__] != 0.) {
00240 fact = dl[i__] / d__[i__];
00241 d__[i__ + 1] -= fact * du[i__];
00242 i__1 = *nrhs;
00243 for (j = 1; j <= i__1; ++j) {
00244 b[i__ + 1 + j * b_dim1] -= fact * b[i__ + j * b_dim1];
00245
00246 }
00247 } else {
00248 *info = i__;
00249 return 0;
00250 }
00251 } else {
00252 fact = d__[i__] / dl[i__];
00253 d__[i__] = dl[i__];
00254 temp = d__[i__ + 1];
00255 d__[i__ + 1] = du[i__] - fact * temp;
00256 du[i__] = temp;
00257 i__1 = *nrhs;
00258 for (j = 1; j <= i__1; ++j) {
00259 temp = b[i__ + j * b_dim1];
00260 b[i__ + j * b_dim1] = b[i__ + 1 + j * b_dim1];
00261 b[i__ + 1 + j * b_dim1] = temp - fact * b[i__ + 1 + j *
00262 b_dim1];
00263
00264 }
00265 }
00266 }
00267 if (d__[*n] == 0.) {
00268 *info = *n;
00269 return 0;
00270 }
00271 }
00272
00273
00274
00275 if (*nrhs <= 2) {
00276 j = 1;
00277 L70:
00278 b[*n + j * b_dim1] /= d__[*n];
00279 if (*n > 1) {
00280 b[*n - 1 + j * b_dim1] = (b[*n - 1 + j * b_dim1] - du[*n - 1] * b[
00281 *n + j * b_dim1]) / d__[*n - 1];
00282 }
00283 for (i__ = *n - 2; i__ >= 1; --i__) {
00284 b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__] * b[i__ + 1
00285 + j * b_dim1] - dl[i__] * b[i__ + 2 + j * b_dim1]) / d__[
00286 i__];
00287
00288 }
00289 if (j < *nrhs) {
00290 ++j;
00291 goto L70;
00292 }
00293 } else {
00294 i__1 = *nrhs;
00295 for (j = 1; j <= i__1; ++j) {
00296 b[*n + j * b_dim1] /= d__[*n];
00297 if (*n > 1) {
00298 b[*n - 1 + j * b_dim1] = (b[*n - 1 + j * b_dim1] - du[*n - 1]
00299 * b[*n + j * b_dim1]) / d__[*n - 1];
00300 }
00301 for (i__ = *n - 2; i__ >= 1; --i__) {
00302 b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__] * b[i__
00303 + 1 + j * b_dim1] - dl[i__] * b[i__ + 2 + j * b_dim1])
00304 / d__[i__];
00305
00306 }
00307
00308 }
00309 }
00310
00311 return 0;
00312
00313
00314
00315 }