110 lines
2.4 KiB
C
110 lines
2.4 KiB
C
#include <complex.h>
|
|
|
|
/*
|
|
*> \brief \b CSSCAL
|
|
*
|
|
* =========== DOCUMENTATION ===========
|
|
*
|
|
* Online html documentation available at
|
|
* http://www.netlib.org/lapack/explore-html/
|
|
*
|
|
* Definition:
|
|
* ===========
|
|
*
|
|
* SUBROUTINE CSSCAL(N,SA,CX,INCX)
|
|
*
|
|
* .. Scalar Arguments ..
|
|
* REAL SA
|
|
* INTEGER INCX,N
|
|
* ..
|
|
* .. Array Arguments ..
|
|
* COMPLEX CX(*)
|
|
* ..
|
|
*
|
|
*
|
|
*> \par Purpose:
|
|
* =============
|
|
*>
|
|
*> \verbatim
|
|
*>
|
|
*> CSSCAL scales a complex vector by a real constant.
|
|
*> \endverbatim
|
|
*
|
|
* Arguments:
|
|
* ==========
|
|
*
|
|
*> \param[in] N
|
|
*> \verbatim
|
|
*> N is INTEGER
|
|
*> number of elements in input vector(s)
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] SA
|
|
*> \verbatim
|
|
*> SA is REAL
|
|
*> On entry, SA specifies the scalar alpha.
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in,out] 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
|
|
*
|
|
* 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 3/93 to return if incx .le. 0.
|
|
*> modified 12/3/93, array(1) declarations changed to array(*)
|
|
*> \endverbatim
|
|
*>
|
|
* =====================================================================
|
|
*/
|
|
void csscal(int n, float sa, complex float *cx, int incx) {
|
|
|
|
// -- Reference BLAS level1 routine --
|
|
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
|
|
// =====================================================================
|
|
|
|
// .. Local Scalars ..
|
|
int i, nincx;
|
|
float one = 1.0;
|
|
|
|
if (n <= 0 || incx <= 0 || sa == one) return;
|
|
|
|
if (incx == 1) {
|
|
// code for increment equal to 1
|
|
for (i = 0; i < n; i++) {
|
|
cx[i] = sa * creal(cx[i]) + sa * cimag(cx[i]) * I;
|
|
}
|
|
} else {
|
|
// code for increment not equal to 1
|
|
nincx = n * incx;
|
|
for (i = 0; i < nincx; i += incx) {
|
|
cx[i] = sa * creal(cx[i]) + sa * cimag(cx[i]) * I;
|
|
}
|
|
}
|
|
|
|
// End of CSSCAL
|
|
|
|
}
|