dla_porpvgrw.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /* _starpu_dla_porpvgrw.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. doublereal _starpu_dla_porpvgrw__(char *uplo, integer *ncols, doublereal *a, integer *
  14. lda, doublereal *af, integer *ldaf, doublereal *work, ftnlen uplo_len)
  15. {
  16. /* System generated locals */
  17. integer a_dim1, a_offset, af_dim1, af_offset, i__1, i__2;
  18. doublereal ret_val, d__1, d__2, d__3;
  19. /* Local variables */
  20. integer i__, j;
  21. doublereal amax, umax;
  22. extern logical _starpu_lsame_(char *, char *);
  23. logical upper;
  24. doublereal rpvgrw;
  25. /* -- LAPACK routine (version 3.2.1) -- */
  26. /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
  27. /* -- Jason Riedy of Univ. of California Berkeley. -- */
  28. /* -- April 2009 -- */
  29. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  30. /* -- Univ. of California Berkeley and NAG Ltd. -- */
  31. /* .. */
  32. /* .. Scalar Arguments .. */
  33. /* .. */
  34. /* .. Array Arguments .. */
  35. /* .. */
  36. /* Purpose */
  37. /* ======= */
  38. /* DLA_PORPVGRW computes the reciprocal pivot growth factor */
  39. /* norm(A)/norm(U). The "max absolute element" norm is used. If this is */
  40. /* much less than 1, the stability of the LU factorization of the */
  41. /* (equilibrated) matrix A could be poor. This also means that the */
  42. /* solution X, estimated condition numbers, and error bounds could be */
  43. /* unreliable. */
  44. /* Arguments */
  45. /* ========= */
  46. /* UPLO (input) CHARACTER*1 */
  47. /* = 'U': Upper triangle of A is stored; */
  48. /* = 'L': Lower triangle of A is stored. */
  49. /* NCOLS (input) INTEGER */
  50. /* The number of columns of the matrix A. NCOLS >= 0. */
  51. /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
  52. /* On entry, the N-by-N matrix A. */
  53. /* LDA (input) INTEGER */
  54. /* The leading dimension of the array A. LDA >= max(1,N). */
  55. /* AF (input) DOUBLE PRECISION array, dimension (LDAF,N) */
  56. /* The triangular factor U or L from the Cholesky factorization */
  57. /* A = U**T*U or A = L*L**T, as computed by DPOTRF. */
  58. /* LDAF (input) INTEGER */
  59. /* The leading dimension of the array AF. LDAF >= max(1,N). */
  60. /* WORK (input) DOUBLE PRECISION array, dimension (2*N) */
  61. /* ===================================================================== */
  62. /* .. Local Scalars .. */
  63. /* .. */
  64. /* .. Intrinsic Functions .. */
  65. /* .. */
  66. /* .. External Functions .. */
  67. /* .. */
  68. /* .. Executable Statements .. */
  69. /* Parameter adjustments */
  70. a_dim1 = *lda;
  71. a_offset = 1 + a_dim1;
  72. a -= a_offset;
  73. af_dim1 = *ldaf;
  74. af_offset = 1 + af_dim1;
  75. af -= af_offset;
  76. --work;
  77. /* Function Body */
  78. upper = _starpu_lsame_("Upper", uplo);
  79. /* DPOTRF will have factored only the NCOLSxNCOLS leading minor, so */
  80. /* we restrict the growth search to that minor and use only the first */
  81. /* 2*NCOLS workspace entries. */
  82. rpvgrw = 1.;
  83. i__1 = *ncols << 1;
  84. for (i__ = 1; i__ <= i__1; ++i__) {
  85. work[i__] = 0.;
  86. }
  87. /* Find the max magnitude entry of each column. */
  88. if (upper) {
  89. i__1 = *ncols;
  90. for (j = 1; j <= i__1; ++j) {
  91. i__2 = j;
  92. for (i__ = 1; i__ <= i__2; ++i__) {
  93. /* Computing MAX */
  94. d__2 = (d__1 = a[i__ + j * a_dim1], abs(d__1)), d__3 = work[*
  95. ncols + j];
  96. work[*ncols + j] = max(d__2,d__3);
  97. }
  98. }
  99. } else {
  100. i__1 = *ncols;
  101. for (j = 1; j <= i__1; ++j) {
  102. i__2 = *ncols;
  103. for (i__ = j; i__ <= i__2; ++i__) {
  104. /* Computing MAX */
  105. d__2 = (d__1 = a[i__ + j * a_dim1], abs(d__1)), d__3 = work[*
  106. ncols + j];
  107. work[*ncols + j] = max(d__2,d__3);
  108. }
  109. }
  110. }
  111. /* Now find the max magnitude entry of each column of the factor in */
  112. /* AF. No pivoting, so no permutations. */
  113. if (_starpu_lsame_("Upper", uplo)) {
  114. i__1 = *ncols;
  115. for (j = 1; j <= i__1; ++j) {
  116. i__2 = j;
  117. for (i__ = 1; i__ <= i__2; ++i__) {
  118. /* Computing MAX */
  119. d__2 = (d__1 = af[i__ + j * af_dim1], abs(d__1)), d__3 = work[
  120. j];
  121. work[j] = max(d__2,d__3);
  122. }
  123. }
  124. } else {
  125. i__1 = *ncols;
  126. for (j = 1; j <= i__1; ++j) {
  127. i__2 = *ncols;
  128. for (i__ = j; i__ <= i__2; ++i__) {
  129. /* Computing MAX */
  130. d__2 = (d__1 = af[i__ + j * af_dim1], abs(d__1)), d__3 = work[
  131. j];
  132. work[j] = max(d__2,d__3);
  133. }
  134. }
  135. }
  136. /* Compute the *inverse* of the max element growth factor. Dividing */
  137. /* by zero would imply the largest entry of the factor's column is */
  138. /* zero. Than can happen when either the column of A is zero or */
  139. /* massive pivots made the factor underflow to zero. Neither counts */
  140. /* as growth in itself, so simply ignore terms with zero */
  141. /* denominators. */
  142. if (_starpu_lsame_("Upper", uplo)) {
  143. i__1 = *ncols;
  144. for (i__ = 1; i__ <= i__1; ++i__) {
  145. umax = work[i__];
  146. amax = work[*ncols + i__];
  147. if (umax != 0.) {
  148. /* Computing MIN */
  149. d__1 = amax / umax;
  150. rpvgrw = min(d__1,rpvgrw);
  151. }
  152. }
  153. } else {
  154. i__1 = *ncols;
  155. for (i__ = 1; i__ <= i__1; ++i__) {
  156. umax = work[i__];
  157. amax = work[*ncols + i__];
  158. if (umax != 0.) {
  159. /* Computing MIN */
  160. d__1 = amax / umax;
  161. rpvgrw = min(d__1,rpvgrw);
  162. }
  163. }
  164. }
  165. ret_val = rpvgrw;
  166. return ret_val;
  167. } /* _starpu_dla_porpvgrw__ */