00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef TEMPLATE_LAPACK_LASR_HEADER
00038 #define TEMPLATE_LAPACK_LASR_HEADER
00039
00040
00041 template<class Treal>
00042 int template_lapack_lasr(const char *side, const char *pivot, const char *direct, const integer *m,
00043 const integer *n, const Treal *c__, const Treal *s, Treal *a, const integer *
00044 lda)
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
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 integer a_dim1, a_offset, i__1, i__2;
00148
00149 integer info;
00150 Treal temp;
00151 integer i__, j;
00152 Treal ctemp, stemp;
00153 #define a_ref(a_1,a_2) a[(a_2)*a_dim1 + a_1]
00154
00155 --c__;
00156 --s;
00157 a_dim1 = *lda;
00158 a_offset = 1 + a_dim1 * 1;
00159 a -= a_offset;
00160
00161
00162 info = 0;
00163 if (! (template_blas_lsame(side, "L") || template_blas_lsame(side, "R"))) {
00164 info = 1;
00165 } else if (! (template_blas_lsame(pivot, "V") || template_blas_lsame(pivot,
00166 "T") || template_blas_lsame(pivot, "B"))) {
00167 info = 2;
00168 } else if (! (template_blas_lsame(direct, "F") || template_blas_lsame(direct,
00169 "B"))) {
00170 info = 3;
00171 } else if (*m < 0) {
00172 info = 4;
00173 } else if (*n < 0) {
00174 info = 5;
00175 } else if (*lda < maxMACRO(1,*m)) {
00176 info = 9;
00177 }
00178 if (info != 0) {
00179 template_blas_erbla("LASR ", &info);
00180 return 0;
00181 }
00182
00183
00184
00185 if (*m == 0 || *n == 0) {
00186 return 0;
00187 }
00188 if (template_blas_lsame(side, "L")) {
00189
00190
00191
00192 if (template_blas_lsame(pivot, "V")) {
00193 if (template_blas_lsame(direct, "F")) {
00194 i__1 = *m - 1;
00195 for (j = 1; j <= i__1; ++j) {
00196 ctemp = c__[j];
00197 stemp = s[j];
00198 if (ctemp != 1. || stemp != 0.) {
00199 i__2 = *n;
00200 for (i__ = 1; i__ <= i__2; ++i__) {
00201 temp = a_ref(j + 1, i__);
00202 a_ref(j + 1, i__) = ctemp * temp - stemp * a_ref(
00203 j, i__);
00204 a_ref(j, i__) = stemp * temp + ctemp * a_ref(j,
00205 i__);
00206
00207 }
00208 }
00209
00210 }
00211 } else if (template_blas_lsame(direct, "B")) {
00212 for (j = *m - 1; j >= 1; --j) {
00213 ctemp = c__[j];
00214 stemp = s[j];
00215 if (ctemp != 1. || stemp != 0.) {
00216 i__1 = *n;
00217 for (i__ = 1; i__ <= i__1; ++i__) {
00218 temp = a_ref(j + 1, i__);
00219 a_ref(j + 1, i__) = ctemp * temp - stemp * a_ref(
00220 j, i__);
00221 a_ref(j, i__) = stemp * temp + ctemp * a_ref(j,
00222 i__);
00223
00224 }
00225 }
00226
00227 }
00228 }
00229 } else if (template_blas_lsame(pivot, "T")) {
00230 if (template_blas_lsame(direct, "F")) {
00231 i__1 = *m;
00232 for (j = 2; j <= i__1; ++j) {
00233 ctemp = c__[j - 1];
00234 stemp = s[j - 1];
00235 if (ctemp != 1. || stemp != 0.) {
00236 i__2 = *n;
00237 for (i__ = 1; i__ <= i__2; ++i__) {
00238 temp = a_ref(j, i__);
00239 a_ref(j, i__) = ctemp * temp - stemp * a_ref(1,
00240 i__);
00241 a_ref(1, i__) = stemp * temp + ctemp * a_ref(1,
00242 i__);
00243
00244 }
00245 }
00246
00247 }
00248 } else if (template_blas_lsame(direct, "B")) {
00249 for (j = *m; j >= 2; --j) {
00250 ctemp = c__[j - 1];
00251 stemp = s[j - 1];
00252 if (ctemp != 1. || stemp != 0.) {
00253 i__1 = *n;
00254 for (i__ = 1; i__ <= i__1; ++i__) {
00255 temp = a_ref(j, i__);
00256 a_ref(j, i__) = ctemp * temp - stemp * a_ref(1,
00257 i__);
00258 a_ref(1, i__) = stemp * temp + ctemp * a_ref(1,
00259 i__);
00260
00261 }
00262 }
00263
00264 }
00265 }
00266 } else if (template_blas_lsame(pivot, "B")) {
00267 if (template_blas_lsame(direct, "F")) {
00268 i__1 = *m - 1;
00269 for (j = 1; j <= i__1; ++j) {
00270 ctemp = c__[j];
00271 stemp = s[j];
00272 if (ctemp != 1. || stemp != 0.) {
00273 i__2 = *n;
00274 for (i__ = 1; i__ <= i__2; ++i__) {
00275 temp = a_ref(j, i__);
00276 a_ref(j, i__) = stemp * a_ref(*m, i__) + ctemp *
00277 temp;
00278 a_ref(*m, i__) = ctemp * a_ref(*m, i__) - stemp *
00279 temp;
00280
00281 }
00282 }
00283
00284 }
00285 } else if (template_blas_lsame(direct, "B")) {
00286 for (j = *m - 1; j >= 1; --j) {
00287 ctemp = c__[j];
00288 stemp = s[j];
00289 if (ctemp != 1. || stemp != 0.) {
00290 i__1 = *n;
00291 for (i__ = 1; i__ <= i__1; ++i__) {
00292 temp = a_ref(j, i__);
00293 a_ref(j, i__) = stemp * a_ref(*m, i__) + ctemp *
00294 temp;
00295 a_ref(*m, i__) = ctemp * a_ref(*m, i__) - stemp *
00296 temp;
00297
00298 }
00299 }
00300
00301 }
00302 }
00303 }
00304 } else if (template_blas_lsame(side, "R")) {
00305
00306
00307
00308 if (template_blas_lsame(pivot, "V")) {
00309 if (template_blas_lsame(direct, "F")) {
00310 i__1 = *n - 1;
00311 for (j = 1; j <= i__1; ++j) {
00312 ctemp = c__[j];
00313 stemp = s[j];
00314 if (ctemp != 1. || stemp != 0.) {
00315 i__2 = *m;
00316 for (i__ = 1; i__ <= i__2; ++i__) {
00317 temp = a_ref(i__, j + 1);
00318 a_ref(i__, j + 1) = ctemp * temp - stemp * a_ref(
00319 i__, j);
00320 a_ref(i__, j) = stemp * temp + ctemp * a_ref(i__,
00321 j);
00322
00323 }
00324 }
00325
00326 }
00327 } else if (template_blas_lsame(direct, "B")) {
00328 for (j = *n - 1; j >= 1; --j) {
00329 ctemp = c__[j];
00330 stemp = s[j];
00331 if (ctemp != 1. || stemp != 0.) {
00332 i__1 = *m;
00333 for (i__ = 1; i__ <= i__1; ++i__) {
00334 temp = a_ref(i__, j + 1);
00335 a_ref(i__, j + 1) = ctemp * temp - stemp * a_ref(
00336 i__, j);
00337 a_ref(i__, j) = stemp * temp + ctemp * a_ref(i__,
00338 j);
00339
00340 }
00341 }
00342
00343 }
00344 }
00345 } else if (template_blas_lsame(pivot, "T")) {
00346 if (template_blas_lsame(direct, "F")) {
00347 i__1 = *n;
00348 for (j = 2; j <= i__1; ++j) {
00349 ctemp = c__[j - 1];
00350 stemp = s[j - 1];
00351 if (ctemp != 1. || stemp != 0.) {
00352 i__2 = *m;
00353 for (i__ = 1; i__ <= i__2; ++i__) {
00354 temp = a_ref(i__, j);
00355 a_ref(i__, j) = ctemp * temp - stemp * a_ref(i__,
00356 1);
00357 a_ref(i__, 1) = stemp * temp + ctemp * a_ref(i__,
00358 1);
00359
00360 }
00361 }
00362
00363 }
00364 } else if (template_blas_lsame(direct, "B")) {
00365 for (j = *n; j >= 2; --j) {
00366 ctemp = c__[j - 1];
00367 stemp = s[j - 1];
00368 if (ctemp != 1. || stemp != 0.) {
00369 i__1 = *m;
00370 for (i__ = 1; i__ <= i__1; ++i__) {
00371 temp = a_ref(i__, j);
00372 a_ref(i__, j) = ctemp * temp - stemp * a_ref(i__,
00373 1);
00374 a_ref(i__, 1) = stemp * temp + ctemp * a_ref(i__,
00375 1);
00376
00377 }
00378 }
00379
00380 }
00381 }
00382 } else if (template_blas_lsame(pivot, "B")) {
00383 if (template_blas_lsame(direct, "F")) {
00384 i__1 = *n - 1;
00385 for (j = 1; j <= i__1; ++j) {
00386 ctemp = c__[j];
00387 stemp = s[j];
00388 if (ctemp != 1. || stemp != 0.) {
00389 i__2 = *m;
00390 for (i__ = 1; i__ <= i__2; ++i__) {
00391 temp = a_ref(i__, j);
00392 a_ref(i__, j) = stemp * a_ref(i__, *n) + ctemp *
00393 temp;
00394 a_ref(i__, *n) = ctemp * a_ref(i__, *n) - stemp *
00395 temp;
00396
00397 }
00398 }
00399
00400 }
00401 } else if (template_blas_lsame(direct, "B")) {
00402 for (j = *n - 1; j >= 1; --j) {
00403 ctemp = c__[j];
00404 stemp = s[j];
00405 if (ctemp != 1. || stemp != 0.) {
00406 i__1 = *m;
00407 for (i__ = 1; i__ <= i__1; ++i__) {
00408 temp = a_ref(i__, j);
00409 a_ref(i__, j) = stemp * a_ref(i__, *n) + ctemp *
00410 temp;
00411 a_ref(i__, *n) = ctemp * a_ref(i__, *n) - stemp *
00412 temp;
00413
00414 }
00415 }
00416
00417 }
00418 }
00419 }
00420 }
00421
00422 return 0;
00423
00424
00425
00426 }
00427
00428 #undef a_ref
00429
00430
00431 #endif