drscl.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* drscl.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_drscl_(integer *n, doublereal *sa, doublereal *sx,
  14. integer *incx)
  15. {
  16. doublereal mul, cden;
  17. logical done;
  18. doublereal cnum, cden1, cnum1;
  19. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  20. integer *), _starpu_dlabad_(doublereal *, doublereal *);
  21. extern doublereal _starpu_dlamch_(char *);
  22. doublereal bignum, smlnum;
  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. /* DRSCL multiplies an n-element real vector x by the real scalar 1/a. */
  33. /* This is done without overflow or underflow as long as */
  34. /* the final result x/a does not overflow or underflow. */
  35. /* Arguments */
  36. /* ========= */
  37. /* N (input) INTEGER */
  38. /* The number of components of the vector x. */
  39. /* SA (input) DOUBLE PRECISION */
  40. /* The scalar a which is used to divide each component of x. */
  41. /* SA must be >= 0, or the subroutine will divide by zero. */
  42. /* SX (input/output) DOUBLE PRECISION array, dimension */
  43. /* (1+(N-1)*abs(INCX)) */
  44. /* The n-element vector x. */
  45. /* INCX (input) INTEGER */
  46. /* The increment between successive values of the vector SX. */
  47. /* > 0: SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i), 1< i<= n */
  48. /* ===================================================================== */
  49. /* .. Parameters .. */
  50. /* .. */
  51. /* .. Local Scalars .. */
  52. /* .. */
  53. /* .. External Functions .. */
  54. /* .. */
  55. /* .. External Subroutines .. */
  56. /* .. */
  57. /* .. Intrinsic Functions .. */
  58. /* .. */
  59. /* .. Executable Statements .. */
  60. /* Quick return if possible */
  61. /* Parameter adjustments */
  62. --sx;
  63. /* Function Body */
  64. if (*n <= 0) {
  65. return 0;
  66. }
  67. /* Get machine parameters */
  68. smlnum = _starpu_dlamch_("S");
  69. bignum = 1. / smlnum;
  70. _starpu_dlabad_(&smlnum, &bignum);
  71. /* Initialize the denominator to SA and the numerator to 1. */
  72. cden = *sa;
  73. cnum = 1.;
  74. L10:
  75. cden1 = cden * smlnum;
  76. cnum1 = cnum / bignum;
  77. if (abs(cden1) > abs(cnum) && cnum != 0.) {
  78. /* Pre-multiply X by SMLNUM if CDEN is large compared to CNUM. */
  79. mul = smlnum;
  80. done = FALSE_;
  81. cden = cden1;
  82. } else if (abs(cnum1) > abs(cden)) {
  83. /* Pre-multiply X by BIGNUM if CDEN is small compared to CNUM. */
  84. mul = bignum;
  85. done = FALSE_;
  86. cnum = cnum1;
  87. } else {
  88. /* Multiply X by CNUM / CDEN and return. */
  89. mul = cnum / cden;
  90. done = TRUE_;
  91. }
  92. /* Scale the vector X by MUL */
  93. _starpu_dscal_(n, &mul, &sx[1], incx);
  94. if (! done) {
  95. goto L10;
  96. }
  97. return 0;
  98. /* End of DRSCL */
  99. } /* _starpu_drscl_ */