dlaqsb.c 5.3 KB

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