dlaqsy.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* dlaqsy.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. /* Subroutine */ int _starpu_dlaqsy_(char *uplo, integer *n, doublereal *a, integer *
  14. lda, doublereal *s, doublereal *scond, doublereal *amax, char *equed)
  15. {
  16. /* System generated locals */
  17. integer a_dim1, a_offset, i__1, i__2;
  18. /* Local variables */
  19. integer i__, j;
  20. doublereal cj, large;
  21. extern logical _starpu_lsame_(char *, char *);
  22. doublereal small;
  23. extern doublereal _starpu_dlamch_(char *);
  24. /* -- LAPACK auxiliary routine (version 3.2) -- */
  25. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  26. /* November 2006 */
  27. /* .. Scalar Arguments .. */
  28. /* .. */
  29. /* .. Array Arguments .. */
  30. /* .. */
  31. /* Purpose */
  32. /* ======= */
  33. /* DLAQSY equilibrates a symmetric matrix A using the scaling factors */
  34. /* in the vector S. */
  35. /* Arguments */
  36. /* ========= */
  37. /* UPLO (input) CHARACTER*1 */
  38. /* Specifies whether the upper or lower triangular part of the */
  39. /* symmetric matrix A is stored. */
  40. /* = 'U': Upper triangular */
  41. /* = 'L': Lower triangular */
  42. /* N (input) INTEGER */
  43. /* The order of the matrix A. N >= 0. */
  44. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  45. /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
  46. /* n by n upper triangular part of A contains the upper */
  47. /* triangular part of the matrix A, and the strictly lower */
  48. /* triangular part of A is not referenced. If UPLO = 'L', the */
  49. /* leading n by n lower triangular part of A contains the lower */
  50. /* triangular part of the matrix A, and the strictly upper */
  51. /* triangular part of A is not referenced. */
  52. /* On exit, if EQUED = 'Y', the equilibrated matrix: */
  53. /* diag(S) * A * diag(S). */
  54. /* LDA (input) INTEGER */
  55. /* The leading dimension of the array A. LDA >= max(N,1). */
  56. /* S (input) DOUBLE PRECISION array, dimension (N) */
  57. /* The scale factors for A. */
  58. /* SCOND (input) DOUBLE PRECISION */
  59. /* Ratio of the smallest S(i) to the largest S(i). */
  60. /* AMAX (input) DOUBLE PRECISION */
  61. /* Absolute value of largest matrix entry. */
  62. /* EQUED (output) CHARACTER*1 */
  63. /* Specifies whether or not equilibration was done. */
  64. /* = 'N': No equilibration. */
  65. /* = 'Y': Equilibration was done, i.e., A has been replaced by */
  66. /* diag(S) * A * diag(S). */
  67. /* Internal Parameters */
  68. /* =================== */
  69. /* THRESH is a threshold value used to decide if scaling should be done */
  70. /* based on the ratio of the scaling factors. If SCOND < THRESH, */
  71. /* scaling is done. */
  72. /* LARGE and SMALL are threshold values used to decide if scaling should */
  73. /* be done based on the absolute size of the largest matrix element. */
  74. /* If AMAX > LARGE or AMAX < SMALL, scaling is done. */
  75. /* ===================================================================== */
  76. /* .. Parameters .. */
  77. /* .. */
  78. /* .. Local Scalars .. */
  79. /* .. */
  80. /* .. External Functions .. */
  81. /* .. */
  82. /* .. Executable Statements .. */
  83. /* Quick return if possible */
  84. /* Parameter adjustments */
  85. a_dim1 = *lda;
  86. a_offset = 1 + a_dim1;
  87. a -= a_offset;
  88. --s;
  89. /* Function Body */
  90. if (*n <= 0) {
  91. *(unsigned char *)equed = 'N';
  92. return 0;
  93. }
  94. /* Initialize LARGE and SMALL. */
  95. small = _starpu_dlamch_("Safe minimum") / _starpu_dlamch_("Precision");
  96. large = 1. / small;
  97. if (*scond >= .1 && *amax >= small && *amax <= large) {
  98. /* No equilibration */
  99. *(unsigned char *)equed = 'N';
  100. } else {
  101. /* Replace A by diag(S) * A * diag(S). */
  102. if (_starpu_lsame_(uplo, "U")) {
  103. /* Upper triangle of A is stored. */
  104. i__1 = *n;
  105. for (j = 1; j <= i__1; ++j) {
  106. cj = s[j];
  107. i__2 = j;
  108. for (i__ = 1; i__ <= i__2; ++i__) {
  109. a[i__ + j * a_dim1] = cj * s[i__] * a[i__ + j * a_dim1];
  110. /* L10: */
  111. }
  112. /* L20: */
  113. }
  114. } else {
  115. /* Lower triangle of A is stored. */
  116. i__1 = *n;
  117. for (j = 1; j <= i__1; ++j) {
  118. cj = s[j];
  119. i__2 = *n;
  120. for (i__ = j; i__ <= i__2; ++i__) {
  121. a[i__ + j * a_dim1] = cj * s[i__] * a[i__ + j * a_dim1];
  122. /* L30: */
  123. }
  124. /* L40: */
  125. }
  126. }
  127. *(unsigned char *)equed = 'Y';
  128. }
  129. return 0;
  130. /* End of DLAQSY */
  131. } /* _starpu_dlaqsy_ */