dgtcon.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /* dgtcon.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_dgtcon_(char *norm, integer *n, doublereal *dl,
  16. doublereal *d__, doublereal *du, doublereal *du2, integer *ipiv,
  17. doublereal *anorm, doublereal *rcond, doublereal *work, integer *
  18. iwork, integer *info)
  19. {
  20. /* System generated locals */
  21. integer i__1;
  22. /* Local variables */
  23. integer i__, kase, kase1;
  24. extern logical _starpu_lsame_(char *, char *);
  25. integer isave[3];
  26. extern /* Subroutine */ int _starpu_dlacn2_(integer *, doublereal *, doublereal *,
  27. integer *, doublereal *, integer *, integer *), _starpu_xerbla_(char *,
  28. integer *);
  29. doublereal ainvnm;
  30. logical onenrm;
  31. extern /* Subroutine */ int _starpu_dgttrs_(char *, integer *, integer *,
  32. doublereal *, doublereal *, doublereal *, doublereal *, integer *,
  33. doublereal *, integer *, integer *);
  34. /* -- LAPACK routine (version 3.2) -- */
  35. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  36. /* November 2006 */
  37. /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */
  38. /* .. Scalar Arguments .. */
  39. /* .. */
  40. /* .. Array Arguments .. */
  41. /* .. */
  42. /* Purpose */
  43. /* ======= */
  44. /* DGTCON estimates the reciprocal of the condition number of a real */
  45. /* tridiagonal matrix A using the LU factorization as computed by */
  46. /* DGTTRF. */
  47. /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */
  48. /* condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
  49. /* Arguments */
  50. /* ========= */
  51. /* NORM (input) CHARACTER*1 */
  52. /* Specifies whether the 1-norm condition number or the */
  53. /* infinity-norm condition number is required: */
  54. /* = '1' or 'O': 1-norm; */
  55. /* = 'I': Infinity-norm. */
  56. /* N (input) INTEGER */
  57. /* The order of the matrix A. N >= 0. */
  58. /* DL (input) DOUBLE PRECISION array, dimension (N-1) */
  59. /* The (n-1) multipliers that define the matrix L from the */
  60. /* LU factorization of A as computed by DGTTRF. */
  61. /* D (input) DOUBLE PRECISION array, dimension (N) */
  62. /* The n diagonal elements of the upper triangular matrix U from */
  63. /* the LU factorization of A. */
  64. /* DU (input) DOUBLE PRECISION array, dimension (N-1) */
  65. /* The (n-1) elements of the first superdiagonal of U. */
  66. /* DU2 (input) DOUBLE PRECISION array, dimension (N-2) */
  67. /* The (n-2) elements of the second superdiagonal of U. */
  68. /* IPIV (input) INTEGER array, dimension (N) */
  69. /* The pivot indices; for 1 <= i <= n, row i of the matrix was */
  70. /* interchanged with row IPIV(i). IPIV(i) will always be either */
  71. /* i or i+1; IPIV(i) = i indicates a row interchange was not */
  72. /* required. */
  73. /* ANORM (input) DOUBLE PRECISION */
  74. /* If NORM = '1' or 'O', the 1-norm of the original matrix A. */
  75. /* If NORM = 'I', the infinity-norm of the original matrix A. */
  76. /* RCOND (output) DOUBLE PRECISION */
  77. /* The reciprocal of the condition number of the matrix A, */
  78. /* computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
  79. /* estimate of the 1-norm of inv(A) computed in this routine. */
  80. /* WORK (workspace) DOUBLE PRECISION array, dimension (2*N) */
  81. /* IWORK (workspace) INTEGER array, dimension (N) */
  82. /* INFO (output) INTEGER */
  83. /* = 0: successful exit */
  84. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  85. /* ===================================================================== */
  86. /* .. Parameters .. */
  87. /* .. */
  88. /* .. Local Scalars .. */
  89. /* .. */
  90. /* .. Local Arrays .. */
  91. /* .. */
  92. /* .. External Functions .. */
  93. /* .. */
  94. /* .. External Subroutines .. */
  95. /* .. */
  96. /* .. Executable Statements .. */
  97. /* Test the input arguments. */
  98. /* Parameter adjustments */
  99. --iwork;
  100. --work;
  101. --ipiv;
  102. --du2;
  103. --du;
  104. --d__;
  105. --dl;
  106. /* Function Body */
  107. *info = 0;
  108. onenrm = *(unsigned char *)norm == '1' || _starpu_lsame_(norm, "O");
  109. if (! onenrm && ! _starpu_lsame_(norm, "I")) {
  110. *info = -1;
  111. } else if (*n < 0) {
  112. *info = -2;
  113. } else if (*anorm < 0.) {
  114. *info = -8;
  115. }
  116. if (*info != 0) {
  117. i__1 = -(*info);
  118. _starpu_xerbla_("DGTCON", &i__1);
  119. return 0;
  120. }
  121. /* Quick return if possible */
  122. *rcond = 0.;
  123. if (*n == 0) {
  124. *rcond = 1.;
  125. return 0;
  126. } else if (*anorm == 0.) {
  127. return 0;
  128. }
  129. /* Check that D(1:N) is non-zero. */
  130. i__1 = *n;
  131. for (i__ = 1; i__ <= i__1; ++i__) {
  132. if (d__[i__] == 0.) {
  133. return 0;
  134. }
  135. /* L10: */
  136. }
  137. ainvnm = 0.;
  138. if (onenrm) {
  139. kase1 = 1;
  140. } else {
  141. kase1 = 2;
  142. }
  143. kase = 0;
  144. L20:
  145. _starpu_dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
  146. if (kase != 0) {
  147. if (kase == kase1) {
  148. /* Multiply by inv(U)*inv(L). */
  149. _starpu_dgttrs_("No transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1]
  150. , &ipiv[1], &work[1], n, info);
  151. } else {
  152. /* Multiply by inv(L')*inv(U'). */
  153. _starpu_dgttrs_("Transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1], &
  154. ipiv[1], &work[1], n, info);
  155. }
  156. goto L20;
  157. }
  158. /* Compute the estimate of the reciprocal condition number. */
  159. if (ainvnm != 0.) {
  160. *rcond = 1. / ainvnm / *anorm;
  161. }
  162. return 0;
  163. /* End of DGTCON */
  164. } /* _starpu_dgtcon_ */