dppcon.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /* dppcon.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_dppcon_(char *uplo, integer *n, doublereal *ap,
  16. doublereal *anorm, doublereal *rcond, doublereal *work, integer *
  17. iwork, integer *info)
  18. {
  19. /* System generated locals */
  20. integer 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 *), _starpu_dlatps_(
  37. char *, char *, char *, char *, integer *, doublereal *,
  38. doublereal *, doublereal *, doublereal *, integer *);
  39. doublereal ainvnm;
  40. char normin[1];
  41. doublereal smlnum;
  42. /* -- LAPACK routine (version 3.2) -- */
  43. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  44. /* November 2006 */
  45. /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */
  46. /* .. Scalar Arguments .. */
  47. /* .. */
  48. /* .. Array Arguments .. */
  49. /* .. */
  50. /* Purpose */
  51. /* ======= */
  52. /* DPPCON estimates the reciprocal of the condition number (in the */
  53. /* 1-norm) of a real symmetric positive definite packed matrix using */
  54. /* the Cholesky factorization A = U**T*U or A = L*L**T computed by */
  55. /* DPPTRF. */
  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. /* AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
  66. /* The triangular factor U or L from the Cholesky factorization */
  67. /* A = U**T*U or A = L*L**T, packed columnwise in a linear */
  68. /* array. The j-th column of U or L is stored in the array AP */
  69. /* as follows: */
  70. /* if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j; */
  71. /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n. */
  72. /* ANORM (input) DOUBLE PRECISION */
  73. /* The 1-norm (or infinity-norm) of the symmetric matrix A. */
  74. /* RCOND (output) DOUBLE PRECISION */
  75. /* The reciprocal of the condition number of the matrix A, */
  76. /* computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
  77. /* estimate of the 1-norm of inv(A) computed in this routine. */
  78. /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */
  79. /* IWORK (workspace) INTEGER array, dimension (N) */
  80. /* INFO (output) INTEGER */
  81. /* = 0: successful exit */
  82. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  83. /* ===================================================================== */
  84. /* .. Parameters .. */
  85. /* .. */
  86. /* .. Local Scalars .. */
  87. /* .. */
  88. /* .. Local Arrays .. */
  89. /* .. */
  90. /* .. External Functions .. */
  91. /* .. */
  92. /* .. External Subroutines .. */
  93. /* .. */
  94. /* .. Intrinsic Functions .. */
  95. /* .. */
  96. /* .. Executable Statements .. */
  97. /* Test the input parameters. */
  98. /* Parameter adjustments */
  99. --iwork;
  100. --work;
  101. --ap;
  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 (*anorm < 0.) {
  110. *info = -4;
  111. }
  112. if (*info != 0) {
  113. i__1 = -(*info);
  114. _starpu_xerbla_("DPPCON", &i__1);
  115. return 0;
  116. }
  117. /* Quick return if possible */
  118. *rcond = 0.;
  119. if (*n == 0) {
  120. *rcond = 1.;
  121. return 0;
  122. } else if (*anorm == 0.) {
  123. return 0;
  124. }
  125. smlnum = _starpu_dlamch_("Safe minimum");
  126. /* Estimate the 1-norm of the inverse. */
  127. kase = 0;
  128. *(unsigned char *)normin = 'N';
  129. L10:
  130. _starpu_dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
  131. if (kase != 0) {
  132. if (upper) {
  133. /* Multiply by inv(U'). */
  134. _starpu_dlatps_("Upper", "Transpose", "Non-unit", normin, n, &ap[1], &
  135. work[1], &scalel, &work[(*n << 1) + 1], info);
  136. *(unsigned char *)normin = 'Y';
  137. /* Multiply by inv(U). */
  138. _starpu_dlatps_("Upper", "No transpose", "Non-unit", normin, n, &ap[1], &
  139. work[1], &scaleu, &work[(*n << 1) + 1], info);
  140. } else {
  141. /* Multiply by inv(L). */
  142. _starpu_dlatps_("Lower", "No transpose", "Non-unit", normin, n, &ap[1], &
  143. work[1], &scalel, &work[(*n << 1) + 1], info);
  144. *(unsigned char *)normin = 'Y';
  145. /* Multiply by inv(L'). */
  146. _starpu_dlatps_("Lower", "Transpose", "Non-unit", normin, n, &ap[1], &
  147. work[1], &scaleu, &work[(*n << 1) + 1], info);
  148. }
  149. /* Multiply by 1/SCALE if doing so will not cause overflow. */
  150. scale = scalel * scaleu;
  151. if (scale != 1.) {
  152. ix = _starpu_idamax_(n, &work[1], &c__1);
  153. if (scale < (d__1 = work[ix], abs(d__1)) * smlnum || scale == 0.)
  154. {
  155. goto L20;
  156. }
  157. _starpu_drscl_(n, &scale, &work[1], &c__1);
  158. }
  159. goto L10;
  160. }
  161. /* Compute the estimate of the reciprocal condition number. */
  162. if (ainvnm != 0.) {
  163. *rcond = 1. / ainvnm / *anorm;
  164. }
  165. L20:
  166. return 0;
  167. /* End of DPPCON */
  168. } /* _starpu_dppcon_ */