Sum of squares

F_SSUMSQ/F_DSUMSQ/F_CSUMSQ/F_ZSUMSQ

Name F_SSUMSQ/F_DSUMSQ/F_CSUMSQ/F_ZSUMSQ

Sum of squares

Purpose F_xSUMSQ returns the values scl and ssq such that

n – 1

scl2 ssq = scale2 sumsq + ( Re( xi)2 + Im( xi)2) i = 0

The value of sumsq should be at least unity and the value of ssq then satisfies

1.0ssq ≤ (sumsq + n) when x is a real vector, and

≤ ≤ ( ˙ )

1.0 ssq sumsq + 2n when x is a complex vector.

scale should be non negative and scl returns the value

scl = max0 i < n(scale, abs(( Re( xi)), abs( Im( xi)))

Specify scale and sumsq on entry in scl and ssq respectively. scl and ssq are overwritten by scl and ssq respectively. The arguments scl and ssq are therefore always real scalars. If n is less than or equal to zero, the routine returns immediately with scl and ssq unchanged.

Usage VECLIB:

INTEGER*4

INCX, N

REAL*4

SCL, SSQ, X( * )

SUBROUTINE F_SSUMSQ (N, X, INCX, SSQ, SCL)

INTEGER*4

INCX, N

REAL*8

SCL, SSQ, X( * )

SUBROUTINE F_DSUMSQ (N, X, INCX, SSQ, SCL)

INTEGER

INCX, N

REAL*4

SCL, SSQ

COMPLEX*8

X( * )

SUBROUTINE F_CSUMSQ (N, X, INCX, SSQ, SCL)

INTEGER

INCX, N

REAL*8

SCL, SSQ

COMPLEX*16

X( * )

SUBROUTINE F_ZSUMSQ (N, X, INCX, SSQ, SCL)

VECLIB8:

Chapter 2 Basic Vector Operations 197