dlaqge.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* dlaqge.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_dlaqge_(integer *m, integer *n, doublereal *a, integer *
  14. lda, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal
  15. *colcnd, doublereal *amax, char *equed)
  16. {
  17. /* System generated locals */
  18. integer a_dim1, a_offset, i__1, i__2;
  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. /* DLAQGE equilibrates a general M by N matrix A using the row and */
  33. /* column scaling factors in the vectors R and C. */
  34. /* Arguments */
  35. /* ========= */
  36. /* M (input) INTEGER */
  37. /* The number of rows of the matrix A. M >= 0. */
  38. /* N (input) INTEGER */
  39. /* The number of columns of the matrix A. N >= 0. */
  40. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  41. /* On entry, the M by N matrix A. */
  42. /* On exit, the equilibrated matrix. See EQUED for the form of */
  43. /* the equilibrated matrix. */
  44. /* LDA (input) INTEGER */
  45. /* The leading dimension of the array A. LDA >= max(M,1). */
  46. /* R (input) DOUBLE PRECISION array, dimension (M) */
  47. /* The row scale factors for A. */
  48. /* C (input) DOUBLE PRECISION array, dimension (N) */
  49. /* The column scale factors for A. */
  50. /* ROWCND (input) DOUBLE PRECISION */
  51. /* Ratio of the smallest R(i) to the largest R(i). */
  52. /* COLCND (input) DOUBLE PRECISION */
  53. /* Ratio of the smallest C(i) to the largest C(i). */
  54. /* AMAX (input) DOUBLE PRECISION */
  55. /* Absolute value of largest matrix entry. */
  56. /* EQUED (output) CHARACTER*1 */
  57. /* Specifies the form of equilibration that was done. */
  58. /* = 'N': No equilibration */
  59. /* = 'R': Row equilibration, i.e., A has been premultiplied by */
  60. /* diag(R). */
  61. /* = 'C': Column equilibration, i.e., A has been postmultiplied */
  62. /* by diag(C). */
  63. /* = 'B': Both row and column equilibration, i.e., A has been */
  64. /* replaced by diag(R) * A * diag(C). */
  65. /* Internal Parameters */
  66. /* =================== */
  67. /* THRESH is a threshold value used to decide if row or column scaling */
  68. /* should be done based on the ratio of the row or column scaling */
  69. /* factors. If ROWCND < THRESH, row scaling is done, and if */
  70. /* COLCND < THRESH, column scaling is done. */
  71. /* LARGE and SMALL are threshold values used to decide if row scaling */
  72. /* should be done based on the absolute size of the largest matrix */
  73. /* element. If AMAX > LARGE or AMAX < SMALL, row scaling is done. */
  74. /* ===================================================================== */
  75. /* .. Parameters .. */
  76. /* .. */
  77. /* .. Local Scalars .. */
  78. /* .. */
  79. /* .. External Functions .. */
  80. /* .. */
  81. /* .. Executable Statements .. */
  82. /* Quick return if possible */
  83. /* Parameter adjustments */
  84. a_dim1 = *lda;
  85. a_offset = 1 + a_dim1;
  86. a -= a_offset;
  87. --r__;
  88. --c__;
  89. /* Function Body */
  90. if (*m <= 0 || *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 (*rowcnd >= .1 && *amax >= small && *amax <= large) {
  98. /* No row scaling */
  99. if (*colcnd >= .1) {
  100. /* No column scaling */
  101. *(unsigned char *)equed = 'N';
  102. } else {
  103. /* Column scaling */
  104. i__1 = *n;
  105. for (j = 1; j <= i__1; ++j) {
  106. cj = c__[j];
  107. i__2 = *m;
  108. for (i__ = 1; i__ <= i__2; ++i__) {
  109. a[i__ + j * a_dim1] = cj * a[i__ + j * a_dim1];
  110. /* L10: */
  111. }
  112. /* L20: */
  113. }
  114. *(unsigned char *)equed = 'C';
  115. }
  116. } else if (*colcnd >= .1) {
  117. /* Row scaling, no column scaling */
  118. i__1 = *n;
  119. for (j = 1; j <= i__1; ++j) {
  120. i__2 = *m;
  121. for (i__ = 1; i__ <= i__2; ++i__) {
  122. a[i__ + j * a_dim1] = r__[i__] * a[i__ + j * a_dim1];
  123. /* L30: */
  124. }
  125. /* L40: */
  126. }
  127. *(unsigned char *)equed = 'R';
  128. } else {
  129. /* Row and column scaling */
  130. i__1 = *n;
  131. for (j = 1; j <= i__1; ++j) {
  132. cj = c__[j];
  133. i__2 = *m;
  134. for (i__ = 1; i__ <= i__2; ++i__) {
  135. a[i__ + j * a_dim1] = cj * r__[i__] * a[i__ + j * a_dim1];
  136. /* L50: */
  137. }
  138. /* L60: */
  139. }
  140. *(unsigned char *)equed = 'B';
  141. }
  142. return 0;
  143. /* End of DLAQGE */
  144. } /* _starpu_dlaqge_ */