dggbak.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /* dggbak.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Subroutine */ int _starpu_dggbak_(char *job, char *side, integer *n, integer *ilo,
  14. integer *ihi, doublereal *lscale, doublereal *rscale, integer *m,
  15. doublereal *v, integer *ldv, integer *info)
  16. {
  17. /* System generated locals */
  18. integer v_dim1, v_offset, i__1;
  19. /* Local variables */
  20. integer i__, k;
  21. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  22. integer *);
  23. extern logical _starpu_lsame_(char *, char *);
  24. extern /* Subroutine */ int _starpu_dswap_(integer *, doublereal *, integer *,
  25. doublereal *, integer *);
  26. logical leftv;
  27. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  28. logical rightv;
  29. /* -- LAPACK routine (version 3.2) -- */
  30. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  31. /* November 2006 */
  32. /* .. Scalar Arguments .. */
  33. /* .. */
  34. /* .. Array Arguments .. */
  35. /* .. */
  36. /* Purpose */
  37. /* ======= */
  38. /* DGGBAK forms the right or left eigenvectors of a real generalized */
  39. /* eigenvalue problem A*x = lambda*B*x, by backward transformation on */
  40. /* the computed eigenvectors of the balanced pair of matrices output by */
  41. /* DGGBAL. */
  42. /* Arguments */
  43. /* ========= */
  44. /* JOB (input) CHARACTER*1 */
  45. /* Specifies the type of backward transformation required: */
  46. /* = 'N': do nothing, return immediately; */
  47. /* = 'P': do backward transformation for permutation only; */
  48. /* = 'S': do backward transformation for scaling only; */
  49. /* = 'B': do backward transformations for both permutation and */
  50. /* scaling. */
  51. /* JOB must be the same as the argument JOB supplied to DGGBAL. */
  52. /* SIDE (input) CHARACTER*1 */
  53. /* = 'R': V contains right eigenvectors; */
  54. /* = 'L': V contains left eigenvectors. */
  55. /* N (input) INTEGER */
  56. /* The number of rows of the matrix V. N >= 0. */
  57. /* ILO (input) INTEGER */
  58. /* IHI (input) INTEGER */
  59. /* The integers ILO and IHI determined by DGGBAL. */
  60. /* 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */
  61. /* LSCALE (input) DOUBLE PRECISION array, dimension (N) */
  62. /* Details of the permutations and/or scaling factors applied */
  63. /* to the left side of A and B, as returned by DGGBAL. */
  64. /* RSCALE (input) DOUBLE PRECISION array, dimension (N) */
  65. /* Details of the permutations and/or scaling factors applied */
  66. /* to the right side of A and B, as returned by DGGBAL. */
  67. /* M (input) INTEGER */
  68. /* The number of columns of the matrix V. M >= 0. */
  69. /* V (input/output) DOUBLE PRECISION array, dimension (LDV,M) */
  70. /* On entry, the matrix of right or left eigenvectors to be */
  71. /* transformed, as returned by DTGEVC. */
  72. /* On exit, V is overwritten by the transformed eigenvectors. */
  73. /* LDV (input) INTEGER */
  74. /* The leading dimension of the matrix V. LDV >= max(1,N). */
  75. /* INFO (output) INTEGER */
  76. /* = 0: successful exit. */
  77. /* < 0: if INFO = -i, the i-th argument had an illegal value. */
  78. /* Further Details */
  79. /* =============== */
  80. /* See R.C. Ward, Balancing the generalized eigenvalue problem, */
  81. /* SIAM J. Sci. Stat. Comp. 2 (1981), 141-152. */
  82. /* ===================================================================== */
  83. /* .. Local Scalars .. */
  84. /* .. */
  85. /* .. External Functions .. */
  86. /* .. */
  87. /* .. External Subroutines .. */
  88. /* .. */
  89. /* .. Intrinsic Functions .. */
  90. /* .. */
  91. /* .. Executable Statements .. */
  92. /* Test the input parameters */
  93. /* Parameter adjustments */
  94. --lscale;
  95. --rscale;
  96. v_dim1 = *ldv;
  97. v_offset = 1 + v_dim1;
  98. v -= v_offset;
  99. /* Function Body */
  100. rightv = _starpu_lsame_(side, "R");
  101. leftv = _starpu_lsame_(side, "L");
  102. *info = 0;
  103. if (! _starpu_lsame_(job, "N") && ! _starpu_lsame_(job, "P") && ! _starpu_lsame_(job, "S")
  104. && ! _starpu_lsame_(job, "B")) {
  105. *info = -1;
  106. } else if (! rightv && ! leftv) {
  107. *info = -2;
  108. } else if (*n < 0) {
  109. *info = -3;
  110. } else if (*ilo < 1) {
  111. *info = -4;
  112. } else if (*n == 0 && *ihi == 0 && *ilo != 1) {
  113. *info = -4;
  114. } else if (*n > 0 && (*ihi < *ilo || *ihi > max(1,*n))) {
  115. *info = -5;
  116. } else if (*n == 0 && *ilo == 1 && *ihi != 0) {
  117. *info = -5;
  118. } else if (*m < 0) {
  119. *info = -8;
  120. } else if (*ldv < max(1,*n)) {
  121. *info = -10;
  122. }
  123. if (*info != 0) {
  124. i__1 = -(*info);
  125. _starpu_xerbla_("DGGBAK", &i__1);
  126. return 0;
  127. }
  128. /* Quick return if possible */
  129. if (*n == 0) {
  130. return 0;
  131. }
  132. if (*m == 0) {
  133. return 0;
  134. }
  135. if (_starpu_lsame_(job, "N")) {
  136. return 0;
  137. }
  138. if (*ilo == *ihi) {
  139. goto L30;
  140. }
  141. /* Backward balance */
  142. if (_starpu_lsame_(job, "S") || _starpu_lsame_(job, "B")) {
  143. /* Backward transformation on right eigenvectors */
  144. if (rightv) {
  145. i__1 = *ihi;
  146. for (i__ = *ilo; i__ <= i__1; ++i__) {
  147. _starpu_dscal_(m, &rscale[i__], &v[i__ + v_dim1], ldv);
  148. /* L10: */
  149. }
  150. }
  151. /* Backward transformation on left eigenvectors */
  152. if (leftv) {
  153. i__1 = *ihi;
  154. for (i__ = *ilo; i__ <= i__1; ++i__) {
  155. _starpu_dscal_(m, &lscale[i__], &v[i__ + v_dim1], ldv);
  156. /* L20: */
  157. }
  158. }
  159. }
  160. /* Backward permutation */
  161. L30:
  162. if (_starpu_lsame_(job, "P") || _starpu_lsame_(job, "B")) {
  163. /* Backward permutation on right eigenvectors */
  164. if (rightv) {
  165. if (*ilo == 1) {
  166. goto L50;
  167. }
  168. for (i__ = *ilo - 1; i__ >= 1; --i__) {
  169. k = (integer) rscale[i__];
  170. if (k == i__) {
  171. goto L40;
  172. }
  173. _starpu_dswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
  174. L40:
  175. ;
  176. }
  177. L50:
  178. if (*ihi == *n) {
  179. goto L70;
  180. }
  181. i__1 = *n;
  182. for (i__ = *ihi + 1; i__ <= i__1; ++i__) {
  183. k = (integer) rscale[i__];
  184. if (k == i__) {
  185. goto L60;
  186. }
  187. _starpu_dswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
  188. L60:
  189. ;
  190. }
  191. }
  192. /* Backward permutation on left eigenvectors */
  193. L70:
  194. if (leftv) {
  195. if (*ilo == 1) {
  196. goto L90;
  197. }
  198. for (i__ = *ilo - 1; i__ >= 1; --i__) {
  199. k = (integer) lscale[i__];
  200. if (k == i__) {
  201. goto L80;
  202. }
  203. _starpu_dswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
  204. L80:
  205. ;
  206. }
  207. L90:
  208. if (*ihi == *n) {
  209. goto L110;
  210. }
  211. i__1 = *n;
  212. for (i__ = *ihi + 1; i__ <= i__1; ++i__) {
  213. k = (integer) lscale[i__];
  214. if (k == i__) {
  215. goto L100;
  216. }
  217. _starpu_dswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
  218. L100:
  219. ;
  220. }
  221. }
  222. }
  223. L110:
  224. return 0;
  225. /* End of DGGBAK */
  226. } /* _starpu_dggbak_ */