kusano 7d535a
/*! @file scsum1.c
kusano 7d535a
 * \brief Takes sum of the absolute values of a complex vector and returns a single precision result
kusano 7d535a
 *
kusano 7d535a
 * 
kusano 7d535a
 *     -- LAPACK auxiliary routine (version 2.0) --   
kusano 7d535a
 *     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,   
kusano 7d535a
 *     Courant Institute, Argonne National Lab, and Rice University   
kusano 7d535a
 *     October 31, 1992   
kusano 7d535a
 * 
kusano 7d535a
 */
kusano 7d535a
#include "slu_scomplex.h"
kusano 7d535a
#include "slu_Cnames.h"
kusano 7d535a
kusano 7d535a
/*! \brief
kusano 7d535a
kusano 7d535a
kusano 7d535a
    Purpose   
kusano 7d535a
    =======   
kusano 7d535a
kusano 7d535a
    SCSUM1 takes the sum of the absolute values of a complex   
kusano 7d535a
    vector and returns a single precision result.   
kusano 7d535a
kusano 7d535a
    Based on SCASUM from the Level 1 BLAS.   
kusano 7d535a
    The change is to use the 'genuine' absolute value.   
kusano 7d535a
kusano 7d535a
    Contributed by Nick Higham for use with CLACON.   
kusano 7d535a
kusano 7d535a
    Arguments   
kusano 7d535a
    =========   
kusano 7d535a
kusano 7d535a
    N       (input) INT
kusano 7d535a
            The number of elements in the vector CX.   
kusano 7d535a
kusano 7d535a
    CX      (input) COMPLEX array, dimension (N)   
kusano 7d535a
            The vector whose elements will be summed.   
kusano 7d535a
kusano 7d535a
    INCX    (input) INT
kusano 7d535a
            The spacing between successive values of CX.  INCX > 0.   
kusano 7d535a
kusano 7d535a
    ===================================================================== 
kusano 7d535a
kusano 7d535a
*/
kusano 7d535a
double scsum1_(int *n, complex *cx, int *incx)
kusano 7d535a
{
kusano 7d535a
    /* System generated locals */
kusano 7d535a
    int i__1, i__2;
kusano 7d535a
    float ret_val;
kusano 7d535a
    /* Builtin functions */
kusano 7d535a
    double c_abs(complex *);
kusano 7d535a
    /* Local variables */
kusano 7d535a
    static int i, nincx;
kusano 7d535a
    static float stemp;
kusano 7d535a
kusano 7d535a
kusano 7d535a
#define CX(I) cx[(I)-1]
kusano 7d535a
kusano 7d535a
kusano 7d535a
    ret_val = 0.f;
kusano 7d535a
    stemp = 0.f;
kusano 7d535a
    if (*n <= 0) {
kusano 7d535a
	return ret_val;
kusano 7d535a
    }
kusano 7d535a
    if (*incx == 1) {
kusano 7d535a
	goto L20;
kusano 7d535a
    }
kusano 7d535a
kusano 7d535a
/*     CODE FOR INCREMENT NOT EQUAL TO 1 */
kusano 7d535a
kusano 7d535a
    nincx = *n * *incx;
kusano 7d535a
    i__1 = nincx;
kusano 7d535a
    i__2 = *incx;
kusano 7d535a
    for (i = 1; *incx < 0 ? i >= nincx : i <= nincx; i += *incx) {
kusano 7d535a
kusano 7d535a
/*        NEXT LINE MODIFIED. */
kusano 7d535a
kusano 7d535a
	stemp += c_abs(&CX(i));
kusano 7d535a
/* L10: */
kusano 7d535a
    }
kusano 7d535a
    ret_val = stemp;
kusano 7d535a
    return ret_val;
kusano 7d535a
kusano 7d535a
/*     CODE FOR INCREMENT EQUAL TO 1 */
kusano 7d535a
kusano 7d535a
L20:
kusano 7d535a
    i__2 = *n;
kusano 7d535a
    for (i = 1; i <= *n; ++i) {
kusano 7d535a
kusano 7d535a
/*        NEXT LINE MODIFIED. */
kusano 7d535a
kusano 7d535a
	stemp += c_abs(&CX(i));
kusano 7d535a
/* L30: */
kusano 7d535a
    }
kusano 7d535a
    ret_val = stemp;
kusano 7d535a
    return ret_val;
kusano 7d535a
kusano 7d535a
/*     End of SCSUM1 */
kusano 7d535a
kusano 7d535a
} /* scsum1_ */
kusano 7d535a