kusano 2b45e8
/*
kusano 2b45e8
 *     Written by D.P. Manley, Digital Equipment Corporation.
kusano 2b45e8
 *     Prefixed "C_" to BLAS routines and their declarations.
kusano 2b45e8
 *
kusano 2b45e8
 *     Modified by T. H. Do, 4/15/98, SGI/CRAY Research.
kusano 2b45e8
 */
kusano 2b45e8
#include <stdlib.h></stdlib.h>
kusano 2b45e8
#include "common.h"
kusano 2b45e8
#include "cblas_test.h"
kusano 2b45e8
#define  TEST_COL_MJR	0
kusano 2b45e8
#define  TEST_ROW_MJR	1
kusano 2b45e8
#define  UNDEFINED     -1
kusano 2b45e8
kusano 2b45e8
void F77_zgemm(int *order, char *transpa, char *transpb, int *m, int *n, 
kusano 2b45e8
     int *k, CBLAS_TEST_ZOMPLEX *alpha, CBLAS_TEST_ZOMPLEX *a, int *lda,
kusano 2b45e8
     CBLAS_TEST_ZOMPLEX *b, int *ldb, CBLAS_TEST_ZOMPLEX *beta, 
kusano 2b45e8
     CBLAS_TEST_ZOMPLEX *c, int *ldc ) {
kusano 2b45e8
kusano 2b45e8
  CBLAS_TEST_ZOMPLEX *A, *B, *C;
kusano 2b45e8
  int i,j,LDA, LDB, LDC;
kusano 2b45e8
  enum CBLAS_TRANSPOSE transa, transb;
kusano 2b45e8
kusano 2b45e8
  get_transpose_type(transpa, &transa);
kusano 2b45e8
  get_transpose_type(transpb, &transb);
kusano 2b45e8
kusano 2b45e8
  if (*order == TEST_ROW_MJR) {
kusano 2b45e8
     if (transa == CblasNoTrans) {
kusano 2b45e8
        LDA = *k+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX*)malloc((*m)*LDA*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*m; i++ )
kusano 2b45e8
           for( j=0; j<*k; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     else {
kusano 2b45e8
        LDA = *m+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc(LDA*(*k)*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*k; i++ )
kusano 2b45e8
           for( j=0; j<*m; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
kusano 2b45e8
     if (transb == CblasNoTrans) {
kusano 2b45e8
        LDB = *n+1;
kusano 2b45e8
        B=(CBLAS_TEST_ZOMPLEX* )malloc((*k)*LDB*sizeof(CBLAS_TEST_ZOMPLEX) );
kusano 2b45e8
        for( i=0; i<*k; i++ )
kusano 2b45e8
           for( j=0; j<*n; j++ ) {
kusano 2b45e8
              B[i*LDB+j].real=b[j*(*ldb)+i].real;
kusano 2b45e8
              B[i*LDB+j].imag=b[j*(*ldb)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     else {
kusano 2b45e8
        LDB = *k+1;
kusano 2b45e8
        B=(CBLAS_TEST_ZOMPLEX* )malloc(LDB*(*n)*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*n; i++ )
kusano 2b45e8
           for( j=0; j<*k; j++ ) {
kusano 2b45e8
              B[i*LDB+j].real=b[j*(*ldb)+i].real;
kusano 2b45e8
              B[i*LDB+j].imag=b[j*(*ldb)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
kusano 2b45e8
     LDC = *n+1;
kusano 2b45e8
     C=(CBLAS_TEST_ZOMPLEX* )malloc((*m)*LDC*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*m; i++ ) {
kusano 2b45e8
           C[i*LDC+j].real=c[j*(*ldc)+i].real;
kusano 2b45e8
           C[i*LDC+j].imag=c[j*(*ldc)+i].imag;
kusano 2b45e8
        }
kusano 2b45e8
     cblas_zgemm( CblasRowMajor, transa, transb, *m, *n, *k, alpha, A, LDA,
kusano 2b45e8
                  B, LDB, beta, C, LDC );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*m; i++ ) {
kusano 2b45e8
           c[j*(*ldc)+i].real=C[i*LDC+j].real;
kusano 2b45e8
           c[j*(*ldc)+i].imag=C[i*LDC+j].imag;
kusano 2b45e8
        }
kusano 2b45e8
     free(A);
kusano 2b45e8
     free(B);
kusano 2b45e8
     free(C);
kusano 2b45e8
  }
kusano 2b45e8
  else if (*order == TEST_COL_MJR)
kusano 2b45e8
     cblas_zgemm( CblasColMajor, transa, transb, *m, *n, *k, alpha, a, *lda,
kusano 2b45e8
                  b, *ldb, beta, c, *ldc );
kusano 2b45e8
  else
kusano 2b45e8
     cblas_zgemm( UNDEFINED, transa, transb, *m, *n, *k, alpha, a, *lda,
kusano 2b45e8
                  b, *ldb, beta, c, *ldc );
kusano 2b45e8
}
kusano 2b45e8
void F77_zhemm(int *order, char *rtlf, char *uplow, int *m, int *n,
kusano 2b45e8
        CBLAS_TEST_ZOMPLEX *alpha, CBLAS_TEST_ZOMPLEX *a, int *lda,
kusano 2b45e8
	CBLAS_TEST_ZOMPLEX *b, int *ldb, CBLAS_TEST_ZOMPLEX *beta,
kusano 2b45e8
        CBLAS_TEST_ZOMPLEX *c, int *ldc ) {
kusano 2b45e8
kusano 2b45e8
  CBLAS_TEST_ZOMPLEX *A, *B, *C;
kusano 2b45e8
  int i,j,LDA, LDB, LDC;
kusano 2b45e8
  enum CBLAS_UPLO uplo;
kusano 2b45e8
  enum CBLAS_SIDE side;
kusano 2b45e8
kusano 2b45e8
  get_uplo_type(uplow,&uplo);
kusano 2b45e8
  get_side_type(rtlf,&side);
kusano 2b45e8
kusano 2b45e8
  if (*order == TEST_ROW_MJR) {
kusano 2b45e8
     if (side == CblasLeft) {
kusano 2b45e8
        LDA = *m+1;
kusano 2b45e8
        A= (CBLAS_TEST_ZOMPLEX* )malloc((*m)*LDA*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*m; i++ )
kusano 2b45e8
           for( j=0; j<*m; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     else{
kusano 2b45e8
        LDA = *n+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
        for( i=0; i<*n; i++ )
kusano 2b45e8
           for( j=0; j<*n; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     LDB = *n+1;
kusano 2b45e8
     B=(CBLAS_TEST_ZOMPLEX* )malloc( (*m)*LDB*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
     for( i=0; i<*m; i++ )
kusano 2b45e8
        for( j=0; j<*n; j++ ) {
kusano 2b45e8
           B[i*LDB+j].real=b[j*(*ldb)+i].real;
kusano 2b45e8
           B[i*LDB+j].imag=b[j*(*ldb)+i].imag;
kusano 2b45e8
        }
kusano 2b45e8
     LDC = *n+1;
kusano 2b45e8
     C=(CBLAS_TEST_ZOMPLEX* )malloc((*m)*LDC*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*m; i++ ) {
kusano 2b45e8
           C[i*LDC+j].real=c[j*(*ldc)+i].real;
kusano 2b45e8
           C[i*LDC+j].imag=c[j*(*ldc)+i].imag;
kusano 2b45e8
        }
kusano 2b45e8
     cblas_zhemm( CblasRowMajor, side, uplo, *m, *n, alpha, A, LDA, B, LDB, 
kusano 2b45e8
                  beta, C, LDC );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*m; i++ ) {
kusano 2b45e8
           c[j*(*ldc)+i].real=C[i*LDC+j].real;
kusano 2b45e8
           c[j*(*ldc)+i].imag=C[i*LDC+j].imag;
kusano 2b45e8
        }
kusano 2b45e8
     free(A);
kusano 2b45e8
     free(B);
kusano 2b45e8
     free(C);
kusano 2b45e8
  }
kusano 2b45e8
  else if (*order == TEST_COL_MJR)
kusano 2b45e8
     cblas_zhemm( CblasColMajor, side, uplo, *m, *n, alpha, a, *lda, b, *ldb, 
kusano 2b45e8
                  beta, c, *ldc );
kusano 2b45e8
  else
kusano 2b45e8
     cblas_zhemm( UNDEFINED, side, uplo, *m, *n, alpha, a, *lda, b, *ldb, 
kusano 2b45e8
                  beta, c, *ldc );
kusano 2b45e8
}
kusano 2b45e8
void F77_zsymm(int *order, char *rtlf, char *uplow, int *m, int *n,
kusano 2b45e8
          CBLAS_TEST_ZOMPLEX *alpha, CBLAS_TEST_ZOMPLEX *a, int *lda,
kusano 2b45e8
	  CBLAS_TEST_ZOMPLEX *b, int *ldb, CBLAS_TEST_ZOMPLEX *beta,
kusano 2b45e8
          CBLAS_TEST_ZOMPLEX *c, int *ldc ) {
kusano 2b45e8
kusano 2b45e8
  CBLAS_TEST_ZOMPLEX *A, *B, *C;
kusano 2b45e8
  int i,j,LDA, LDB, LDC;
kusano 2b45e8
  enum CBLAS_UPLO uplo;
kusano 2b45e8
  enum CBLAS_SIDE side;
kusano 2b45e8
kusano 2b45e8
  get_uplo_type(uplow,&uplo);
kusano 2b45e8
  get_side_type(rtlf,&side);
kusano 2b45e8
kusano 2b45e8
  if (*order == TEST_ROW_MJR) {
kusano 2b45e8
     if (side == CblasLeft) {
kusano 2b45e8
        LDA = *m+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*m)*LDA*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*m; i++ )
kusano 2b45e8
           for( j=0; j<*m; j++ )
kusano 2b45e8
              A[i*LDA+j]=a[j*(*lda)+i];
kusano 2b45e8
     }
kusano 2b45e8
     else{
kusano 2b45e8
        LDA = *n+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
        for( i=0; i<*n; i++ )
kusano 2b45e8
           for( j=0; j<*n; j++ )
kusano 2b45e8
              A[i*LDA+j]=a[j*(*lda)+i];
kusano 2b45e8
     }
kusano 2b45e8
     LDB = *n+1;
kusano 2b45e8
     B=(CBLAS_TEST_ZOMPLEX* )malloc((*m)*LDB*sizeof(CBLAS_TEST_ZOMPLEX ));
kusano 2b45e8
     for( i=0; i<*m; i++ )
kusano 2b45e8
        for( j=0; j<*n; j++ )
kusano 2b45e8
           B[i*LDB+j]=b[j*(*ldb)+i];
kusano 2b45e8
     LDC = *n+1;
kusano 2b45e8
     C=(CBLAS_TEST_ZOMPLEX* )malloc((*m)*LDC*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*m; i++ )
kusano 2b45e8
           C[i*LDC+j]=c[j*(*ldc)+i];
kusano 2b45e8
     cblas_zsymm( CblasRowMajor, side, uplo, *m, *n, alpha, A, LDA, B, LDB, 
kusano 2b45e8
                  beta, C, LDC );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*m; i++ )
kusano 2b45e8
           c[j*(*ldc)+i]=C[i*LDC+j];
kusano 2b45e8
     free(A);
kusano 2b45e8
     free(B);
kusano 2b45e8
     free(C);
kusano 2b45e8
  }
kusano 2b45e8
  else if (*order == TEST_COL_MJR)
kusano 2b45e8
     cblas_zsymm( CblasColMajor, side, uplo, *m, *n, alpha, a, *lda, b, *ldb, 
kusano 2b45e8
                  beta, c, *ldc );
kusano 2b45e8
  else
kusano 2b45e8
     cblas_zsymm( UNDEFINED, side, uplo, *m, *n, alpha, a, *lda, b, *ldb, 
kusano 2b45e8
                  beta, c, *ldc );
kusano 2b45e8
}
kusano 2b45e8
kusano 2b45e8
void F77_zherk(int *order, char *uplow, char *transp, int *n, int *k,
kusano 2b45e8
     double *alpha, CBLAS_TEST_ZOMPLEX *a, int *lda, 
kusano 2b45e8
     double *beta, CBLAS_TEST_ZOMPLEX *c, int *ldc ) {
kusano 2b45e8
kusano 2b45e8
  int i,j,LDA,LDC;
kusano 2b45e8
  CBLAS_TEST_ZOMPLEX *A, *C;
kusano 2b45e8
  enum CBLAS_UPLO uplo;
kusano 2b45e8
  enum CBLAS_TRANSPOSE trans;
kusano 2b45e8
kusano 2b45e8
  get_uplo_type(uplow,&uplo);
kusano 2b45e8
  get_transpose_type(transp,&trans);
kusano 2b45e8
kusano 2b45e8
  if (*order == TEST_ROW_MJR) {
kusano 2b45e8
     if (trans == CblasNoTrans) {
kusano 2b45e8
        LDA = *k+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
        for( i=0; i<*n; i++ )
kusano 2b45e8
           for( j=0; j<*k; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     else{
kusano 2b45e8
        LDA = *n+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*k)*LDA*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
        for( i=0; i<*k; i++ )
kusano 2b45e8
           for( j=0; j<*n; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     LDC = *n+1;
kusano 2b45e8
     C=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDC*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
     for( i=0; i<*n; i++ )
kusano 2b45e8
        for( j=0; j<*n; j++ ) {
kusano 2b45e8
           C[i*LDC+j].real=c[j*(*ldc)+i].real;
kusano 2b45e8
           C[i*LDC+j].imag=c[j*(*ldc)+i].imag;
kusano 2b45e8
        }
kusano 2b45e8
     cblas_zherk(CblasRowMajor, uplo, trans, *n, *k, *alpha, A, LDA, *beta, 
kusano 2b45e8
	         C, LDC );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*n; i++ ) {
kusano 2b45e8
           c[j*(*ldc)+i].real=C[i*LDC+j].real;
kusano 2b45e8
           c[j*(*ldc)+i].imag=C[i*LDC+j].imag;
kusano 2b45e8
        }
kusano 2b45e8
     free(A);
kusano 2b45e8
     free(C);
kusano 2b45e8
  }
kusano 2b45e8
  else if (*order == TEST_COL_MJR)
kusano 2b45e8
     cblas_zherk(CblasColMajor, uplo, trans, *n, *k, *alpha, a, *lda, *beta, 
kusano 2b45e8
	         c, *ldc );
kusano 2b45e8
  else
kusano 2b45e8
     cblas_zherk(UNDEFINED, uplo, trans, *n, *k, *alpha, a, *lda, *beta, 
kusano 2b45e8
	         c, *ldc );
kusano 2b45e8
}
kusano 2b45e8
kusano 2b45e8
void F77_zsyrk(int *order, char *uplow, char *transp, int *n, int *k,
kusano 2b45e8
     CBLAS_TEST_ZOMPLEX *alpha, CBLAS_TEST_ZOMPLEX *a, int *lda, 
kusano 2b45e8
     CBLAS_TEST_ZOMPLEX *beta, CBLAS_TEST_ZOMPLEX *c, int *ldc ) {
kusano 2b45e8
kusano 2b45e8
  int i,j,LDA,LDC;
kusano 2b45e8
  CBLAS_TEST_ZOMPLEX *A, *C;
kusano 2b45e8
  enum CBLAS_UPLO uplo;
kusano 2b45e8
  enum CBLAS_TRANSPOSE trans;
kusano 2b45e8
kusano 2b45e8
  get_uplo_type(uplow,&uplo);
kusano 2b45e8
  get_transpose_type(transp,&trans);
kusano 2b45e8
kusano 2b45e8
  if (*order == TEST_ROW_MJR) {
kusano 2b45e8
     if (trans == CblasNoTrans) {
kusano 2b45e8
        LDA = *k+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*n; i++ )
kusano 2b45e8
           for( j=0; j<*k; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     else{
kusano 2b45e8
        LDA = *n+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*k)*LDA*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
        for( i=0; i<*k; i++ )
kusano 2b45e8
           for( j=0; j<*n; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     LDC = *n+1;
kusano 2b45e8
     C=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDC*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
     for( i=0; i<*n; i++ )
kusano 2b45e8
        for( j=0; j<*n; j++ ) {
kusano 2b45e8
           C[i*LDC+j].real=c[j*(*ldc)+i].real;
kusano 2b45e8
           C[i*LDC+j].imag=c[j*(*ldc)+i].imag;
kusano 2b45e8
        }
kusano 2b45e8
     cblas_zsyrk(CblasRowMajor, uplo, trans, *n, *k, alpha, A, LDA, beta, 
kusano 2b45e8
	         C, LDC );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*n; i++ ) {
kusano 2b45e8
           c[j*(*ldc)+i].real=C[i*LDC+j].real;
kusano 2b45e8
           c[j*(*ldc)+i].imag=C[i*LDC+j].imag;
kusano 2b45e8
        }
kusano 2b45e8
     free(A);
kusano 2b45e8
     free(C);
kusano 2b45e8
  }
kusano 2b45e8
  else if (*order == TEST_COL_MJR)
kusano 2b45e8
     cblas_zsyrk(CblasColMajor, uplo, trans, *n, *k, alpha, a, *lda, beta, 
kusano 2b45e8
	         c, *ldc );
kusano 2b45e8
  else
kusano 2b45e8
     cblas_zsyrk(UNDEFINED, uplo, trans, *n, *k, alpha, a, *lda, beta, 
kusano 2b45e8
	         c, *ldc );
kusano 2b45e8
}
kusano 2b45e8
void F77_zher2k(int *order, char *uplow, char *transp, int *n, int *k,
kusano 2b45e8
        CBLAS_TEST_ZOMPLEX *alpha, CBLAS_TEST_ZOMPLEX *a, int *lda,
kusano 2b45e8
	CBLAS_TEST_ZOMPLEX *b, int *ldb, double *beta,
kusano 2b45e8
        CBLAS_TEST_ZOMPLEX *c, int *ldc ) {
kusano 2b45e8
  int i,j,LDA,LDB,LDC;
kusano 2b45e8
  CBLAS_TEST_ZOMPLEX *A, *B, *C;
kusano 2b45e8
  enum CBLAS_UPLO uplo;
kusano 2b45e8
  enum CBLAS_TRANSPOSE trans;
kusano 2b45e8
kusano 2b45e8
  get_uplo_type(uplow,&uplo);
kusano 2b45e8
  get_transpose_type(transp,&trans);
kusano 2b45e8
kusano 2b45e8
  if (*order == TEST_ROW_MJR) {
kusano 2b45e8
     if (trans == CblasNoTrans) {
kusano 2b45e8
        LDA = *k+1;
kusano 2b45e8
        LDB = *k+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_ZOMPLEX ));
kusano 2b45e8
        B=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDB*sizeof(CBLAS_TEST_ZOMPLEX ));
kusano 2b45e8
        for( i=0; i<*n; i++ )
kusano 2b45e8
           for( j=0; j<*k; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
              B[i*LDB+j].real=b[j*(*ldb)+i].real;
kusano 2b45e8
              B[i*LDB+j].imag=b[j*(*ldb)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     else {
kusano 2b45e8
        LDA = *n+1;
kusano 2b45e8
        LDB = *n+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc( LDA*(*k)*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
        B=(CBLAS_TEST_ZOMPLEX* )malloc( LDB*(*k)*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
        for( i=0; i<*k; i++ )
kusano 2b45e8
           for( j=0; j<*n; j++ ){
kusano 2b45e8
	      A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
              B[i*LDB+j].real=b[j*(*ldb)+i].real;
kusano 2b45e8
              B[i*LDB+j].imag=b[j*(*ldb)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     LDC = *n+1;
kusano 2b45e8
     C=(CBLAS_TEST_ZOMPLEX* )malloc( (*n)*LDC*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
     for( i=0; i<*n; i++ )
kusano 2b45e8
        for( j=0; j<*n; j++ ) {
kusano 2b45e8
           C[i*LDC+j].real=c[j*(*ldc)+i].real;
kusano 2b45e8
           C[i*LDC+j].imag=c[j*(*ldc)+i].imag;
kusano 2b45e8
        }
kusano 2b45e8
     cblas_zher2k(CblasRowMajor, uplo, trans, *n, *k, alpha, A, LDA, 
kusano 2b45e8
		  B, LDB, *beta, C, LDC );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*n; i++ ) {
kusano 2b45e8
           c[j*(*ldc)+i].real=C[i*LDC+j].real;
kusano 2b45e8
           c[j*(*ldc)+i].imag=C[i*LDC+j].imag;
kusano 2b45e8
        }
kusano 2b45e8
     free(A);
kusano 2b45e8
     free(B);
kusano 2b45e8
     free(C);
kusano 2b45e8
  }
kusano 2b45e8
  else if (*order == TEST_COL_MJR)
kusano 2b45e8
     cblas_zher2k(CblasColMajor, uplo, trans, *n, *k, alpha, a, *lda, 
kusano 2b45e8
		   b, *ldb, *beta, c, *ldc );
kusano 2b45e8
  else
kusano 2b45e8
     cblas_zher2k(UNDEFINED, uplo, trans, *n, *k, alpha, a, *lda, 
kusano 2b45e8
		   b, *ldb, *beta, c, *ldc );
kusano 2b45e8
}
kusano 2b45e8
void F77_zsyr2k(int *order, char *uplow, char *transp, int *n, int *k,
kusano 2b45e8
         CBLAS_TEST_ZOMPLEX *alpha, CBLAS_TEST_ZOMPLEX *a, int *lda,
kusano 2b45e8
	 CBLAS_TEST_ZOMPLEX *b, int *ldb, CBLAS_TEST_ZOMPLEX *beta,
kusano 2b45e8
         CBLAS_TEST_ZOMPLEX *c, int *ldc ) {
kusano 2b45e8
  int i,j,LDA,LDB,LDC;
kusano 2b45e8
  CBLAS_TEST_ZOMPLEX *A, *B, *C;
kusano 2b45e8
  enum CBLAS_UPLO uplo;
kusano 2b45e8
  enum CBLAS_TRANSPOSE trans;
kusano 2b45e8
kusano 2b45e8
  get_uplo_type(uplow,&uplo);
kusano 2b45e8
  get_transpose_type(transp,&trans);
kusano 2b45e8
kusano 2b45e8
  if (*order == TEST_ROW_MJR) {
kusano 2b45e8
     if (trans == CblasNoTrans) {
kusano 2b45e8
        LDA = *k+1;
kusano 2b45e8
        LDB = *k+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        B=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDB*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*n; i++ )
kusano 2b45e8
           for( j=0; j<*k; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
              B[i*LDB+j].real=b[j*(*ldb)+i].real;
kusano 2b45e8
              B[i*LDB+j].imag=b[j*(*ldb)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     else {
kusano 2b45e8
        LDA = *n+1;
kusano 2b45e8
        LDB = *n+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc(LDA*(*k)*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        B=(CBLAS_TEST_ZOMPLEX* )malloc(LDB*(*k)*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*k; i++ )
kusano 2b45e8
           for( j=0; j<*n; j++ ){
kusano 2b45e8
	      A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
              B[i*LDB+j].real=b[j*(*ldb)+i].real;
kusano 2b45e8
              B[i*LDB+j].imag=b[j*(*ldb)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     LDC = *n+1;
kusano 2b45e8
     C=(CBLAS_TEST_ZOMPLEX* )malloc( (*n)*LDC*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
     for( i=0; i<*n; i++ )
kusano 2b45e8
        for( j=0; j<*n; j++ ) {
kusano 2b45e8
           C[i*LDC+j].real=c[j*(*ldc)+i].real;
kusano 2b45e8
           C[i*LDC+j].imag=c[j*(*ldc)+i].imag;
kusano 2b45e8
        }
kusano 2b45e8
     cblas_zsyr2k(CblasRowMajor, uplo, trans, *n, *k, alpha, A, LDA, 
kusano 2b45e8
		  B, LDB, beta, C, LDC );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*n; i++ ) {
kusano 2b45e8
           c[j*(*ldc)+i].real=C[i*LDC+j].real;
kusano 2b45e8
           c[j*(*ldc)+i].imag=C[i*LDC+j].imag;
kusano 2b45e8
        }
kusano 2b45e8
     free(A);
kusano 2b45e8
     free(B);
kusano 2b45e8
     free(C);
kusano 2b45e8
  }
kusano 2b45e8
  else if (*order == TEST_COL_MJR)
kusano 2b45e8
     cblas_zsyr2k(CblasColMajor, uplo, trans, *n, *k, alpha, a, *lda, 
kusano 2b45e8
		   b, *ldb, beta, c, *ldc );
kusano 2b45e8
  else
kusano 2b45e8
     cblas_zsyr2k(UNDEFINED, uplo, trans, *n, *k, alpha, a, *lda, 
kusano 2b45e8
		   b, *ldb, beta, c, *ldc );
kusano 2b45e8
}
kusano 2b45e8
void F77_ztrmm(int *order, char *rtlf, char *uplow, char *transp, char *diagn,
kusano 2b45e8
       int *m, int *n, CBLAS_TEST_ZOMPLEX *alpha, CBLAS_TEST_ZOMPLEX *a, 
kusano 2b45e8
       int *lda, CBLAS_TEST_ZOMPLEX *b, int *ldb) {
kusano 2b45e8
  int i,j,LDA,LDB;
kusano 2b45e8
  CBLAS_TEST_ZOMPLEX *A, *B;
kusano 2b45e8
  enum CBLAS_SIDE side;
kusano 2b45e8
  enum CBLAS_DIAG diag;
kusano 2b45e8
  enum CBLAS_UPLO uplo;
kusano 2b45e8
  enum CBLAS_TRANSPOSE trans;
kusano 2b45e8
kusano 2b45e8
  get_uplo_type(uplow,&uplo);
kusano 2b45e8
  get_transpose_type(transp,&trans);
kusano 2b45e8
  get_diag_type(diagn,&diag);
kusano 2b45e8
  get_side_type(rtlf,&side);
kusano 2b45e8
kusano 2b45e8
  if (*order == TEST_ROW_MJR) {
kusano 2b45e8
     if (side == CblasLeft) {
kusano 2b45e8
        LDA = *m+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*m)*LDA*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*m; i++ )
kusano 2b45e8
           for( j=0; j<*m; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     else{
kusano 2b45e8
        LDA = *n+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*n; i++ )
kusano 2b45e8
           for( j=0; j<*n; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     LDB = *n+1;
kusano 2b45e8
     B=(CBLAS_TEST_ZOMPLEX* )malloc((*m)*LDB*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
     for( i=0; i<*m; i++ )
kusano 2b45e8
        for( j=0; j<*n; j++ ) {
kusano 2b45e8
           B[i*LDB+j].real=b[j*(*ldb)+i].real;
kusano 2b45e8
           B[i*LDB+j].imag=b[j*(*ldb)+i].imag;
kusano 2b45e8
        }
kusano 2b45e8
     cblas_ztrmm(CblasRowMajor, side, uplo, trans, diag, *m, *n, alpha, 
kusano 2b45e8
		 A, LDA, B, LDB );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*m; i++ ) {
kusano 2b45e8
           b[j*(*ldb)+i].real=B[i*LDB+j].real;
kusano 2b45e8
           b[j*(*ldb)+i].imag=B[i*LDB+j].imag;
kusano 2b45e8
        }
kusano 2b45e8
     free(A);
kusano 2b45e8
     free(B);
kusano 2b45e8
  }
kusano 2b45e8
  else if (*order == TEST_COL_MJR)
kusano 2b45e8
     cblas_ztrmm(CblasColMajor, side, uplo, trans, diag, *m, *n, alpha, 
kusano 2b45e8
		   a, *lda, b, *ldb);
kusano 2b45e8
  else
kusano 2b45e8
     cblas_ztrmm(UNDEFINED, side, uplo, trans, diag, *m, *n, alpha, 
kusano 2b45e8
		   a, *lda, b, *ldb);
kusano 2b45e8
}
kusano 2b45e8
kusano 2b45e8
void F77_ztrsm(int *order, char *rtlf, char *uplow, char *transp, char *diagn,
kusano 2b45e8
         int *m, int *n, CBLAS_TEST_ZOMPLEX *alpha, CBLAS_TEST_ZOMPLEX *a, 
kusano 2b45e8
         int *lda, CBLAS_TEST_ZOMPLEX *b, int *ldb) {
kusano 2b45e8
  int i,j,LDA,LDB;
kusano 2b45e8
  CBLAS_TEST_ZOMPLEX *A, *B;
kusano 2b45e8
  enum CBLAS_SIDE side;
kusano 2b45e8
  enum CBLAS_DIAG diag;
kusano 2b45e8
  enum CBLAS_UPLO uplo;
kusano 2b45e8
  enum CBLAS_TRANSPOSE trans;
kusano 2b45e8
kusano 2b45e8
  get_uplo_type(uplow,&uplo);
kusano 2b45e8
  get_transpose_type(transp,&trans);
kusano 2b45e8
  get_diag_type(diagn,&diag);
kusano 2b45e8
  get_side_type(rtlf,&side);
kusano 2b45e8
kusano 2b45e8
  if (*order == TEST_ROW_MJR) {
kusano 2b45e8
     if (side == CblasLeft) {
kusano 2b45e8
        LDA = *m+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc( (*m)*LDA*sizeof(CBLAS_TEST_ZOMPLEX ) );
kusano 2b45e8
        for( i=0; i<*m; i++ )
kusano 2b45e8
           for( j=0; j<*m; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     else{
kusano 2b45e8
        LDA = *n+1;
kusano 2b45e8
        A=(CBLAS_TEST_ZOMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
        for( i=0; i<*n; i++ )
kusano 2b45e8
           for( j=0; j<*n; j++ ) {
kusano 2b45e8
              A[i*LDA+j].real=a[j*(*lda)+i].real;
kusano 2b45e8
              A[i*LDA+j].imag=a[j*(*lda)+i].imag;
kusano 2b45e8
           }
kusano 2b45e8
     }
kusano 2b45e8
     LDB = *n+1;
kusano 2b45e8
     B=(CBLAS_TEST_ZOMPLEX* )malloc((*m)*LDB*sizeof(CBLAS_TEST_ZOMPLEX));
kusano 2b45e8
     for( i=0; i<*m; i++ )
kusano 2b45e8
        for( j=0; j<*n; j++ ) {
kusano 2b45e8
           B[i*LDB+j].real=b[j*(*ldb)+i].real;
kusano 2b45e8
           B[i*LDB+j].imag=b[j*(*ldb)+i].imag;
kusano 2b45e8
        }
kusano 2b45e8
     cblas_ztrsm(CblasRowMajor, side, uplo, trans, diag, *m, *n, alpha, 
kusano 2b45e8
		 A, LDA, B, LDB );
kusano 2b45e8
     for( j=0; j<*n; j++ )
kusano 2b45e8
        for( i=0; i<*m; i++ ) {
kusano 2b45e8
           b[j*(*ldb)+i].real=B[i*LDB+j].real;
kusano 2b45e8
           b[j*(*ldb)+i].imag=B[i*LDB+j].imag;
kusano 2b45e8
        }
kusano 2b45e8
     free(A);
kusano 2b45e8
     free(B);
kusano 2b45e8
  }
kusano 2b45e8
  else if (*order == TEST_COL_MJR)
kusano 2b45e8
     cblas_ztrsm(CblasColMajor, side, uplo, trans, diag, *m, *n, alpha, 
kusano 2b45e8
		   a, *lda, b, *ldb);
kusano 2b45e8
  else
kusano 2b45e8
     cblas_ztrsm(UNDEFINED, side, uplo, trans, diag, *m, *n, alpha, 
kusano 2b45e8
		   a, *lda, b, *ldb);
kusano 2b45e8
}