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


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