dpocon.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /* dpocon.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_dpocon_(char *uplo, integer *n, doublereal *a, integer *
  16. lda, doublereal *anorm, doublereal *rcond, doublereal *work, integer *
  17. iwork, integer *info)
  18. {
  19. /* System generated locals */
  20. integer a_dim1, a_offset, i__1;
  21. doublereal d__1;
  22. /* Local variables */
  23. integer ix, kase;
  24. doublereal scale;
  25. extern logical _starpu_lsame_(char *, char *);
  26. integer isave[3];
  27. extern /* Subroutine */ int _starpu_drscl_(integer *, doublereal *, doublereal *,
  28. integer *);
  29. logical upper;
  30. extern /* Subroutine */ int _starpu_dlacn2_(integer *, doublereal *, doublereal *,
  31. integer *, doublereal *, integer *, integer *);
  32. extern doublereal _starpu_dlamch_(char *);
  33. doublereal scalel;
  34. extern integer _starpu_idamax_(integer *, doublereal *, integer *);
  35. doublereal scaleu;
  36. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  37. doublereal ainvnm;
  38. extern /* Subroutine */ int _starpu_dlatrs_(char *, char *, char *, char *,
  39. integer *, doublereal *, integer *, doublereal *, doublereal *,
  40. doublereal *, integer *);
  41. char normin[1];
  42. doublereal smlnum;
  43. /* -- LAPACK routine (version 3.2) -- */
  44. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  45. /* November 2006 */
  46. /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */
  47. /* .. Scalar Arguments .. */
  48. /* .. */
  49. /* .. Array Arguments .. */
  50. /* .. */
  51. /* Purpose */
  52. /* ======= */
  53. /* DPOCON estimates the reciprocal of the condition number (in the */
  54. /* 1-norm) of a real symmetric positive definite matrix using the */
  55. /* Cholesky factorization A = U**T*U or A = L*L**T computed by DPOTRF. */
  56. /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */
  57. /* condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
  58. /* Arguments */
  59. /* ========= */
  60. /* UPLO (input) CHARACTER*1 */
  61. /* = 'U': Upper triangle of A is stored; */
  62. /* = 'L': Lower triangle of A is stored. */
  63. /* N (input) INTEGER */
  64. /* The order of the matrix A. N >= 0. */
  65. /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
  66. /* The triangular factor U or L from the Cholesky factorization */
  67. /* A = U**T*U or A = L*L**T, as computed by DPOTRF. */
  68. /* LDA (input) INTEGER */
  69. /* The leading dimension of the array A. LDA >= max(1,N). */
  70. /* ANORM (input) DOUBLE PRECISION */
  71. /* The 1-norm (or infinity-norm) of the symmetric matrix A. */
  72. /* RCOND (output) DOUBLE PRECISION */
  73. /* The reciprocal of the condition number of the matrix A, */
  74. /* computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
  75. /* estimate of the 1-norm of inv(A) computed in this routine. */
  76. /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */
  77. /* IWORK (workspace) INTEGER array, dimension (N) */
  78. /* INFO (output) INTEGER */
  79. /* = 0: successful exit */
  80. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  81. /* ===================================================================== */
  82. /* .. Parameters .. */
  83. /* .. */
  84. /* .. Local Scalars .. */
  85. /* .. */
  86. /* .. Local Arrays .. */
  87. /* .. */
  88. /* .. External Functions .. */
  89. /* .. */
  90. /* .. External Subroutines .. */
  91. /* .. */
  92. /* .. Intrinsic Functions .. */
  93. /* .. */
  94. /* .. Executable Statements .. */
  95. /* Test the input parameters. */
  96. /* Parameter adjustments */
  97. a_dim1 = *lda;
  98. a_offset = 1 + a_dim1;
  99. a -= a_offset;
  100. --work;
  101. --iwork;
  102. /* Function Body */
  103. *info = 0;
  104. upper = _starpu_lsame_(uplo, "U");
  105. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  106. *info = -1;
  107. } else if (*n < 0) {
  108. *info = -2;
  109. } else if (*lda < max(1,*n)) {
  110. *info = -4;
  111. } else if (*anorm < 0.) {
  112. *info = -5;
  113. }
  114. if (*info != 0) {
  115. i__1 = -(*info);
  116. _starpu_xerbla_("DPOCON", &i__1);
  117. return 0;
  118. }
  119. /* Quick return if possible */
  120. *rcond = 0.;
  121. if (*n == 0) {
  122. *rcond = 1.;
  123. return 0;
  124. } else if (*anorm == 0.) {
  125. return 0;
  126. }
  127. smlnum = _starpu_dlamch_("Safe minimum");
  128. /* Estimate the 1-norm of inv(A). */
  129. kase = 0;
  130. *(unsigned char *)normin = 'N';
  131. L10:
  132. _starpu_dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
  133. if (kase != 0) {
  134. if (upper) {
  135. /* Multiply by inv(U'). */
  136. _starpu_dlatrs_("Upper", "Transpose", "Non-unit", normin, n, &a[a_offset],
  137. lda, &work[1], &scalel, &work[(*n << 1) + 1], info);
  138. *(unsigned char *)normin = 'Y';
  139. /* Multiply by inv(U). */
  140. _starpu_dlatrs_("Upper", "No transpose", "Non-unit", normin, n, &a[
  141. a_offset], lda, &work[1], &scaleu, &work[(*n << 1) + 1],
  142. info);
  143. } else {
  144. /* Multiply by inv(L). */
  145. _starpu_dlatrs_("Lower", "No transpose", "Non-unit", normin, n, &a[
  146. a_offset], lda, &work[1], &scalel, &work[(*n << 1) + 1],
  147. info);
  148. *(unsigned char *)normin = 'Y';
  149. /* Multiply by inv(L'). */
  150. _starpu_dlatrs_("Lower", "Transpose", "Non-unit", normin, n, &a[a_offset],
  151. lda, &work[1], &scaleu, &work[(*n << 1) + 1], info);
  152. }
  153. /* Multiply by 1/SCALE if doing so will not cause overflow. */
  154. scale = scalel * scaleu;
  155. if (scale != 1.) {
  156. ix = _starpu_idamax_(n, &work[1], &c__1);
  157. if (scale < (d__1 = work[ix], abs(d__1)) * smlnum || scale == 0.)
  158. {
  159. goto L20;
  160. }
  161. _starpu_drscl_(n, &scale, &work[1], &c__1);
  162. }
  163. goto L10;
  164. }
  165. /* Compute the estimate of the reciprocal condition number. */
  166. if (ainvnm != 0.) {
  167. *rcond = 1. / ainvnm / *anorm;
  168. }
  169. L20:
  170. return 0;
  171. /* End of DPOCON */
  172. } /* _starpu_dpocon_ */