caxpy.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* caxpy.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 caxpy_(integer *n, complex *ca, complex *cx, integer *
  14. incx, complex *cy, integer *incy)
  15. {
  16. /* System generated locals */
  17. integer i__1, i__2, i__3, i__4;
  18. complex q__1, q__2;
  19. /* Local variables */
  20. integer i__, ix, iy;
  21. extern doublereal scabs1_(complex *);
  22. /* .. Scalar Arguments .. */
  23. /* .. */
  24. /* .. Array Arguments .. */
  25. /* .. */
  26. /* Purpose */
  27. /* ======= */
  28. /* CAXPY constant times a vector plus a vector. */
  29. /* Further Details */
  30. /* =============== */
  31. /* jack dongarra, linpack, 3/11/78. */
  32. /* modified 12/3/93, array(1) declarations changed to array(*) */
  33. /* .. Local Scalars .. */
  34. /* .. */
  35. /* .. External Functions .. */
  36. /* .. */
  37. /* Parameter adjustments */
  38. --cy;
  39. --cx;
  40. /* Function Body */
  41. if (*n <= 0) {
  42. return 0;
  43. }
  44. if (scabs1_(ca) == 0.f) {
  45. return 0;
  46. }
  47. if (*incx == 1 && *incy == 1) {
  48. goto L20;
  49. }
  50. /* code for unequal increments or equal increments */
  51. /* not equal to 1 */
  52. ix = 1;
  53. iy = 1;
  54. if (*incx < 0) {
  55. ix = (-(*n) + 1) * *incx + 1;
  56. }
  57. if (*incy < 0) {
  58. iy = (-(*n) + 1) * *incy + 1;
  59. }
  60. i__1 = *n;
  61. for (i__ = 1; i__ <= i__1; ++i__) {
  62. i__2 = iy;
  63. i__3 = iy;
  64. i__4 = ix;
  65. q__2.r = ca->r * cx[i__4].r - ca->i * cx[i__4].i, q__2.i = ca->r * cx[
  66. i__4].i + ca->i * cx[i__4].r;
  67. q__1.r = cy[i__3].r + q__2.r, q__1.i = cy[i__3].i + q__2.i;
  68. cy[i__2].r = q__1.r, cy[i__2].i = q__1.i;
  69. ix += *incx;
  70. iy += *incy;
  71. /* L10: */
  72. }
  73. return 0;
  74. /* code for both increments equal to 1 */
  75. L20:
  76. i__1 = *n;
  77. for (i__ = 1; i__ <= i__1; ++i__) {
  78. i__2 = i__;
  79. i__3 = i__;
  80. i__4 = i__;
  81. q__2.r = ca->r * cx[i__4].r - ca->i * cx[i__4].i, q__2.i = ca->r * cx[
  82. i__4].i + ca->i * cx[i__4].r;
  83. q__1.r = cy[i__3].r + q__2.r, q__1.i = cy[i__3].i + q__2.i;
  84. cy[i__2].r = q__1.r, cy[i__2].i = q__1.i;
  85. /* L30: */
  86. }
  87. return 0;
  88. } /* caxpy_ */