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 sgtsv_(integer *n, integer *nrhs, real *dl, real *d__,
00017 real *du, real *b, integer *ldb, integer *info)
00018 {
00019
00020 integer b_dim1, b_offset, i__1, i__2;
00021 real r__1, r__2;
00022
00023
00024 integer i__, j;
00025 real fact, temp;
00026 extern int xerbla_(char *, integer *);
00027
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 --dl;
00109 --d__;
00110 --du;
00111 b_dim1 = *ldb;
00112 b_offset = 1 + b_dim1;
00113 b -= b_offset;
00114
00115
00116 *info = 0;
00117 if (*n < 0) {
00118 *info = -1;
00119 } else if (*nrhs < 0) {
00120 *info = -2;
00121 } else if (*ldb < max(1,*n)) {
00122 *info = -7;
00123 }
00124 if (*info != 0) {
00125 i__1 = -(*info);
00126 xerbla_("SGTSV ", &i__1);
00127 return 0;
00128 }
00129
00130 if (*n == 0) {
00131 return 0;
00132 }
00133
00134 if (*nrhs == 1) {
00135 i__1 = *n - 2;
00136 for (i__ = 1; i__ <= i__1; ++i__) {
00137 if ((r__1 = d__[i__], dabs(r__1)) >= (r__2 = dl[i__], dabs(r__2)))
00138 {
00139
00140
00141
00142 if (d__[i__] != 0.f) {
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.f;
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 ((r__1 = d__[i__], dabs(r__1)) >= (r__2 = dl[i__], dabs(r__2)))
00171 {
00172 if (d__[i__] != 0.f) {
00173 fact = dl[i__] / d__[i__];
00174 d__[i__ + 1] -= fact * du[i__];
00175 b[i__ + 1 + b_dim1] -= fact * b[i__ + b_dim1];
00176 } else {
00177 *info = i__;
00178 return 0;
00179 }
00180 } else {
00181 fact = d__[i__] / dl[i__];
00182 d__[i__] = dl[i__];
00183 temp = d__[i__ + 1];
00184 d__[i__ + 1] = du[i__] - fact * temp;
00185 du[i__] = temp;
00186 temp = b[i__ + b_dim1];
00187 b[i__ + b_dim1] = b[i__ + 1 + b_dim1];
00188 b[i__ + 1 + b_dim1] = temp - fact * b[i__ + 1 + b_dim1];
00189 }
00190 }
00191 if (d__[*n] == 0.f) {
00192 *info = *n;
00193 return 0;
00194 }
00195 } else {
00196 i__1 = *n - 2;
00197 for (i__ = 1; i__ <= i__1; ++i__) {
00198 if ((r__1 = d__[i__], dabs(r__1)) >= (r__2 = dl[i__], dabs(r__2)))
00199 {
00200
00201
00202
00203 if (d__[i__] != 0.f) {
00204 fact = dl[i__] / d__[i__];
00205 d__[i__ + 1] -= fact * du[i__];
00206 i__2 = *nrhs;
00207 for (j = 1; j <= i__2; ++j) {
00208 b[i__ + 1 + j * b_dim1] -= fact * b[i__ + j * b_dim1];
00209
00210 }
00211 } else {
00212 *info = i__;
00213 return 0;
00214 }
00215 dl[i__] = 0.f;
00216 } else {
00217
00218
00219
00220 fact = d__[i__] / dl[i__];
00221 d__[i__] = dl[i__];
00222 temp = d__[i__ + 1];
00223 d__[i__ + 1] = du[i__] - fact * temp;
00224 dl[i__] = du[i__ + 1];
00225 du[i__ + 1] = -fact * dl[i__];
00226 du[i__] = temp;
00227 i__2 = *nrhs;
00228 for (j = 1; j <= i__2; ++j) {
00229 temp = b[i__ + j * b_dim1];
00230 b[i__ + j * b_dim1] = b[i__ + 1 + j * b_dim1];
00231 b[i__ + 1 + j * b_dim1] = temp - fact * b[i__ + 1 + j *
00232 b_dim1];
00233
00234 }
00235 }
00236
00237 }
00238 if (*n > 1) {
00239 i__ = *n - 1;
00240 if ((r__1 = d__[i__], dabs(r__1)) >= (r__2 = dl[i__], dabs(r__2)))
00241 {
00242 if (d__[i__] != 0.f) {
00243 fact = dl[i__] / d__[i__];
00244 d__[i__ + 1] -= fact * du[i__];
00245 i__1 = *nrhs;
00246 for (j = 1; j <= i__1; ++j) {
00247 b[i__ + 1 + j * b_dim1] -= fact * b[i__ + j * b_dim1];
00248
00249 }
00250 } else {
00251 *info = i__;
00252 return 0;
00253 }
00254 } else {
00255 fact = d__[i__] / dl[i__];
00256 d__[i__] = dl[i__];
00257 temp = d__[i__ + 1];
00258 d__[i__ + 1] = du[i__] - fact * temp;
00259 du[i__] = temp;
00260 i__1 = *nrhs;
00261 for (j = 1; j <= i__1; ++j) {
00262 temp = b[i__ + j * b_dim1];
00263 b[i__ + j * b_dim1] = b[i__ + 1 + j * b_dim1];
00264 b[i__ + 1 + j * b_dim1] = temp - fact * b[i__ + 1 + j *
00265 b_dim1];
00266
00267 }
00268 }
00269 }
00270 if (d__[*n] == 0.f) {
00271 *info = *n;
00272 return 0;
00273 }
00274 }
00275
00276
00277
00278 if (*nrhs <= 2) {
00279 j = 1;
00280 L70:
00281 b[*n + j * b_dim1] /= d__[*n];
00282 if (*n > 1) {
00283 b[*n - 1 + j * b_dim1] = (b[*n - 1 + j * b_dim1] - du[*n - 1] * b[
00284 *n + j * b_dim1]) / d__[*n - 1];
00285 }
00286 for (i__ = *n - 2; i__ >= 1; --i__) {
00287 b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__] * b[i__ + 1
00288 + j * b_dim1] - dl[i__] * b[i__ + 2 + j * b_dim1]) / d__[
00289 i__];
00290
00291 }
00292 if (j < *nrhs) {
00293 ++j;
00294 goto L70;
00295 }
00296 } else {
00297 i__1 = *nrhs;
00298 for (j = 1; j <= i__1; ++j) {
00299 b[*n + j * b_dim1] /= d__[*n];
00300 if (*n > 1) {
00301 b[*n - 1 + j * b_dim1] = (b[*n - 1 + j * b_dim1] - du[*n - 1]
00302 * b[*n + j * b_dim1]) / d__[*n - 1];
00303 }
00304 for (i__ = *n - 2; i__ >= 1; --i__) {
00305 b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__] * b[i__
00306 + 1 + j * b_dim1] - dl[i__] * b[i__ + 2 + j * b_dim1])
00307 / d__[i__];
00308
00309 }
00310
00311 }
00312 }
00313
00314 return 0;
00315
00316
00317
00318 }