dsbgv.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /* dsbgv.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_dsbgv_(char *jobz, char *uplo, integer *n, integer *ka,
  14. integer *kb, doublereal *ab, integer *ldab, doublereal *bb, integer *
  15. ldbb, doublereal *w, doublereal *z__, integer *ldz, doublereal *work,
  16. integer *info)
  17. {
  18. /* System generated locals */
  19. integer ab_dim1, ab_offset, bb_dim1, bb_offset, z_dim1, z_offset, i__1;
  20. /* Local variables */
  21. integer inde;
  22. char vect[1];
  23. extern logical _starpu_lsame_(char *, char *);
  24. integer iinfo;
  25. logical upper, wantz;
  26. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *), _starpu_dpbstf_(
  27. char *, integer *, integer *, doublereal *, integer *, integer *), _starpu_dsbtrd_(char *, char *, integer *, integer *, doublereal
  28. *, integer *, doublereal *, doublereal *, doublereal *, integer *,
  29. doublereal *, integer *), _starpu_dsbgst_(char *, char *,
  30. integer *, integer *, integer *, doublereal *, integer *,
  31. doublereal *, integer *, doublereal *, integer *, doublereal *,
  32. integer *), _starpu_dsterf_(integer *, doublereal *,
  33. doublereal *, integer *);
  34. integer indwrk;
  35. extern /* Subroutine */ int _starpu_dsteqr_(char *, integer *, doublereal *,
  36. doublereal *, doublereal *, integer *, doublereal *, integer *);
  37. /* -- LAPACK driver routine (version 3.2) -- */
  38. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  39. /* November 2006 */
  40. /* .. Scalar Arguments .. */
  41. /* .. */
  42. /* .. Array Arguments .. */
  43. /* .. */
  44. /* Purpose */
  45. /* ======= */
  46. /* DSBGV computes all the eigenvalues, and optionally, the eigenvectors */
  47. /* of a real generalized symmetric-definite banded eigenproblem, of */
  48. /* the form A*x=(lambda)*B*x. Here A and B are assumed to be symmetric */
  49. /* and banded, and B is also positive definite. */
  50. /* Arguments */
  51. /* ========= */
  52. /* JOBZ (input) CHARACTER*1 */
  53. /* = 'N': Compute eigenvalues only; */
  54. /* = 'V': Compute eigenvalues and eigenvectors. */
  55. /* UPLO (input) CHARACTER*1 */
  56. /* = 'U': Upper triangles of A and B are stored; */
  57. /* = 'L': Lower triangles of A and B are stored. */
  58. /* N (input) INTEGER */
  59. /* The order of the matrices A and B. N >= 0. */
  60. /* KA (input) INTEGER */
  61. /* The number of superdiagonals of the matrix A if UPLO = 'U', */
  62. /* or the number of subdiagonals if UPLO = 'L'. KA >= 0. */
  63. /* KB (input) INTEGER */
  64. /* The number of superdiagonals of the matrix B if UPLO = 'U', */
  65. /* or the number of subdiagonals if UPLO = 'L'. KB >= 0. */
  66. /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB, N) */
  67. /* On entry, the upper or lower triangle of the symmetric band */
  68. /* matrix A, stored in the first ka+1 rows of the array. The */
  69. /* j-th column of A is stored in the j-th column of the array AB */
  70. /* as follows: */
  71. /* if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j; */
  72. /* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+ka). */
  73. /* On exit, the contents of AB are destroyed. */
  74. /* LDAB (input) INTEGER */
  75. /* The leading dimension of the array AB. LDAB >= KA+1. */
  76. /* BB (input/output) DOUBLE PRECISION array, dimension (LDBB, N) */
  77. /* On entry, the upper or lower triangle of the symmetric band */
  78. /* matrix B, stored in the first kb+1 rows of the array. The */
  79. /* j-th column of B is stored in the j-th column of the array BB */
  80. /* as follows: */
  81. /* if UPLO = 'U', BB(kb+1+i-j,j) = B(i,j) for max(1,j-kb)<=i<=j; */
  82. /* if UPLO = 'L', BB(1+i-j,j) = B(i,j) for j<=i<=min(n,j+kb). */
  83. /* On exit, the factor S from the split Cholesky factorization */
  84. /* B = S**T*S, as returned by DPBSTF. */
  85. /* LDBB (input) INTEGER */
  86. /* The leading dimension of the array BB. LDBB >= KB+1. */
  87. /* W (output) DOUBLE PRECISION array, dimension (N) */
  88. /* If INFO = 0, the eigenvalues in ascending order. */
  89. /* Z (output) DOUBLE PRECISION array, dimension (LDZ, N) */
  90. /* If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of */
  91. /* eigenvectors, with the i-th column of Z holding the */
  92. /* eigenvector associated with W(i). The eigenvectors are */
  93. /* normalized so that Z**T*B*Z = I. */
  94. /* If JOBZ = 'N', then Z is not referenced. */
  95. /* LDZ (input) INTEGER */
  96. /* The leading dimension of the array Z. LDZ >= 1, and if */
  97. /* JOBZ = 'V', LDZ >= N. */
  98. /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */
  99. /* INFO (output) INTEGER */
  100. /* = 0: successful exit */
  101. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  102. /* > 0: if INFO = i, and i is: */
  103. /* <= N: the algorithm failed to converge: */
  104. /* i off-diagonal elements of an intermediate */
  105. /* tridiagonal form did not converge to zero; */
  106. /* > N: if INFO = N + i, for 1 <= i <= N, then DPBSTF */
  107. /* returned INFO = i: B is not positive definite. */
  108. /* The factorization of B could not be completed and */
  109. /* no eigenvalues or eigenvectors were computed. */
  110. /* ===================================================================== */
  111. /* .. Local Scalars .. */
  112. /* .. */
  113. /* .. External Functions .. */
  114. /* .. */
  115. /* .. External Subroutines .. */
  116. /* .. */
  117. /* .. Executable Statements .. */
  118. /* Test the input parameters. */
  119. /* Parameter adjustments */
  120. ab_dim1 = *ldab;
  121. ab_offset = 1 + ab_dim1;
  122. ab -= ab_offset;
  123. bb_dim1 = *ldbb;
  124. bb_offset = 1 + bb_dim1;
  125. bb -= bb_offset;
  126. --w;
  127. z_dim1 = *ldz;
  128. z_offset = 1 + z_dim1;
  129. z__ -= z_offset;
  130. --work;
  131. /* Function Body */
  132. wantz = _starpu_lsame_(jobz, "V");
  133. upper = _starpu_lsame_(uplo, "U");
  134. *info = 0;
  135. if (! (wantz || _starpu_lsame_(jobz, "N"))) {
  136. *info = -1;
  137. } else if (! (upper || _starpu_lsame_(uplo, "L"))) {
  138. *info = -2;
  139. } else if (*n < 0) {
  140. *info = -3;
  141. } else if (*ka < 0) {
  142. *info = -4;
  143. } else if (*kb < 0 || *kb > *ka) {
  144. *info = -5;
  145. } else if (*ldab < *ka + 1) {
  146. *info = -7;
  147. } else if (*ldbb < *kb + 1) {
  148. *info = -9;
  149. } else if (*ldz < 1 || wantz && *ldz < *n) {
  150. *info = -12;
  151. }
  152. if (*info != 0) {
  153. i__1 = -(*info);
  154. _starpu_xerbla_("DSBGV ", &i__1);
  155. return 0;
  156. }
  157. /* Quick return if possible */
  158. if (*n == 0) {
  159. return 0;
  160. }
  161. /* Form a split Cholesky factorization of B. */
  162. _starpu_dpbstf_(uplo, n, kb, &bb[bb_offset], ldbb, info);
  163. if (*info != 0) {
  164. *info = *n + *info;
  165. return 0;
  166. }
  167. /* Transform problem to standard eigenvalue problem. */
  168. inde = 1;
  169. indwrk = inde + *n;
  170. _starpu_dsbgst_(jobz, uplo, n, ka, kb, &ab[ab_offset], ldab, &bb[bb_offset], ldbb,
  171. &z__[z_offset], ldz, &work[indwrk], &iinfo)
  172. ;
  173. /* Reduce to tridiagonal form. */
  174. if (wantz) {
  175. *(unsigned char *)vect = 'U';
  176. } else {
  177. *(unsigned char *)vect = 'N';
  178. }
  179. _starpu_dsbtrd_(vect, uplo, n, ka, &ab[ab_offset], ldab, &w[1], &work[inde], &z__[
  180. z_offset], ldz, &work[indwrk], &iinfo);
  181. /* For eigenvalues only, call DSTERF. For eigenvectors, call SSTEQR. */
  182. if (! wantz) {
  183. _starpu_dsterf_(n, &w[1], &work[inde], info);
  184. } else {
  185. _starpu_dsteqr_(jobz, n, &w[1], &work[inde], &z__[z_offset], ldz, &work[
  186. indwrk], info);
  187. }
  188. return 0;
  189. /* End of DSBGV */
  190. } /* _starpu_dsbgv_ */