dsycon.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /* dsycon.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_dsycon_(char *uplo, integer *n, doublereal *a, integer *
  16. lda, integer *ipiv, doublereal *anorm, doublereal *rcond, doublereal *
  17. work, integer *iwork, integer *info)
  18. {
  19. /* System generated locals */
  20. integer a_dim1, a_offset, i__1;
  21. /* Local variables */
  22. integer i__, kase;
  23. extern logical _starpu_lsame_(char *, char *);
  24. integer isave[3];
  25. logical upper;
  26. extern /* Subroutine */ int _starpu_dlacn2_(integer *, doublereal *, doublereal *,
  27. integer *, doublereal *, integer *, integer *), _starpu_xerbla_(char *,
  28. integer *);
  29. doublereal ainvnm;
  30. extern /* Subroutine */ int _starpu_dsytrs_(char *, integer *, integer *,
  31. doublereal *, integer *, integer *, doublereal *, integer *,
  32. integer *);
  33. /* -- LAPACK routine (version 3.2) -- */
  34. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  35. /* November 2006 */
  36. /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */
  37. /* .. Scalar Arguments .. */
  38. /* .. */
  39. /* .. Array Arguments .. */
  40. /* .. */
  41. /* Purpose */
  42. /* ======= */
  43. /* DSYCON estimates the reciprocal of the condition number (in the */
  44. /* 1-norm) of a real symmetric matrix A using the factorization */
  45. /* A = U*D*U**T or A = L*D*L**T computed by DSYTRF. */
  46. /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */
  47. /* condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
  48. /* Arguments */
  49. /* ========= */
  50. /* UPLO (input) CHARACTER*1 */
  51. /* Specifies whether the details of the factorization are stored */
  52. /* as an upper or lower triangular matrix. */
  53. /* = 'U': Upper triangular, form is A = U*D*U**T; */
  54. /* = 'L': Lower triangular, form is A = L*D*L**T. */
  55. /* N (input) INTEGER */
  56. /* The order of the matrix A. N >= 0. */
  57. /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
  58. /* The block diagonal matrix D and the multipliers used to */
  59. /* obtain the factor U or L as computed by DSYTRF. */
  60. /* LDA (input) INTEGER */
  61. /* The leading dimension of the array A. LDA >= max(1,N). */
  62. /* IPIV (input) INTEGER array, dimension (N) */
  63. /* Details of the interchanges and the block structure of D */
  64. /* as determined by DSYTRF. */
  65. /* ANORM (input) DOUBLE PRECISION */
  66. /* The 1-norm of the original matrix A. */
  67. /* RCOND (output) DOUBLE PRECISION */
  68. /* The reciprocal of the condition number of the matrix A, */
  69. /* computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
  70. /* estimate of the 1-norm of inv(A) computed in this routine. */
  71. /* WORK (workspace) DOUBLE PRECISION array, dimension (2*N) */
  72. /* IWORK (workspace) INTEGER array, dimension (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. /* .. Local Arrays .. */
  82. /* .. */
  83. /* .. External Functions .. */
  84. /* .. */
  85. /* .. External Subroutines .. */
  86. /* .. */
  87. /* .. Intrinsic Functions .. */
  88. /* .. */
  89. /* .. Executable Statements .. */
  90. /* Test the input parameters. */
  91. /* Parameter adjustments */
  92. a_dim1 = *lda;
  93. a_offset = 1 + a_dim1;
  94. a -= a_offset;
  95. --ipiv;
  96. --work;
  97. --iwork;
  98. /* Function Body */
  99. *info = 0;
  100. upper = _starpu_lsame_(uplo, "U");
  101. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  102. *info = -1;
  103. } else if (*n < 0) {
  104. *info = -2;
  105. } else if (*lda < max(1,*n)) {
  106. *info = -4;
  107. } else if (*anorm < 0.) {
  108. *info = -6;
  109. }
  110. if (*info != 0) {
  111. i__1 = -(*info);
  112. _starpu_xerbla_("DSYCON", &i__1);
  113. return 0;
  114. }
  115. /* Quick return if possible */
  116. *rcond = 0.;
  117. if (*n == 0) {
  118. *rcond = 1.;
  119. return 0;
  120. } else if (*anorm <= 0.) {
  121. return 0;
  122. }
  123. /* Check that the diagonal matrix D is nonsingular. */
  124. if (upper) {
  125. /* Upper triangular storage: examine D from bottom to top */
  126. for (i__ = *n; i__ >= 1; --i__) {
  127. if (ipiv[i__] > 0 && a[i__ + i__ * a_dim1] == 0.) {
  128. return 0;
  129. }
  130. /* L10: */
  131. }
  132. } else {
  133. /* Lower triangular storage: examine D from top to bottom. */
  134. i__1 = *n;
  135. for (i__ = 1; i__ <= i__1; ++i__) {
  136. if (ipiv[i__] > 0 && a[i__ + i__ * a_dim1] == 0.) {
  137. return 0;
  138. }
  139. /* L20: */
  140. }
  141. }
  142. /* Estimate the 1-norm of the inverse. */
  143. kase = 0;
  144. L30:
  145. _starpu_dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
  146. if (kase != 0) {
  147. /* Multiply by inv(L*D*L') or inv(U*D*U'). */
  148. _starpu_dsytrs_(uplo, n, &c__1, &a[a_offset], lda, &ipiv[1], &work[1], n,
  149. info);
  150. goto L30;
  151. }
  152. /* Compute the estimate of the reciprocal condition number. */
  153. if (ainvnm != 0.) {
  154. *rcond = 1. / ainvnm / *anorm;
  155. }
  156. return 0;
  157. /* End of DSYCON */
  158. } /* _starpu_dsycon_ */