dstev.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* dstev.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. /* Table of constant values */
  14. static integer c__1 = 1;
  15. /* Subroutine */ int _starpu_dstev_(char *jobz, integer *n, doublereal *d__,
  16. doublereal *e, doublereal *z__, integer *ldz, doublereal *work,
  17. integer *info)
  18. {
  19. /* System generated locals */
  20. integer z_dim1, z_offset, i__1;
  21. doublereal d__1;
  22. /* Builtin functions */
  23. double sqrt(doublereal);
  24. /* Local variables */
  25. doublereal eps;
  26. integer imax;
  27. doublereal rmin, rmax, tnrm;
  28. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  29. integer *);
  30. doublereal sigma;
  31. extern logical _starpu_lsame_(char *, char *);
  32. logical wantz;
  33. extern doublereal _starpu_dlamch_(char *);
  34. integer iscale;
  35. doublereal safmin;
  36. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  37. doublereal bignum;
  38. extern doublereal _starpu_dlanst_(char *, integer *, doublereal *, doublereal *);
  39. extern /* Subroutine */ int _starpu_dsterf_(integer *, doublereal *, doublereal *,
  40. integer *), _starpu_dsteqr_(char *, integer *, doublereal *, doublereal *
  41. , doublereal *, integer *, doublereal *, integer *);
  42. doublereal smlnum;
  43. /* -- LAPACK driver routine (version 3.2) -- */
  44. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  45. /* November 2006 */
  46. /* .. Scalar Arguments .. */
  47. /* .. */
  48. /* .. Array Arguments .. */
  49. /* .. */
  50. /* Purpose */
  51. /* ======= */
  52. /* DSTEV computes all eigenvalues and, optionally, eigenvectors of a */
  53. /* real symmetric tridiagonal matrix A. */
  54. /* Arguments */
  55. /* ========= */
  56. /* JOBZ (input) CHARACTER*1 */
  57. /* = 'N': Compute eigenvalues only; */
  58. /* = 'V': Compute eigenvalues and eigenvectors. */
  59. /* N (input) INTEGER */
  60. /* The order of the matrix. N >= 0. */
  61. /* D (input/output) DOUBLE PRECISION array, dimension (N) */
  62. /* On entry, the n diagonal elements of the tridiagonal matrix */
  63. /* A. */
  64. /* On exit, if INFO = 0, the eigenvalues in ascending order. */
  65. /* E (input/output) DOUBLE PRECISION array, dimension (N-1) */
  66. /* On entry, the (n-1) subdiagonal elements of the tridiagonal */
  67. /* matrix A, stored in elements 1 to N-1 of E. */
  68. /* On exit, the contents of E are destroyed. */
  69. /* Z (output) DOUBLE PRECISION array, dimension (LDZ, N) */
  70. /* If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal */
  71. /* eigenvectors of the matrix A, with the i-th column of Z */
  72. /* holding the eigenvector associated with D(i). */
  73. /* If JOBZ = 'N', then Z is not referenced. */
  74. /* LDZ (input) INTEGER */
  75. /* The leading dimension of the array Z. LDZ >= 1, and if */
  76. /* JOBZ = 'V', LDZ >= max(1,N). */
  77. /* WORK (workspace) DOUBLE PRECISION array, dimension (max(1,2*N-2)) */
  78. /* If JOBZ = 'N', WORK is not referenced. */
  79. /* INFO (output) INTEGER */
  80. /* = 0: successful exit */
  81. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  82. /* > 0: if INFO = i, the algorithm failed to converge; i */
  83. /* off-diagonal elements of E did not converge to zero. */
  84. /* ===================================================================== */
  85. /* .. Parameters .. */
  86. /* .. */
  87. /* .. Local Scalars .. */
  88. /* .. */
  89. /* .. External Functions .. */
  90. /* .. */
  91. /* .. External Subroutines .. */
  92. /* .. */
  93. /* .. Intrinsic Functions .. */
  94. /* .. */
  95. /* .. Executable Statements .. */
  96. /* Test the input parameters. */
  97. /* Parameter adjustments */
  98. --d__;
  99. --e;
  100. z_dim1 = *ldz;
  101. z_offset = 1 + z_dim1;
  102. z__ -= z_offset;
  103. --work;
  104. /* Function Body */
  105. wantz = _starpu_lsame_(jobz, "V");
  106. *info = 0;
  107. if (! (wantz || _starpu_lsame_(jobz, "N"))) {
  108. *info = -1;
  109. } else if (*n < 0) {
  110. *info = -2;
  111. } else if (*ldz < 1 || wantz && *ldz < *n) {
  112. *info = -6;
  113. }
  114. if (*info != 0) {
  115. i__1 = -(*info);
  116. _starpu_xerbla_("DSTEV ", &i__1);
  117. return 0;
  118. }
  119. /* Quick return if possible */
  120. if (*n == 0) {
  121. return 0;
  122. }
  123. if (*n == 1) {
  124. if (wantz) {
  125. z__[z_dim1 + 1] = 1.;
  126. }
  127. return 0;
  128. }
  129. /* Get machine constants. */
  130. safmin = _starpu_dlamch_("Safe minimum");
  131. eps = _starpu_dlamch_("Precision");
  132. smlnum = safmin / eps;
  133. bignum = 1. / smlnum;
  134. rmin = sqrt(smlnum);
  135. rmax = sqrt(bignum);
  136. /* Scale matrix to allowable range, if necessary. */
  137. iscale = 0;
  138. tnrm = _starpu_dlanst_("M", n, &d__[1], &e[1]);
  139. if (tnrm > 0. && tnrm < rmin) {
  140. iscale = 1;
  141. sigma = rmin / tnrm;
  142. } else if (tnrm > rmax) {
  143. iscale = 1;
  144. sigma = rmax / tnrm;
  145. }
  146. if (iscale == 1) {
  147. _starpu_dscal_(n, &sigma, &d__[1], &c__1);
  148. i__1 = *n - 1;
  149. _starpu_dscal_(&i__1, &sigma, &e[1], &c__1);
  150. }
  151. /* For eigenvalues only, call DSTERF. For eigenvalues and */
  152. /* eigenvectors, call DSTEQR. */
  153. if (! wantz) {
  154. _starpu_dsterf_(n, &d__[1], &e[1], info);
  155. } else {
  156. _starpu_dsteqr_("I", n, &d__[1], &e[1], &z__[z_offset], ldz, &work[1], info);
  157. }
  158. /* If matrix was scaled, then rescale eigenvalues appropriately. */
  159. if (iscale == 1) {
  160. if (*info == 0) {
  161. imax = *n;
  162. } else {
  163. imax = *info - 1;
  164. }
  165. d__1 = 1. / sigma;
  166. _starpu_dscal_(&imax, &d__1, &d__[1], &c__1);
  167. }
  168. return 0;
  169. /* End of DSTEV */
  170. } /* _starpu_dstev_ */