dlaqsp.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* dlaqsp.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 dlaqsp_(char *uplo, integer *n, doublereal *ap,
  14. doublereal *s, doublereal *scond, doublereal *amax, char *equed)
  15. {
  16. /* System generated locals */
  17. integer i__1, i__2;
  18. /* Local variables */
  19. integer i__, j, jc;
  20. doublereal cj, large;
  21. extern logical lsame_(char *, char *);
  22. doublereal small;
  23. extern doublereal 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. /* DLAQSP 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. /* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
  45. /* On entry, the upper or lower triangle of the symmetric matrix */
  46. /* A, packed columnwise in a linear array. The j-th column of A */
  47. /* is stored in the array AP as follows: */
  48. /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
  49. /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
  50. /* On exit, the equilibrated matrix: diag(S) * A * diag(S), in */
  51. /* the same storage format as A. */
  52. /* S (input) DOUBLE PRECISION array, dimension (N) */
  53. /* The scale factors for A. */
  54. /* SCOND (input) DOUBLE PRECISION */
  55. /* Ratio of the smallest S(i) to the largest S(i). */
  56. /* AMAX (input) DOUBLE PRECISION */
  57. /* Absolute value of largest matrix entry. */
  58. /* EQUED (output) CHARACTER*1 */
  59. /* Specifies whether or not equilibration was done. */
  60. /* = 'N': No equilibration. */
  61. /* = 'Y': Equilibration was done, i.e., A has been replaced by */
  62. /* diag(S) * A * diag(S). */
  63. /* Internal Parameters */
  64. /* =================== */
  65. /* THRESH is a threshold value used to decide if scaling should be done */
  66. /* based on the ratio of the scaling factors. If SCOND < THRESH, */
  67. /* scaling is done. */
  68. /* LARGE and SMALL are threshold values used to decide if scaling should */
  69. /* be done based on the absolute size of the largest matrix element. */
  70. /* If AMAX > LARGE or AMAX < SMALL, scaling is done. */
  71. /* ===================================================================== */
  72. /* .. Parameters .. */
  73. /* .. */
  74. /* .. Local Scalars .. */
  75. /* .. */
  76. /* .. External Functions .. */
  77. /* .. */
  78. /* .. Executable Statements .. */
  79. /* Quick return if possible */
  80. /* Parameter adjustments */
  81. --s;
  82. --ap;
  83. /* Function Body */
  84. if (*n <= 0) {
  85. *(unsigned char *)equed = 'N';
  86. return 0;
  87. }
  88. /* Initialize LARGE and SMALL. */
  89. small = dlamch_("Safe minimum") / dlamch_("Precision");
  90. large = 1. / small;
  91. if (*scond >= .1 && *amax >= small && *amax <= large) {
  92. /* No equilibration */
  93. *(unsigned char *)equed = 'N';
  94. } else {
  95. /* Replace A by diag(S) * A * diag(S). */
  96. if (lsame_(uplo, "U")) {
  97. /* Upper triangle of A is stored. */
  98. jc = 1;
  99. i__1 = *n;
  100. for (j = 1; j <= i__1; ++j) {
  101. cj = s[j];
  102. i__2 = j;
  103. for (i__ = 1; i__ <= i__2; ++i__) {
  104. ap[jc + i__ - 1] = cj * s[i__] * ap[jc + i__ - 1];
  105. /* L10: */
  106. }
  107. jc += j;
  108. /* L20: */
  109. }
  110. } else {
  111. /* Lower triangle of A is stored. */
  112. jc = 1;
  113. i__1 = *n;
  114. for (j = 1; j <= i__1; ++j) {
  115. cj = s[j];
  116. i__2 = *n;
  117. for (i__ = j; i__ <= i__2; ++i__) {
  118. ap[jc + i__ - j] = cj * s[i__] * ap[jc + i__ - j];
  119. /* L30: */
  120. }
  121. jc = jc + *n - j + 1;
  122. /* L40: */
  123. }
  124. }
  125. *(unsigned char *)equed = 'Y';
  126. }
  127. return 0;
  128. /* End of DLAQSP */
  129. } /* dlaqsp_ */