dspcon.c 5.3 KB

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