119 lines
2.6 KiB
C
119 lines
2.6 KiB
C
#include <complex.h>
|
|
|
|
/*
|
|
*> \brief \b CDOTU
|
|
*
|
|
* =========== DOCUMENTATION ===========
|
|
*
|
|
* Online html documentation available at
|
|
* http://www.netlib.org/lapack/explore-html/
|
|
*
|
|
* Definition:
|
|
* ===========
|
|
*
|
|
* COMPLEX FUNCTION CDOTU(N,CX,INCX,CY,INCY)
|
|
*
|
|
* .. Scalar Arguments ..
|
|
* INTEGER INCX,INCY,N
|
|
* ..
|
|
* .. Array Arguments ..
|
|
* COMPLEX CX(*),CY(*)
|
|
* ..
|
|
*
|
|
*
|
|
*> \par Purpose:
|
|
* =============
|
|
*>
|
|
*> \verbatim
|
|
*>
|
|
*> CDOTU forms the dot product of two complex vectors
|
|
*> CDOTU = X^T * Y
|
|
*>
|
|
*> \endverbatim
|
|
*
|
|
* Arguments:
|
|
* ==========
|
|
*
|
|
*> \param[in] N
|
|
*> \verbatim
|
|
*> N is INTEGER
|
|
*> number of elements in input vector(s)
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] CX
|
|
*> \verbatim
|
|
*> CX is COMPLEX array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] INCX
|
|
*> \verbatim
|
|
*> INCX is INTEGER
|
|
*> storage spacing between elements of CX
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] CY
|
|
*> \verbatim
|
|
*> CY is COMPLEX array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] INCY
|
|
*> \verbatim
|
|
*> INCY is INTEGER
|
|
*> storage spacing between elements of CY
|
|
*> \endverbatim
|
|
*
|
|
* Authors:
|
|
* ========
|
|
*
|
|
*> \author Univ. of Tennessee
|
|
*> \author Univ. of California Berkeley
|
|
*> \author Univ. of Colorado Denver
|
|
*> \author NAG Ltd.
|
|
*
|
|
*> \ingroup complex_blas_level1
|
|
*
|
|
*> \par Further Details:
|
|
* =====================
|
|
*>
|
|
*> \verbatim
|
|
*>
|
|
*> jack dongarra, linpack, 3/11/78.
|
|
*> modified 12/3/93, array(1) declarations changed to array(*)
|
|
*> \endverbatim
|
|
*>
|
|
* =====================================================================
|
|
*/
|
|
complex float cdotu(int n, complex float* cx, int incx, complex float *cy, int incy) {
|
|
|
|
// -- Reference BLAS level1 routine (version 3.4.0) --
|
|
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
// November 2011
|
|
|
|
int i, ix, iy;
|
|
complex double ctemp = 0.0 + 0.0*I;
|
|
if (n <= 0) return ctemp;
|
|
|
|
if (incx == 1 && incy == 1) {
|
|
// code for both increments equal to 1
|
|
for (i = 0; i < n; i++) {
|
|
ctemp += cx[i] * cy[i];
|
|
}
|
|
} else {
|
|
// code for unequal increments or equal increments not equal to 1
|
|
ix = 0;
|
|
iy = 0;
|
|
if (incx < 0) ix = (-n+1)*incx;
|
|
if (incy < 0) iy = (-n+1)*incy;
|
|
for (i = 0; i < n; i++) {
|
|
ctemp += cx[ix] * cy[iy];
|
|
ix += incx;
|
|
iy += incy;
|
|
}
|
|
}
|
|
|
|
return ctemp;
|
|
|
|
// End of CDOTU
|
|
|
|
}
|