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


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