cblas_chemv.c
Go to the documentation of this file.
00001 /*
00002  * cblas_chemv.c
00003  * The program is a C interface to chemv
00004  * 
00005  * Keita Teranishi  5/18/98
00006  *
00007  */
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include "cblas.h"
00011 #include "cblas_f77.h"
00012 void cblas_chemv(const enum CBLAS_ORDER order,
00013                  const enum CBLAS_UPLO Uplo, const int N,
00014                  const void *alpha, const void *A, const int lda,
00015                  const void *X, const int incX, const void *beta,
00016                  void  *Y, const int incY)
00017 {
00018    char UL;
00019 #ifdef F77_CHAR
00020    F77_CHAR F77_UL;
00021 #else
00022    #define F77_UL &UL   
00023 #endif
00024 #ifdef F77_INT
00025    F77_INT F77_N=N, F77_lda=lda, F77_incX=incX, F77_incY=incY;
00026 #else
00027    #define F77_N N
00028    #define F77_lda lda
00029    #define F77_incX incx
00030    #define F77_incY incY
00031 #endif
00032    int n=0, i=0, incx=incX;
00033    const float *xx= (float *)X, *alp= (float *)alpha, *bet = (float *)beta;
00034    float ALPHA[2],BETA[2];
00035    int tincY, tincx;
00036    float *x=(float *)X, *y=(float *)Y, *st=0, *tx;
00037    extern int CBLAS_CallFromC;
00038    extern int RowMajorStrg;
00039    RowMajorStrg = 0;
00040 
00041 
00042    CBLAS_CallFromC = 1;
00043    if (order == CblasColMajor)
00044    {
00045       if (Uplo == CblasUpper) UL = 'U';
00046       else if (Uplo == CblasLower) UL = 'L';
00047       else 
00048       {
00049          cblas_xerbla(2, "cblas_chemv","Illegal Uplo setting, %d\n",Uplo );
00050          CBLAS_CallFromC = 0;
00051          RowMajorStrg = 0;
00052          return;
00053       }
00054       #ifdef F77_CHAR
00055          F77_UL = C2F_CHAR(&UL);
00056       #endif
00057       F77_chemv(F77_UL, &F77_N, alpha, A, &F77_lda, X, &F77_incX, 
00058                 beta, Y, &F77_incY);
00059    }
00060    else if (order == CblasRowMajor)
00061    {
00062       RowMajorStrg = 1;
00063       ALPHA[0]= *alp;
00064       ALPHA[1]= -alp[1];
00065       BETA[0]= *bet;
00066       BETA[1]= -bet[1];
00067 
00068       if (N > 0)
00069       {
00070          n = N << 1;
00071          x = malloc(n*sizeof(float));
00072  
00073          tx = x;
00074          if( incX > 0 ) {
00075            i = incX << 1 ;
00076            tincx = 2;
00077            st= x+n;
00078          } else {
00079            i = incX *(-2);
00080            tincx = -2;
00081            st = x-2;
00082            x +=(n-2);
00083          }
00084 
00085          do
00086          {
00087            *x = *xx;
00088            x[1] = -xx[1];
00089            x += tincx ;
00090            xx += i;
00091          }
00092          while (x != st);
00093          x=tx;
00094 
00095 
00096          #ifdef F77_INT
00097             F77_incX = 1;
00098          #else
00099             incx = 1;
00100          #endif
00101  
00102          if(incY > 0)
00103            tincY = incY;
00104          else
00105            tincY = -incY;
00106          y++;
00107 
00108          i = tincY << 1;
00109          n = i * N ;
00110          st = y + n;
00111          do {
00112             *y = -(*y);
00113             y += i;
00114          } while(y != st);
00115          y -= n;
00116       }  else
00117          x = (float *) X;
00118 
00119           
00120       if (Uplo == CblasUpper) UL = 'L';
00121       else if (Uplo == CblasLower) UL = 'U';
00122       else 
00123       {
00124          cblas_xerbla(2, "cblas_chemv","Illegal Uplo setting, %d\n", Uplo);
00125          CBLAS_CallFromC = 0;
00126          RowMajorStrg = 0;
00127          return;
00128       }
00129       #ifdef F77_CHAR
00130          F77_UL = C2F_CHAR(&UL);
00131       #endif
00132       F77_chemv(F77_UL, &F77_N, ALPHA, A, &F77_lda, x, &F77_incX, 
00133                 BETA, Y, &F77_incY);
00134    }
00135    else 
00136    {
00137       cblas_xerbla(1, "cblas_chemv","Illegal Order setting, %d\n", order);
00138       CBLAS_CallFromC = 0;
00139       RowMajorStrg = 0;
00140       return;
00141    }
00142    if ( order == CblasRowMajor )
00143    {
00144       RowMajorStrg = 1;
00145       if ( X != x )
00146          free(x);
00147       if (N > 0)
00148       {
00149          do
00150          {
00151             *y = -(*y);
00152             y += i;
00153          }
00154          while (y != st);
00155      }
00156    }
00157    CBLAS_CallFromC = 0;
00158    RowMajorStrg = 0;
00159    return;
00160 }


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:15