dlaqgb.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /* dlaqgb.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_dlaqgb_(integer *m, integer *n, integer *kl, integer *ku,
  14. doublereal *ab, integer *ldab, doublereal *r__, doublereal *c__,
  15. doublereal *rowcnd, doublereal *colcnd, doublereal *amax, char *equed)
  16. {
  17. /* System generated locals */
  18. integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6;
  19. /* Local variables */
  20. integer i__, j;
  21. doublereal cj, large, small;
  22. extern doublereal _starpu_dlamch_(char *);
  23. /* -- LAPACK auxiliary routine (version 3.2) -- */
  24. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  25. /* November 2006 */
  26. /* .. Scalar Arguments .. */
  27. /* .. */
  28. /* .. Array Arguments .. */
  29. /* .. */
  30. /* Purpose */
  31. /* ======= */
  32. /* DLAQGB equilibrates a general M by N band matrix A with KL */
  33. /* subdiagonals and KU superdiagonals using the row and scaling factors */
  34. /* in the vectors R and C. */
  35. /* Arguments */
  36. /* ========= */
  37. /* M (input) INTEGER */
  38. /* The number of rows of the matrix A. M >= 0. */
  39. /* N (input) INTEGER */
  40. /* The number of columns of the matrix A. N >= 0. */
  41. /* KL (input) INTEGER */
  42. /* The number of subdiagonals within the band of A. KL >= 0. */
  43. /* KU (input) INTEGER */
  44. /* The number of superdiagonals within the band of A. KU >= 0. */
  45. /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */
  46. /* On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */
  47. /* The j-th column of A is stored in the j-th column of the */
  48. /* array AB as follows: */
  49. /* AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl) */
  50. /* On exit, the equilibrated matrix, in the same storage format */
  51. /* as A. See EQUED for the form of the equilibrated matrix. */
  52. /* LDAB (input) INTEGER */
  53. /* The leading dimension of the array AB. LDA >= KL+KU+1. */
  54. /* R (input) DOUBLE PRECISION array, dimension (M) */
  55. /* The row scale factors for A. */
  56. /* C (input) DOUBLE PRECISION array, dimension (N) */
  57. /* The column scale factors for A. */
  58. /* ROWCND (input) DOUBLE PRECISION */
  59. /* Ratio of the smallest R(i) to the largest R(i). */
  60. /* COLCND (input) DOUBLE PRECISION */
  61. /* Ratio of the smallest C(i) to the largest C(i). */
  62. /* AMAX (input) DOUBLE PRECISION */
  63. /* Absolute value of largest matrix entry. */
  64. /* EQUED (output) CHARACTER*1 */
  65. /* Specifies the form of equilibration that was done. */
  66. /* = 'N': No equilibration */
  67. /* = 'R': Row equilibration, i.e., A has been premultiplied by */
  68. /* diag(R). */
  69. /* = 'C': Column equilibration, i.e., A has been postmultiplied */
  70. /* by diag(C). */
  71. /* = 'B': Both row and column equilibration, i.e., A has been */
  72. /* replaced by diag(R) * A * diag(C). */
  73. /* Internal Parameters */
  74. /* =================== */
  75. /* THRESH is a threshold value used to decide if row or column scaling */
  76. /* should be done based on the ratio of the row or column scaling */
  77. /* factors. If ROWCND < THRESH, row scaling is done, and if */
  78. /* COLCND < THRESH, column scaling is done. */
  79. /* LARGE and SMALL are threshold values used to decide if row scaling */
  80. /* should be done based on the absolute size of the largest matrix */
  81. /* element. If AMAX > LARGE or AMAX < SMALL, row scaling is done. */
  82. /* ===================================================================== */
  83. /* .. Parameters .. */
  84. /* .. */
  85. /* .. Local Scalars .. */
  86. /* .. */
  87. /* .. External Functions .. */
  88. /* .. */
  89. /* .. Intrinsic Functions .. */
  90. /* .. */
  91. /* .. Executable Statements .. */
  92. /* Quick return if possible */
  93. /* Parameter adjustments */
  94. ab_dim1 = *ldab;
  95. ab_offset = 1 + ab_dim1;
  96. ab -= ab_offset;
  97. --r__;
  98. --c__;
  99. /* Function Body */
  100. if (*m <= 0 || *n <= 0) {
  101. *(unsigned char *)equed = 'N';
  102. return 0;
  103. }
  104. /* Initialize LARGE and SMALL. */
  105. small = _starpu_dlamch_("Safe minimum") / _starpu_dlamch_("Precision");
  106. large = 1. / small;
  107. if (*rowcnd >= .1 && *amax >= small && *amax <= large) {
  108. /* No row scaling */
  109. if (*colcnd >= .1) {
  110. /* No column scaling */
  111. *(unsigned char *)equed = 'N';
  112. } else {
  113. /* Column scaling */
  114. i__1 = *n;
  115. for (j = 1; j <= i__1; ++j) {
  116. cj = c__[j];
  117. /* Computing MAX */
  118. i__2 = 1, i__3 = j - *ku;
  119. /* Computing MIN */
  120. i__5 = *m, i__6 = j + *kl;
  121. i__4 = min(i__5,i__6);
  122. for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
  123. ab[*ku + 1 + i__ - j + j * ab_dim1] = cj * ab[*ku + 1 +
  124. i__ - j + j * ab_dim1];
  125. /* L10: */
  126. }
  127. /* L20: */
  128. }
  129. *(unsigned char *)equed = 'C';
  130. }
  131. } else if (*colcnd >= .1) {
  132. /* Row scaling, no column scaling */
  133. i__1 = *n;
  134. for (j = 1; j <= i__1; ++j) {
  135. /* Computing MAX */
  136. i__4 = 1, i__2 = j - *ku;
  137. /* Computing MIN */
  138. i__5 = *m, i__6 = j + *kl;
  139. i__3 = min(i__5,i__6);
  140. for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
  141. ab[*ku + 1 + i__ - j + j * ab_dim1] = r__[i__] * ab[*ku + 1 +
  142. i__ - j + j * ab_dim1];
  143. /* L30: */
  144. }
  145. /* L40: */
  146. }
  147. *(unsigned char *)equed = 'R';
  148. } else {
  149. /* Row and column scaling */
  150. i__1 = *n;
  151. for (j = 1; j <= i__1; ++j) {
  152. cj = c__[j];
  153. /* Computing MAX */
  154. i__3 = 1, i__4 = j - *ku;
  155. /* Computing MIN */
  156. i__5 = *m, i__6 = j + *kl;
  157. i__2 = min(i__5,i__6);
  158. for (i__ = max(i__3,i__4); i__ <= i__2; ++i__) {
  159. ab[*ku + 1 + i__ - j + j * ab_dim1] = cj * r__[i__] * ab[*ku
  160. + 1 + i__ - j + j * ab_dim1];
  161. /* L50: */
  162. }
  163. /* L60: */
  164. }
  165. *(unsigned char *)equed = 'B';
  166. }
  167. return 0;
  168. /* End of DLAQGB */
  169. } /* _starpu_dlaqgb_ */