sscal.c 2.1 KB

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