dgebak.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /* dgebak.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_dgebak_(char *job, char *side, integer *n, integer *ilo,
  14. integer *ihi, doublereal *scale, integer *m, doublereal *v, integer *
  15. ldv, integer *info)
  16. {
  17. /* System generated locals */
  18. integer v_dim1, v_offset, i__1;
  19. /* Local variables */
  20. integer i__, k;
  21. doublereal s;
  22. integer ii;
  23. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  24. integer *);
  25. extern logical _starpu_lsame_(char *, char *);
  26. extern /* Subroutine */ int _starpu_dswap_(integer *, doublereal *, integer *,
  27. doublereal *, integer *);
  28. logical leftv;
  29. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  30. logical rightv;
  31. /* -- LAPACK routine (version 3.2) -- */
  32. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  33. /* November 2006 */
  34. /* .. Scalar Arguments .. */
  35. /* .. */
  36. /* .. Array Arguments .. */
  37. /* .. */
  38. /* Purpose */
  39. /* ======= */
  40. /* DGEBAK forms the right or left eigenvectors of a real general matrix */
  41. /* by backward transformation on the computed eigenvectors of the */
  42. /* balanced matrix output by DGEBAL. */
  43. /* Arguments */
  44. /* ========= */
  45. /* JOB (input) CHARACTER*1 */
  46. /* Specifies the type of backward transformation required: */
  47. /* = 'N', do nothing, return immediately; */
  48. /* = 'P', do backward transformation for permutation only; */
  49. /* = 'S', do backward transformation for scaling only; */
  50. /* = 'B', do backward transformations for both permutation and */
  51. /* scaling. */
  52. /* JOB must be the same as the argument JOB supplied to DGEBAL. */
  53. /* SIDE (input) CHARACTER*1 */
  54. /* = 'R': V contains right eigenvectors; */
  55. /* = 'L': V contains left eigenvectors. */
  56. /* N (input) INTEGER */
  57. /* The number of rows of the matrix V. N >= 0. */
  58. /* ILO (input) INTEGER */
  59. /* IHI (input) INTEGER */
  60. /* The integers ILO and IHI determined by DGEBAL. */
  61. /* 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */
  62. /* SCALE (input) DOUBLE PRECISION array, dimension (N) */
  63. /* Details of the permutation and scaling factors, as returned */
  64. /* by DGEBAL. */
  65. /* M (input) INTEGER */
  66. /* The number of columns of the matrix V. M >= 0. */
  67. /* V (input/output) DOUBLE PRECISION array, dimension (LDV,M) */
  68. /* On entry, the matrix of right or left eigenvectors to be */
  69. /* transformed, as returned by DHSEIN or DTREVC. */
  70. /* On exit, V is overwritten by the transformed eigenvectors. */
  71. /* LDV (input) INTEGER */
  72. /* The leading dimension of the array V. LDV >= max(1,N). */
  73. /* INFO (output) INTEGER */
  74. /* = 0: successful exit */
  75. /* < 0: if INFO = -i, the i-th argument had an illegal value. */
  76. /* ===================================================================== */
  77. /* .. Parameters .. */
  78. /* .. */
  79. /* .. Local Scalars .. */
  80. /* .. */
  81. /* .. External Functions .. */
  82. /* .. */
  83. /* .. External Subroutines .. */
  84. /* .. */
  85. /* .. Intrinsic Functions .. */
  86. /* .. */
  87. /* .. Executable Statements .. */
  88. /* Decode and Test the input parameters */
  89. /* Parameter adjustments */
  90. --scale;
  91. v_dim1 = *ldv;
  92. v_offset = 1 + v_dim1;
  93. v -= v_offset;
  94. /* Function Body */
  95. rightv = _starpu_lsame_(side, "R");
  96. leftv = _starpu_lsame_(side, "L");
  97. *info = 0;
  98. if (! _starpu_lsame_(job, "N") && ! _starpu_lsame_(job, "P") && ! _starpu_lsame_(job, "S")
  99. && ! _starpu_lsame_(job, "B")) {
  100. *info = -1;
  101. } else if (! rightv && ! leftv) {
  102. *info = -2;
  103. } else if (*n < 0) {
  104. *info = -3;
  105. } else if (*ilo < 1 || *ilo > max(1,*n)) {
  106. *info = -4;
  107. } else if (*ihi < min(*ilo,*n) || *ihi > *n) {
  108. *info = -5;
  109. } else if (*m < 0) {
  110. *info = -7;
  111. } else if (*ldv < max(1,*n)) {
  112. *info = -9;
  113. }
  114. if (*info != 0) {
  115. i__1 = -(*info);
  116. _starpu_xerbla_("DGEBAK", &i__1);
  117. return 0;
  118. }
  119. /* Quick return if possible */
  120. if (*n == 0) {
  121. return 0;
  122. }
  123. if (*m == 0) {
  124. return 0;
  125. }
  126. if (_starpu_lsame_(job, "N")) {
  127. return 0;
  128. }
  129. if (*ilo == *ihi) {
  130. goto L30;
  131. }
  132. /* Backward balance */
  133. if (_starpu_lsame_(job, "S") || _starpu_lsame_(job, "B")) {
  134. if (rightv) {
  135. i__1 = *ihi;
  136. for (i__ = *ilo; i__ <= i__1; ++i__) {
  137. s = scale[i__];
  138. _starpu_dscal_(m, &s, &v[i__ + v_dim1], ldv);
  139. /* L10: */
  140. }
  141. }
  142. if (leftv) {
  143. i__1 = *ihi;
  144. for (i__ = *ilo; i__ <= i__1; ++i__) {
  145. s = 1. / scale[i__];
  146. _starpu_dscal_(m, &s, &v[i__ + v_dim1], ldv);
  147. /* L20: */
  148. }
  149. }
  150. }
  151. /* Backward permutation */
  152. /* For I = ILO-1 step -1 until 1, */
  153. /* IHI+1 step 1 until N do -- */
  154. L30:
  155. if (_starpu_lsame_(job, "P") || _starpu_lsame_(job, "B")) {
  156. if (rightv) {
  157. i__1 = *n;
  158. for (ii = 1; ii <= i__1; ++ii) {
  159. i__ = ii;
  160. if (i__ >= *ilo && i__ <= *ihi) {
  161. goto L40;
  162. }
  163. if (i__ < *ilo) {
  164. i__ = *ilo - ii;
  165. }
  166. k = (integer) scale[i__];
  167. if (k == i__) {
  168. goto L40;
  169. }
  170. _starpu_dswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
  171. L40:
  172. ;
  173. }
  174. }
  175. if (leftv) {
  176. i__1 = *n;
  177. for (ii = 1; ii <= i__1; ++ii) {
  178. i__ = ii;
  179. if (i__ >= *ilo && i__ <= *ihi) {
  180. goto L50;
  181. }
  182. if (i__ < *ilo) {
  183. i__ = *ilo - ii;
  184. }
  185. k = (integer) scale[i__];
  186. if (k == i__) {
  187. goto L50;
  188. }
  189. _starpu_dswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
  190. L50:
  191. ;
  192. }
  193. }
  194. }
  195. return 0;
  196. /* End of DGEBAK */
  197. } /* _starpu_dgebak_ */