dlaed1.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /* dlaed1.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. static integer c_n1 = -1;
  16. /* Subroutine */ int _starpu_dlaed1_(integer *n, doublereal *d__, doublereal *q,
  17. integer *ldq, integer *indxq, doublereal *rho, integer *cutpnt,
  18. doublereal *work, integer *iwork, integer *info)
  19. {
  20. /* System generated locals */
  21. integer q_dim1, q_offset, i__1, i__2;
  22. /* Local variables */
  23. integer i__, k, n1, n2, is, iw, iz, iq2, zpp1, indx, indxc;
  24. extern /* Subroutine */ int _starpu_dcopy_(integer *, doublereal *, integer *,
  25. doublereal *, integer *);
  26. integer indxp;
  27. extern /* Subroutine */ int _starpu_dlaed2_(integer *, integer *, integer *,
  28. doublereal *, doublereal *, integer *, integer *, doublereal *,
  29. doublereal *, doublereal *, doublereal *, doublereal *, integer *,
  30. integer *, integer *, integer *, integer *), _starpu_dlaed3_(integer *,
  31. integer *, integer *, doublereal *, doublereal *, integer *,
  32. doublereal *, doublereal *, doublereal *, integer *, integer *,
  33. doublereal *, doublereal *, integer *);
  34. integer idlmda;
  35. extern /* Subroutine */ int _starpu_dlamrg_(integer *, integer *, doublereal *,
  36. integer *, integer *, integer *), _starpu_xerbla_(char *, integer *);
  37. integer coltyp;
  38. /* -- LAPACK routine (version 3.2) -- */
  39. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  40. /* November 2006 */
  41. /* .. Scalar Arguments .. */
  42. /* .. */
  43. /* .. Array Arguments .. */
  44. /* .. */
  45. /* Purpose */
  46. /* ======= */
  47. /* DLAED1 computes the updated eigensystem of a diagonal */
  48. /* matrix after modification by a rank-one symmetric matrix. This */
  49. /* routine is used only for the eigenproblem which requires all */
  50. /* eigenvalues and eigenvectors of a tridiagonal matrix. DLAED7 handles */
  51. /* the case in which eigenvalues only or eigenvalues and eigenvectors */
  52. /* of a full symmetric matrix (which was reduced to tridiagonal form) */
  53. /* are desired. */
  54. /* T = Q(in) ( D(in) + RHO * Z*Z' ) Q'(in) = Q(out) * D(out) * Q'(out) */
  55. /* where Z = Q'u, u is a vector of length N with ones in the */
  56. /* CUTPNT and CUTPNT + 1 th elements and zeros elsewhere. */
  57. /* The eigenvectors of the original matrix are stored in Q, and the */
  58. /* eigenvalues are in D. The algorithm consists of three stages: */
  59. /* The first stage consists of deflating the size of the problem */
  60. /* when there are multiple eigenvalues or if there is a zero in */
  61. /* the Z vector. For each such occurence the dimension of the */
  62. /* secular equation problem is reduced by one. This stage is */
  63. /* performed by the routine DLAED2. */
  64. /* The second stage consists of calculating the updated */
  65. /* eigenvalues. This is done by finding the roots of the secular */
  66. /* equation via the routine DLAED4 (as called by DLAED3). */
  67. /* This routine also calculates the eigenvectors of the current */
  68. /* problem. */
  69. /* The final stage consists of computing the updated eigenvectors */
  70. /* directly using the updated eigenvalues. The eigenvectors for */
  71. /* the current problem are multiplied with the eigenvectors from */
  72. /* the overall problem. */
  73. /* Arguments */
  74. /* ========= */
  75. /* N (input) INTEGER */
  76. /* The dimension of the symmetric tridiagonal matrix. N >= 0. */
  77. /* D (input/output) DOUBLE PRECISION array, dimension (N) */
  78. /* On entry, the eigenvalues of the rank-1-perturbed matrix. */
  79. /* On exit, the eigenvalues of the repaired matrix. */
  80. /* Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N) */
  81. /* On entry, the eigenvectors of the rank-1-perturbed matrix. */
  82. /* On exit, the eigenvectors of the repaired tridiagonal matrix. */
  83. /* LDQ (input) INTEGER */
  84. /* The leading dimension of the array Q. LDQ >= max(1,N). */
  85. /* INDXQ (input/output) INTEGER array, dimension (N) */
  86. /* On entry, the permutation which separately sorts the two */
  87. /* subproblems in D into ascending order. */
  88. /* On exit, the permutation which will reintegrate the */
  89. /* subproblems back into sorted order, */
  90. /* i.e. D( INDXQ( I = 1, N ) ) will be in ascending order. */
  91. /* RHO (input) DOUBLE PRECISION */
  92. /* The subdiagonal entry used to create the rank-1 modification. */
  93. /* CUTPNT (input) INTEGER */
  94. /* The location of the last eigenvalue in the leading sub-matrix. */
  95. /* min(1,N) <= CUTPNT <= N/2. */
  96. /* WORK (workspace) DOUBLE PRECISION array, dimension (4*N + N**2) */
  97. /* IWORK (workspace) INTEGER array, dimension (4*N) */
  98. /* INFO (output) INTEGER */
  99. /* = 0: successful exit. */
  100. /* < 0: if INFO = -i, the i-th argument had an illegal value. */
  101. /* > 0: if INFO = 1, an eigenvalue did not converge */
  102. /* Further Details */
  103. /* =============== */
  104. /* Based on contributions by */
  105. /* Jeff Rutter, Computer Science Division, University of California */
  106. /* at Berkeley, USA */
  107. /* Modified by Francoise Tisseur, University of Tennessee. */
  108. /* ===================================================================== */
  109. /* .. Local Scalars .. */
  110. /* .. */
  111. /* .. External Subroutines .. */
  112. /* .. */
  113. /* .. Intrinsic Functions .. */
  114. /* .. */
  115. /* .. Executable Statements .. */
  116. /* Test the input parameters. */
  117. /* Parameter adjustments */
  118. --d__;
  119. q_dim1 = *ldq;
  120. q_offset = 1 + q_dim1;
  121. q -= q_offset;
  122. --indxq;
  123. --work;
  124. --iwork;
  125. /* Function Body */
  126. *info = 0;
  127. if (*n < 0) {
  128. *info = -1;
  129. } else if (*ldq < max(1,*n)) {
  130. *info = -4;
  131. } else /* if(complicated condition) */ {
  132. /* Computing MIN */
  133. i__1 = 1, i__2 = *n / 2;
  134. if (min(i__1,i__2) > *cutpnt || *n / 2 < *cutpnt) {
  135. *info = -7;
  136. }
  137. }
  138. if (*info != 0) {
  139. i__1 = -(*info);
  140. _starpu_xerbla_("DLAED1", &i__1);
  141. return 0;
  142. }
  143. /* Quick return if possible */
  144. if (*n == 0) {
  145. return 0;
  146. }
  147. /* The following values are integer pointers which indicate */
  148. /* the portion of the workspace */
  149. /* used by a particular array in DLAED2 and DLAED3. */
  150. iz = 1;
  151. idlmda = iz + *n;
  152. iw = idlmda + *n;
  153. iq2 = iw + *n;
  154. indx = 1;
  155. indxc = indx + *n;
  156. coltyp = indxc + *n;
  157. indxp = coltyp + *n;
  158. /* Form the z-vector which consists of the last row of Q_1 and the */
  159. /* first row of Q_2. */
  160. _starpu_dcopy_(cutpnt, &q[*cutpnt + q_dim1], ldq, &work[iz], &c__1);
  161. zpp1 = *cutpnt + 1;
  162. i__1 = *n - *cutpnt;
  163. _starpu_dcopy_(&i__1, &q[zpp1 + zpp1 * q_dim1], ldq, &work[iz + *cutpnt], &c__1);
  164. /* Deflate eigenvalues. */
  165. _starpu_dlaed2_(&k, n, cutpnt, &d__[1], &q[q_offset], ldq, &indxq[1], rho, &work[
  166. iz], &work[idlmda], &work[iw], &work[iq2], &iwork[indx], &iwork[
  167. indxc], &iwork[indxp], &iwork[coltyp], info);
  168. if (*info != 0) {
  169. goto L20;
  170. }
  171. /* Solve Secular Equation. */
  172. if (k != 0) {
  173. is = (iwork[coltyp] + iwork[coltyp + 1]) * *cutpnt + (iwork[coltyp +
  174. 1] + iwork[coltyp + 2]) * (*n - *cutpnt) + iq2;
  175. _starpu_dlaed3_(&k, n, cutpnt, &d__[1], &q[q_offset], ldq, rho, &work[idlmda],
  176. &work[iq2], &iwork[indxc], &iwork[coltyp], &work[iw], &work[
  177. is], info);
  178. if (*info != 0) {
  179. goto L20;
  180. }
  181. /* Prepare the INDXQ sorting permutation. */
  182. n1 = k;
  183. n2 = *n - k;
  184. _starpu_dlamrg_(&n1, &n2, &d__[1], &c__1, &c_n1, &indxq[1]);
  185. } else {
  186. i__1 = *n;
  187. for (i__ = 1; i__ <= i__1; ++i__) {
  188. indxq[i__] = i__;
  189. /* L10: */
  190. }
  191. }
  192. L20:
  193. return 0;
  194. /* End of DLAED1 */
  195. } /* _starpu_dlaed1_ */