001: /*
002:  *
003:  * cblas_cher2k.c
004:  * This program is a C interface to cher2k.
005:  * Written by Keita Teranishi
006:  * 4/8/1998
007:  *
008:  */
009: 
010: #include "cblas.h"
011: #include "cblas_f77.h"
012: void cblas_cher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
013:                   const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
014:                   const void *alpha, const void *A, const int lda,
015:                   const void *B, const int ldb, const float beta,
016:                   void *C, const int ldc)
017: {
018:    char UL, TR;
019: #ifdef F77_CHAR
020:    F77_CHAR F77_TR, F77_UL;
021: #else
022:    #define F77_TR &TR
023:    #define F77_UL &UL
024: #endif
025: 
026: #ifdef F77_INT
027:    F77_INT F77_N=N, F77_K=K, F77_lda=lda, F77_ldb=ldb;
028:    F77_INT F77_ldc=ldc;
029: #else
030:    #define F77_N N
031:    #define F77_K K
032:    #define F77_lda lda
033:    #define F77_ldb ldb
034:    #define F77_ldc ldc
035: #endif
036: 
037:    extern int CBLAS_CallFromC;
038:    extern int RowMajorStrg;
039:    float ALPHA[2];
040:    const float *alp=(float *)alpha;
041: 
042:    CBLAS_CallFromC = 1;
043:    RowMajorStrg = 0;
044: 
045:    if( Order == CblasColMajor )
046:    {
047: 
048:       if( Uplo == CblasUpper) UL='U';
049:       else if ( Uplo == CblasLower ) UL='L';
050:       else
051:       {
052:          cblas_xerbla(2, "cblas_cher2k", "Illegal Uplo setting, %d\n", Uplo);
053:          CBLAS_CallFromC = 0;
054:          RowMajorStrg = 0;
055:          return;
056:       }
057: 
058:       if( Trans == CblasTrans) TR ='T';
059:       else if ( Trans == CblasConjTrans ) TR='C';
060:       else if ( Trans == CblasNoTrans )   TR='N';
061:       else
062:       {
063:          cblas_xerbla(3, "cblas_cher2k", "Illegal Trans setting, %d\n", Trans);
064:          CBLAS_CallFromC = 0;
065:          RowMajorStrg = 0;
066:          return;
067:       }
068: 
069:       #ifdef F77_CHAR
070:          F77_UL = C2F_CHAR(&UL);
071:          F77_TR = C2F_CHAR(&TR);
072:       #endif
073: 
074:       F77_cher2k(F77_UL, F77_TR, &F77_N, &F77_K, (const float *)alpha, (const float *)A, &F77_lda, (const float *)B, &F77_ldb, (const float *)&beta, (float *)C, &F77_ldc);
075:    } else if (Order == CblasRowMajor)
076:    {
077:       RowMajorStrg = 1;
078: 
079:       if( Uplo == CblasUpper) UL='L';
080:       else if ( Uplo == CblasLower ) UL='U';
081:       else
082:       {
083:          cblas_xerbla(2, "cblas_cher2k", "Illegal Uplo setting, %d\n", Uplo);
084:          CBLAS_CallFromC = 0;
085:          RowMajorStrg = 0;
086:          return;
087:       }
088:       if( Trans == CblasTrans) TR ='N';
089:       else if ( Trans == CblasConjTrans ) TR='N';
090:       else if ( Trans == CblasNoTrans )   TR='C';
091:       else
092:       {
093:          cblas_xerbla(3, "cblas_cher2k", "Illegal Trans setting, %d\n", Trans);
094:          CBLAS_CallFromC = 0;
095:          RowMajorStrg = 0;
096:          return;
097:       }
098:       #ifdef F77_CHAR
099:          F77_UL = C2F_CHAR(&UL);
100:          F77_TR = C2F_CHAR(&TR);
101:       #endif
102: 
103:       ALPHA[0]= *alp;
104:       ALPHA[1]= -alp[1];
105:       F77_cher2k(F77_UL,F77_TR, &F77_N, &F77_K, ALPHA, (const float *)A, &F77_lda, (const float *)B, &F77_ldb, (const float *)&beta, (float *)C, &F77_ldc);
106:    }
107:    else  cblas_xerbla(1, "cblas_cher2k", "Illegal Order setting, %d\n", Order);
108:    CBLAS_CallFromC = 0;
109:    RowMajorStrg = 0;
110:    return;
111: }
112: