scasum.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* scasum.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. doublereal scasum_(integer *n, complex *cx, integer *incx)
  14. {
  15. /* System generated locals */
  16. integer i__1, i__2, i__3;
  17. real ret_val, r__1, r__2;
  18. /* Builtin functions */
  19. double r_imag(complex *);
  20. /* Local variables */
  21. integer i__, nincx;
  22. real stemp;
  23. /* .. Scalar Arguments .. */
  24. /* .. */
  25. /* .. Array Arguments .. */
  26. /* .. */
  27. /* Purpose */
  28. /* ======= */
  29. /* takes the sum of the absolute values of a complex vector and */
  30. /* returns a single precision result. */
  31. /* jack dongarra, linpack, 3/11/78. */
  32. /* modified 3/93 to return if incx .le. 0. */
  33. /* modified 12/3/93, array(1) declarations changed to array(*) */
  34. /* .. Local Scalars .. */
  35. /* .. */
  36. /* .. Intrinsic Functions .. */
  37. /* .. */
  38. /* Parameter adjustments */
  39. --cx;
  40. /* Function Body */
  41. ret_val = 0.f;
  42. stemp = 0.f;
  43. if (*n <= 0 || *incx <= 0) {
  44. return ret_val;
  45. }
  46. if (*incx == 1) {
  47. goto L20;
  48. }
  49. /* code for increment not equal to 1 */
  50. nincx = *n * *incx;
  51. i__1 = nincx;
  52. i__2 = *incx;
  53. for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
  54. i__3 = i__;
  55. stemp = stemp + (r__1 = cx[i__3].r, dabs(r__1)) + (r__2 = r_imag(&cx[
  56. i__]), dabs(r__2));
  57. /* L10: */
  58. }
  59. ret_val = stemp;
  60. return ret_val;
  61. /* code for increment equal to 1 */
  62. L20:
  63. i__2 = *n;
  64. for (i__ = 1; i__ <= i__2; ++i__) {
  65. i__1 = i__;
  66. stemp = stemp + (r__1 = cx[i__1].r, dabs(r__1)) + (r__2 = r_imag(&cx[
  67. i__]), dabs(r__2));
  68. /* L30: */
  69. }
  70. ret_val = stemp;
  71. return ret_val;
  72. } /* scasum_ */