/* * Written by D.P. Manley, Digital Equipment Corporation. * Prefixed "C_" to BLAS routines and their declarations. * * Modified by T. H. Do, 1/23/98, SGI/CRAY Research. */ #include #include "cblas.h" #include "cblas_test.h" void F77_dgemv(int *layout, char *transp, int *m, int *n, double *alpha, double *a, int *lda, double *x, int *incx, double *beta, double *y, int *incy ) { double *A; int i,j,LDA; CBLAS_TRANSPOSE trans; get_transpose_type(transp, &trans); if (*layout == TEST_ROW_MJR) { LDA = *n+1; A = ( double* )malloc( (*m)*LDA*sizeof( double ) ); for( i=0; i<*m; i++ ) for( j=0; j<*n; j++ ) A[ LDA*i+j ]=a[ (*lda)*j+i ]; cblas_dgemv( CblasRowMajor, trans, *m, *n, *alpha, A, LDA, x, *incx, *beta, y, *incy ); free(A); } else if (*layout == TEST_COL_MJR) cblas_dgemv( CblasColMajor, trans, *m, *n, *alpha, a, *lda, x, *incx, *beta, y, *incy ); else cblas_dgemv( UNDEFINED, trans, *m, *n, *alpha, a, *lda, x, *incx, *beta, y, *incy ); } void F77_dger(int *layout, int *m, int *n, double *alpha, double *x, int *incx, double *y, int *incy, double *a, int *lda ) { double *A; int i,j,LDA; if (*layout == TEST_ROW_MJR) { LDA = *n+1; A = ( double* )malloc( (*m)*LDA*sizeof( double ) ); for( i=0; i<*m; i++ ) { for( j=0; j<*n; j++ ) A[ LDA*i+j ]=a[ (*lda)*j+i ]; } cblas_dger(CblasRowMajor, *m, *n, *alpha, x, *incx, y, *incy, A, LDA ); for( i=0; i<*m; i++ ) for( j=0; j<*n; j++ ) a[ (*lda)*j+i ]=A[ LDA*i+j ]; free(A); } else cblas_dger( CblasColMajor, *m, *n, *alpha, x, *incx, y, *incy, a, *lda ); } void F77_dtrmv(int *layout, char *uplow, char *transp, char *diagn, int *n, double *a, int *lda, double *x, int *incx) { double *A; int i,j,LDA; CBLAS_TRANSPOSE trans; CBLAS_UPLO uplo; CBLAS_DIAG diag; get_transpose_type(transp,&trans); get_uplo_type(uplow,&uplo); get_diag_type(diagn,&diag); if (*layout == TEST_ROW_MJR) { LDA = *n+1; A = ( double* )malloc( (*n)*LDA*sizeof( double ) ); for( i=0; i<*n; i++ ) for( j=0; j<*n; j++ ) A[ LDA*i+j ]=a[ (*lda)*j+i ]; cblas_dtrmv(CblasRowMajor, uplo, trans, diag, *n, A, LDA, x, *incx); free(A); } else if (*layout == TEST_COL_MJR) cblas_dtrmv(CblasColMajor, uplo, trans, diag, *n, a, *lda, x, *incx); else { cblas_dtrmv(UNDEFINED, uplo, trans, diag, *n, a, *lda, x, *incx); } } void F77_dtrsv(int *layout, char *uplow, char *transp, char *diagn, int *n, double *a, int *lda, double *x, int *incx ) { double *A; int i,j,LDA; CBLAS_TRANSPOSE trans; CBLAS_UPLO uplo; CBLAS_DIAG diag; get_transpose_type(transp,&trans); get_uplo_type(uplow,&uplo); get_diag_type(diagn,&diag); if (*layout == TEST_ROW_MJR) { LDA = *n+1; A = ( double* )malloc( (*n)*LDA*sizeof( double ) ); for( i=0; i<*n; i++ ) for( j=0; j<*n; j++ ) A[ LDA*i+j ]=a[ (*lda)*j+i ]; cblas_dtrsv(CblasRowMajor, uplo, trans, diag, *n, A, LDA, x, *incx ); free(A); } else cblas_dtrsv(CblasColMajor, uplo, trans, diag, *n, a, *lda, x, *incx ); } void F77_dsymv(int *layout, char *uplow, int *n, double *alpha, double *a, int *lda, double *x, int *incx, double *beta, double *y, int *incy) { double *A; int i,j,LDA; CBLAS_UPLO uplo; get_uplo_type(uplow,&uplo); if (*layout == TEST_ROW_MJR) { LDA = *n+1; A = ( double* )malloc( (*n)*LDA*sizeof( double ) ); for( i=0; i<*n; i++ ) for( j=0; j<*n; j++ ) A[ LDA*i+j ]=a[ (*lda)*j+i ]; cblas_dsymv(CblasRowMajor, uplo, *n, *alpha, A, LDA, x, *incx, *beta, y, *incy ); free(A); } else cblas_dsymv(CblasColMajor, uplo, *n, *alpha, a, *lda, x, *incx, *beta, y, *incy ); } void F77_dsyr(int *layout, char *uplow, int *n, double *alpha, double *x, int *incx, double *a, int *lda) { double *A; int i,j,LDA; CBLAS_UPLO uplo; get_uplo_type(uplow,&uplo); if (*layout == TEST_ROW_MJR) { LDA = *n+1; A = ( double* )malloc( (*n)*LDA*sizeof( double ) ); for( i=0; i<*n; i++ ) for( j=0; j<*n; j++ ) A[ LDA*i+j ]=a[ (*lda)*j+i ]; cblas_dsyr(CblasRowMajor, uplo, *n, *alpha, x, *incx, A, LDA); for( i=0; i<*n; i++ ) for( j=0; j<*n; j++ ) a[ (*lda)*j+i ]=A[ LDA*i+j ]; free(A); } else cblas_dsyr(CblasColMajor, uplo, *n, *alpha, x, *incx, a, *lda); } void F77_dsyr2(int *layout, char *uplow, int *n, double *alpha, double *x, int *incx, double *y, int *incy, double *a, int *lda) { double *A; int i,j,LDA; CBLAS_UPLO uplo; get_uplo_type(uplow,&uplo); if (*layout == TEST_ROW_MJR) { LDA = *n+1; A = ( double* )malloc( (*n)*LDA*sizeof( double ) ); for( i=0; i<*n; i++ ) for( j=0; j<*n; j++ ) A[ LDA*i+j ]=a[ (*lda)*j+i ]; cblas_dsyr2(CblasRowMajor, uplo, *n, *alpha, x, *incx, y, *incy, A, LDA); for( i=0; i<*n; i++ ) for( j=0; j<*n; j++ ) a[ (*lda)*j+i ]=A[ LDA*i+j ]; free(A); } else cblas_dsyr2(CblasColMajor, uplo, *n, *alpha, x, *incx, y, *incy, a, *lda); } void F77_dgbmv(int *layout, char *transp, int *m, int *n, int *kl, int *ku, double *alpha, double *a, int *lda, double *x, int *incx, double *beta, double *y, int *incy ) { double *A; int i,irow,j,jcol,LDA; CBLAS_TRANSPOSE trans; get_transpose_type(transp, &trans); if (*layout == TEST_ROW_MJR) { LDA = *ku+*kl+2; A = ( double* )malloc( (*n+*kl)*LDA*sizeof( double ) ); for( i=0; i<*ku; i++ ){ irow=*ku+*kl-i; jcol=(*ku)-i; for( j=jcol; j<*n; j++ ) A[ LDA*(j-jcol)+irow ]=a[ (*lda)*j+i ]; } i=*ku; irow=*ku+*kl-i; for( j=0; j<*n; j++ ) A[ LDA*j+irow ]=a[ (*lda)*j+i ]; for( i=*ku+1; i<*ku+*kl+1; i++ ){ irow=*ku+*kl-i; jcol=i-(*ku); for( j=jcol; j<(*n+*kl); j++ ) A[ LDA*j+irow ]=a[ (*lda)*(j-jcol)+i ]; } cblas_dgbmv( CblasRowMajor, trans, *m, *n, *kl, *ku, *alpha, A, LDA, x, *incx, *beta, y, *incy ); free(A); } else cblas_dgbmv( CblasColMajor, trans, *m, *n, *kl, *ku, *alpha, a, *lda, x, *incx, *beta, y, *incy ); } void F77_dtbmv(int *layout, char *uplow, char *transp, char *diagn, int *n, int *k, double *a, int *lda, double *x, int *incx) { double *A; int irow, jcol, i, j, LDA; CBLAS_TRANSPOSE trans; CBLAS_UPLO uplo; CBLAS_DIAG diag; get_transpose_type(transp,&trans); get_uplo_type(uplow,&uplo); get_diag_type(diagn,&diag); if (*layout == TEST_ROW_MJR) { LDA = *k+1; A = ( double* )malloc( (*n+*k)*LDA*sizeof( double ) ); if (uplo == CblasUpper) { for( i=0; i<*k; i++ ){ irow=*k-i; jcol=(*k)-i; for( j=jcol; j<*n; j++ ) A[ LDA*(j-jcol)+irow ]=a[ (*lda)*j+i ]; } i=*k; irow=*k-i; for( j=0; j<*n; j++ ) A[ LDA*j+irow ]=a[ (*lda)*j+i ]; } else { i=0; irow=*k-i; for( j=0; j<*n; j++ ) A[ LDA*j+irow ]=a[ (*lda)*j+i ]; for( i=1; i<*k+1; i++ ){ irow=*k-i; jcol=i; for( j=jcol; j<(*n+*k); j++ ) A[ LDA*j+irow ]=a[ (*lda)*(j-jcol)+i ]; } } cblas_dtbmv(CblasRowMajor, uplo, trans, diag, *n, *k, A, LDA, x, *incx); free(A); } else cblas_dtbmv(CblasColMajor, uplo, trans, diag, *n, *k, a, *lda, x, *incx); } void F77_dtbsv(int *layout, char *uplow, char *transp, char *diagn, int *n, int *k, double *a, int *lda, double *x, int *incx) { double *A; int irow, jcol, i, j, LDA; CBLAS_TRANSPOSE trans; CBLAS_UPLO uplo; CBLAS_DIAG diag; get_transpose_type(transp,&trans); get_uplo_type(uplow,&uplo); get_diag_type(diagn,&diag); if (*layout == TEST_ROW_MJR) { LDA = *k+1; A = ( double* )malloc( (*n+*k)*LDA*sizeof( double ) ); if (uplo == CblasUpper) { for( i=0; i<*k; i++ ){ irow=*k-i; jcol=(*k)-i; for( j=jcol; j<*n; j++ ) A[ LDA*(j-jcol)+irow ]=a[ (*lda)*j+i ]; } i=*k; irow=*k-i; for( j=0; j<*n; j++ ) A[ LDA*j+irow ]=a[ (*lda)*j+i ]; } else { i=0; irow=*k-i; for( j=0; j<*n; j++ ) A[ LDA*j+irow ]=a[ (*lda)*j+i ]; for( i=1; i<*k+1; i++ ){ irow=*k-i; jcol=i; for( j=jcol; j<(*n+*k); j++ ) A[ LDA*j+irow ]=a[ (*lda)*(j-jcol)+i ]; } } cblas_dtbsv(CblasRowMajor, uplo, trans, diag, *n, *k, A, LDA, x, *incx); free(A); } else cblas_dtbsv(CblasColMajor, uplo, trans, diag, *n, *k, a, *lda, x, *incx); } void F77_dsbmv(int *layout, char *uplow, int *n, int *k, double *alpha, double *a, int *lda, double *x, int *incx, double *beta, double *y, int *incy) { double *A; int i,j,irow,jcol,LDA; CBLAS_UPLO uplo; get_uplo_type(uplow,&uplo); if (*layout == TEST_ROW_MJR) { LDA = *k+1; A = ( double* )malloc( (*n+*k)*LDA*sizeof( double ) ); if (uplo == CblasUpper) { for( i=0; i<*k; i++ ){ irow=*k-i; jcol=(*k)-i; for( j=jcol; j<*n; j++ ) A[ LDA*(j-jcol)+irow ]=a[ (*lda)*j+i ]; } i=*k; irow=*k-i; for( j=0; j<*n; j++ ) A[ LDA*j+irow ]=a[ (*lda)*j+i ]; } else { i=0; irow=*k-i; for( j=0; j<*n; j++ ) A[ LDA*j+irow ]=a[ (*lda)*j+i ]; for( i=1; i<*k+1; i++ ){ irow=*k-i; jcol=i; for( j=jcol; j<(*n+*k); j++ ) A[ LDA*j+irow ]=a[ (*lda)*(j-jcol)+i ]; } } cblas_dsbmv(CblasRowMajor, uplo, *n, *k, *alpha, A, LDA, x, *incx, *beta, y, *incy ); free(A); } else cblas_dsbmv(CblasColMajor, uplo, *n, *k, *alpha, a, *lda, x, *incx, *beta, y, *incy ); } void F77_dspmv(int *layout, char *uplow, int *n, double *alpha, double *ap, double *x, int *incx, double *beta, double *y, int *incy) { double *A,*AP; int i,j,k,LDA; CBLAS_UPLO uplo; get_uplo_type(uplow,&uplo); if (*layout == TEST_ROW_MJR) { LDA = *n; A = ( double* )malloc( LDA*LDA*sizeof( double ) ); AP = ( double* )malloc( (((LDA+1)*LDA)/2)*sizeof( double ) ); if (uplo == CblasUpper) { for( j=0, k=0; j<*n; j++ ) for( i=0; i