GotoBlas2之xASUM

xASUM 绝对值求和。

 

#include <stdio.h> #include "gotoblas2.h" #pragma comment(lib,"libgoto2.lib") //FUNCTION xASUM (N , X, INCX) /* SASUM, DASUM, SCASUM, and DZASUM (Sum of the Magnitudes of the Elements in a Vector) On Entry n is the number of elements in vector x. Specified as: an integer; n greater than or equal to 0. x is the vector x of length n. Specified as: a one-dimensional array of (at least) length 1+(n-1)|incx|, containing numbers of the data type indicated in Table 1. incx is the stride for vector x. Specified as: an integer. It can have any value. On Return Function value is the result of the summation. SASUM and DASUM compute the sum of the absolute values of the elements of x. SCASUM and DZASUM compute the sum of the absolute values of the real and imaginary parts of the elements of x */ int main(void) { float X1[9]={1.0, 2.0, 7.0, -8.0, -5.0, -10.0, -9.0, 10.0, 6.0}; double X2[9]={1.0, 11.0, 7.0, -8.0, -5.0, -10.0, -9.0, 10.0, 6.0}; myccomplex_t X3[5]={{9.0 , 2.0}, {7.0,-8.0},{-5.0 , -10.0} , {-4.0 , 10.0}, {6.0 , 3.0}}; myzcomplex_t X4[5]={{9.0 , 2.0}, {7.0,-8.0},{-5.0 , -10.0} , {-4.0 , 10.0}, {6.0 , 3.0}}; float I1,I3; double I2,I4; blasint N; blasint INCX; N=9; INCX=1; I1=SASUM( &N , X1 , &INCX ); printf(" The IASUM is %.3f/n",I1); N=5; INCX=2; I2 = dasum( &N , X2 , &INCX ); printf(" The IASUM is %.3lf/n",I2); N=5; INCX=1; I3=scasum( &N , (float *)X3 , &INCX ); printf(" The IASUM is %.3f/n",I3); N=3; INCX=2; I4 = dzasum( &N , (double *)X4 , &INCX ); printf(" The IASUM is %.3lf/n",I4); N=5; INCX=0; I1 = sasum( &N , X1 , &INCX ); I2 = dasum( &N , X2 , &INCX ); N=5; I3 = scasum( &N , (float *)X3 , &INCX ); I4 = dzasum( &N , (double *)X4 , &INCX ); if(I1<1e-5&&I2<1e-5&&I3<1e-5&&I4<1e-5) printf("/n xASUM if incx <= 0 , Return 0/n"); N=5; INCX=0; I1 = sasum( &N , X1 , &INCX ); I2 = dasum( &N , X2 , &INCX ); N=0; INCX=1; I3 = scasum( &N , (float *)X3 , &INCX ); I4 = dzasum( &N , (double *)X4 , &INCX ); if(I1<1e-5&&I2<1e-5&&I3<1e-5&&I4<1e-5) printf(" xASUM If N <= 0 , Return 0/n"); return 0; } /*result The IASUM is 58.000 The IASUM is 28.000 The IASUM is 64.000 The IASUM is 35.000 xASUM if incx <= 0 , Return 0 xASUM If N <= 0 , Return 0 */

你可能感兴趣的:(vector,function,table,Integer,float,Numbers)