cblas_sgemm.c
Go to the documentation of this file.
00001 /*
00002  *
00003  * cblas_sgemm.c
00004  * This program is a C interface to sgemm.
00005  * Written by Keita Teranishi
00006  * 4/8/1998
00007  *
00008  */
00009 
00010 #include "cblas.h"
00011 #include "cblas_f77.h"
00012 void cblas_sgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
00013                  const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
00014                  const int K, const float alpha, const float  *A,
00015                  const int lda, const float  *B, const int ldb,
00016                  const float beta, float  *C, const int ldc)
00017 {
00018    char TA, TB;   
00019 #ifdef F77_CHAR
00020    F77_CHAR F77_TA, F77_TB;
00021 #else
00022    #define F77_TA &TA  
00023    #define F77_TB &TB  
00024 #endif
00025 
00026 #ifdef F77_INT
00027    F77_INT F77_M=M, F77_N=N, F77_K=K, F77_lda=lda, F77_ldb=ldb;
00028    F77_INT F77_ldc=ldc;
00029 #else
00030    #define F77_M M
00031    #define F77_N N
00032    #define F77_K K
00033    #define F77_lda lda
00034    #define F77_ldb ldb
00035    #define F77_ldc ldc
00036 #endif
00037    
00038    extern int CBLAS_CallFromC;
00039    extern int RowMajorStrg;
00040    RowMajorStrg = 0;
00041    CBLAS_CallFromC = 1;
00042    if( Order == CblasColMajor )
00043    {
00044       if(TransA == CblasTrans) TA='T';
00045       else if ( TransA == CblasConjTrans ) TA='C';
00046       else if ( TransA == CblasNoTrans )   TA='N';
00047       else 
00048       {
00049          cblas_xerbla(2, "cblas_sgemm", 
00050                        "Illegal TransA setting, %d\n", TransA);
00051          CBLAS_CallFromC = 0;
00052          RowMajorStrg = 0;
00053          return;
00054       }
00055 
00056       if(TransB == CblasTrans) TB='T';
00057       else if ( TransB == CblasConjTrans ) TB='C';
00058       else if ( TransB == CblasNoTrans )   TB='N';
00059       else 
00060       {
00061          cblas_xerbla(3, "cblas_sgemm", 
00062                        "Illegal TransB setting, %d\n", TransB);
00063          CBLAS_CallFromC = 0;
00064          RowMajorStrg = 0;
00065          return;
00066       }
00067 
00068       #ifdef F77_CHAR
00069          F77_TA = C2F_CHAR(&TA);
00070          F77_TB = C2F_CHAR(&TB);
00071       #endif
00072 
00073       F77_sgemm(F77_TA, F77_TB, &F77_M, &F77_N, &F77_K, &alpha, A, &F77_lda, B, &F77_ldb, &beta, C, &F77_ldc);
00074    } else if (Order == CblasRowMajor)
00075    {
00076       RowMajorStrg = 1;
00077       if(TransA == CblasTrans) TB='T';
00078       else if ( TransA == CblasConjTrans ) TB='C';
00079       else if ( TransA == CblasNoTrans )   TB='N';
00080       else 
00081       {
00082          cblas_xerbla(2, "cblas_sgemm", 
00083                        "Illegal TransA setting, %d\n", TransA);
00084          CBLAS_CallFromC = 0;
00085          RowMajorStrg = 0;
00086          return;
00087       }
00088       if(TransB == CblasTrans) TA='T';
00089       else if ( TransB == CblasConjTrans ) TA='C';
00090       else if ( TransB == CblasNoTrans )   TA='N';
00091       else 
00092       {
00093          cblas_xerbla(2, "cblas_sgemm", 
00094                        "Illegal TransA setting, %d\n", TransA);
00095          CBLAS_CallFromC = 0;
00096          RowMajorStrg = 0;
00097          return;
00098       }
00099       #ifdef F77_CHAR
00100          F77_TA = C2F_CHAR(&TA);
00101          F77_TB = C2F_CHAR(&TB);
00102       #endif
00103 
00104       F77_sgemm(F77_TA, F77_TB, &F77_N, &F77_M, &F77_K, &alpha, B, &F77_ldb, A, &F77_lda, &beta, C, &F77_ldc);
00105    } else  
00106      cblas_xerbla(1, "cblas_sgemm",
00107                      "Illegal Order setting, %d\n", Order);
00108    CBLAS_CallFromC = 0;
00109    RowMajorStrg = 0;
00110 }


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