dscal.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* dscal.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 dscal_(integer *n, doublereal *da, doublereal *dx,
  14. integer *incx)
  15. {
  16. /* System generated locals */
  17. integer i__1, i__2;
  18. /* Local variables */
  19. integer i__, m, mp1, nincx;
  20. /* .. Scalar Arguments .. */
  21. /* .. */
  22. /* .. Array Arguments .. */
  23. /* .. */
  24. /* Purpose */
  25. /* ======= */
  26. /* * */
  27. /* scales a vector by a constant. */
  28. /* uses unrolled loops for increment equal to one. */
  29. /* jack dongarra, linpack, 3/11/78. */
  30. /* modified 3/93 to return if incx .le. 0. */
  31. /* modified 12/3/93, array(1) declarations changed to array(*) */
  32. /* .. Local Scalars .. */
  33. /* .. */
  34. /* .. Intrinsic Functions .. */
  35. /* .. */
  36. /* Parameter adjustments */
  37. --dx;
  38. /* Function Body */
  39. if (*n <= 0 || *incx <= 0) {
  40. return 0;
  41. }
  42. if (*incx == 1) {
  43. goto L20;
  44. }
  45. /* code for increment not equal to 1 */
  46. nincx = *n * *incx;
  47. i__1 = nincx;
  48. i__2 = *incx;
  49. for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
  50. dx[i__] = *da * dx[i__];
  51. /* L10: */
  52. }
  53. return 0;
  54. /* code for increment equal to 1 */
  55. /* clean-up loop */
  56. L20:
  57. m = *n % 5;
  58. if (m == 0) {
  59. goto L40;
  60. }
  61. i__2 = m;
  62. for (i__ = 1; i__ <= i__2; ++i__) {
  63. dx[i__] = *da * dx[i__];
  64. /* L30: */
  65. }
  66. if (*n < 5) {
  67. return 0;
  68. }
  69. L40:
  70. mp1 = m + 1;
  71. i__2 = *n;
  72. for (i__ = mp1; i__ <= i__2; i__ += 5) {
  73. dx[i__] = *da * dx[i__];
  74. dx[i__ + 1] = *da * dx[i__ + 1];
  75. dx[i__ + 2] = *da * dx[i__ + 2];
  76. dx[i__ + 3] = *da * dx[i__ + 3];
  77. dx[i__ + 4] = *da * dx[i__ + 4];
  78. /* L50: */
  79. }
  80. return 0;
  81. } /* dscal_ */