dlassq.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* dlassq.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_dlassq_(integer *n, doublereal *x, integer *incx,
  14. doublereal *scale, doublereal *sumsq)
  15. {
  16. /* System generated locals */
  17. integer i__1, i__2;
  18. doublereal d__1;
  19. /* Local variables */
  20. integer ix;
  21. doublereal absxi;
  22. /* -- LAPACK auxiliary routine (version 3.2) -- */
  23. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  24. /* November 2006 */
  25. /* .. Scalar Arguments .. */
  26. /* .. */
  27. /* .. Array Arguments .. */
  28. /* .. */
  29. /* Purpose */
  30. /* ======= */
  31. /* DLASSQ returns the values scl and smsq such that */
  32. /* ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq, */
  33. /* where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is */
  34. /* assumed to be non-negative and scl returns the value */
  35. /* scl = max( scale, abs( x( i ) ) ). */
  36. /* scale and sumsq must be supplied in SCALE and SUMSQ and */
  37. /* scl and smsq are overwritten on SCALE and SUMSQ respectively. */
  38. /* The routine makes only one pass through the vector x. */
  39. /* Arguments */
  40. /* ========= */
  41. /* N (input) INTEGER */
  42. /* The number of elements to be used from the vector X. */
  43. /* X (input) DOUBLE PRECISION array, dimension (N) */
  44. /* The vector for which a scaled sum of squares is computed. */
  45. /* x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n. */
  46. /* INCX (input) INTEGER */
  47. /* The increment between successive values of the vector X. */
  48. /* INCX > 0. */
  49. /* SCALE (input/output) DOUBLE PRECISION */
  50. /* On entry, the value scale in the equation above. */
  51. /* On exit, SCALE is overwritten with scl , the scaling factor */
  52. /* for the sum of squares. */
  53. /* SUMSQ (input/output) DOUBLE PRECISION */
  54. /* On entry, the value sumsq in the equation above. */
  55. /* On exit, SUMSQ is overwritten with smsq , the basic sum of */
  56. /* squares from which scl has been factored out. */
  57. /* ===================================================================== */
  58. /* .. Parameters .. */
  59. /* .. */
  60. /* .. Local Scalars .. */
  61. /* .. */
  62. /* .. Intrinsic Functions .. */
  63. /* .. */
  64. /* .. Executable Statements .. */
  65. /* Parameter adjustments */
  66. --x;
  67. /* Function Body */
  68. if (*n > 0) {
  69. i__1 = (*n - 1) * *incx + 1;
  70. i__2 = *incx;
  71. for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
  72. if (x[ix] != 0.) {
  73. absxi = (d__1 = x[ix], abs(d__1));
  74. if (*scale < absxi) {
  75. /* Computing 2nd power */
  76. d__1 = *scale / absxi;
  77. *sumsq = *sumsq * (d__1 * d__1) + 1;
  78. *scale = absxi;
  79. } else {
  80. /* Computing 2nd power */
  81. d__1 = absxi / *scale;
  82. *sumsq += d__1 * d__1;
  83. }
  84. }
  85. /* L10: */
  86. }
  87. }
  88. return 0;
  89. /* End of DLASSQ */
  90. } /* _starpu_dlassq_ */