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