/*
 * cblas_f77.h
 * Written by Keita Teranishi
 *
 * Updated by Jeff Horner
 * Merged cblas_f77.h and cblas_fortran_header.h
 */

#ifndef CBLAS_F77_H
#define CBLAS_F77_H

#define FCHAR char *
#define FINT const int *

/*
 * Level 1 BLAS
 */
// Google-local: Nonstandard xerbla name to avoid collisions with LAPACK.
#define F77_xerbla cblas_f77_xerbla_
#define F77_srotg      srotg_
#define F77_srotmg     srotmg_
#define F77_srot       srot_
#define F77_srotm      srotm_
#define F77_drotg      drotg_
#define F77_drotmg     drotmg_
#define F77_drot       drot_
#define F77_drotm      drotm_
#define F77_sswap      sswap_
#define F77_scopy      scopy_
#define F77_saxpy      saxpy_
#define F77_dswap      dswap_
#define F77_dcopy      dcopy_
#define F77_daxpy      daxpy_
#define F77_cswap      cswap_
#define F77_ccopy      ccopy_
#define F77_caxpy      caxpy_
#define F77_zswap      zswap_
#define F77_zcopy      zcopy_
#define F77_zaxpy      zaxpy_
#define F77_sscal      sscal_
#define F77_dscal      dscal_
#define F77_cscal      cscal_
#define F77_zscal      zscal_
#define F77_csscal      csscal_
#define F77_zdscal      zdscal_

// Google-local: Use the function version of these, so that we don't need
// the built-in Fortran wrappers.
#define F77_sdot   sdot_
#define F77_ddot   ddot_
#define F77_dsdot   dsdot_
#define F77_sdsdot   sdsdot_
#define F77_snrm2  snrm2_
#define F77_sasum  sasum_
#define F77_dnrm2  dnrm2_
#define F77_dasum  dasum_
#define F77_isamax isamax_
#define F77_idamax idamax_
#define F77_icamax icamax_
#define F77_izamax izamax_
#define F77_scnrm2  scnrm2_
#define F77_scasum  scasum_
#define F77_dznrm2  dznrm2_
#define F77_dzasum  dzasum_

// Google-local: Use Eigen's "subroutine" versions of these functions, not
// the built-in Fortran wrappers.
#define F77_cdotc_sub  cdotcw_
#define F77_cdotu_sub  cdotuw_
#define F77_zdotu_sub  zdotuw_
#define F77_zdotc_sub  zdotcw_

/*
 * Level 2 BLAS
 */
#define F77_ssymv      ssymv_
#define F77_ssbmv      ssbmv_
#define F77_sspmv      sspmv_
#define F77_sger       sger_
#define F77_ssyr       ssyr_
#define F77_sspr       sspr_
#define F77_ssyr2      ssyr2_
#define F77_sspr2      sspr2_
#define F77_dsymv      dsymv_
#define F77_dsbmv      dsbmv_
#define F77_dspmv      dspmv_
#define F77_dger       dger_
#define F77_dsyr       dsyr_
#define F77_dspr       dspr_
#define F77_dsyr2      dsyr2_
#define F77_dspr2      dspr2_
#define F77_chemv      chemv_
#define F77_chbmv      chbmv_
#define F77_chpmv      chpmv_
#define F77_cgeru      cgeru_
#define F77_cgerc      cgerc_
#define F77_cher       cher_
#define F77_chpr       chpr_
#define F77_cher2      cher2_
#define F77_chpr2      chpr2_
#define F77_zhemv      zhemv_
#define F77_zhbmv      zhbmv_
#define F77_zhpmv      zhpmv_
#define F77_zgeru      zgeru_
#define F77_zgerc      zgerc_
#define F77_zher       zher_
#define F77_zhpr       zhpr_
#define F77_zher2      zher2_
#define F77_zhpr2      zhpr2_
#define F77_sgemv      sgemv_
#define F77_sgbmv      sgbmv_
#define F77_strmv      strmv_
#define F77_stbmv      stbmv_
#define F77_stpmv      stpmv_
#define F77_strsv      strsv_
#define F77_stbsv      stbsv_
#define F77_stpsv      stpsv_
#define F77_dgemv      dgemv_
#define F77_dgbmv      dgbmv_
#define F77_dtrmv      dtrmv_
#define F77_dtbmv      dtbmv_
#define F77_dtpmv      dtpmv_
#define F77_dtrsv      dtrsv_
#define F77_dtbsv      dtbsv_
#define F77_dtpsv      dtpsv_
#define F77_cgemv      cgemv_
#define F77_cgbmv      cgbmv_
#define F77_ctrmv      ctrmv_
#define F77_ctbmv      ctbmv_
#define F77_ctpmv      ctpmv_
#define F77_ctrsv      ctrsv_
#define F77_ctbsv      ctbsv_
#define F77_ctpsv      ctpsv_
#define F77_zgemv      zgemv_
#define F77_zgbmv      zgbmv_
#define F77_ztrmv      ztrmv_
#define F77_ztbmv      ztbmv_
#define F77_ztpmv      ztpmv_
#define F77_ztrsv      ztrsv_
#define F77_ztbsv      ztbsv_
#define F77_ztpsv      ztpsv_
/*
 * Level 3 BLAS
 */
#define F77_chemm      chemm_
#define F77_cherk      cherk_
#define F77_cher2k     cher2k_
#define F77_zhemm      zhemm_
#define F77_zherk      zherk_
#define F77_zher2k     zher2k_
#define F77_sgemm      sgemm_
#define F77_ssymm      ssymm_
#define F77_ssyrk      ssyrk_
#define F77_ssyr2k     ssyr2k_
#define F77_strmm      strmm_
#define F77_strsm      strsm_
#define F77_dgemm      dgemm_
#define F77_dsymm      dsymm_
#define F77_dsyrk      dsyrk_
#define F77_dsyr2k     dsyr2k_
#define F77_dtrmm      dtrmm_
#define F77_dtrsm      dtrsm_
#define F77_cgemm      cgemm_
#define F77_csymm      csymm_
#define F77_csyrk      csyrk_
#define F77_csyr2k     csyr2k_
#define F77_ctrmm      ctrmm_
#define F77_ctrsm      ctrsm_
#define F77_zgemm      zgemm_
#define F77_zsymm      zsymm_
#define F77_zsyrk      zsyrk_
#define F77_zsyr2k     zsyr2k_
#define F77_ztrmm      ztrmm_
#define F77_ztrsm      ztrsm_

#ifdef __cplusplus
extern "C" {
#endif

   void F77_xerbla(FCHAR, void *);
/*
 * Level 1 Fortran Prototypes
 */

/* Single Precision */

   void F77_srot(FINT, float *, FINT, float *, FINT, const float *, const float *);
   void F77_srotg(float *,float *,float *,float *);    
   void F77_srotm( FINT, float *, FINT, float *, FINT, const float *);
   void F77_srotmg(float *,float *,float *,const float *, float *);
   void F77_sswap( FINT, float *, FINT, float *, FINT);
   void F77_scopy( FINT, const float *, FINT, float *, FINT);
   void F77_saxpy( FINT, const float *, const float *, FINT, float *, FINT);
   void F77_sscal( FINT, const float *, float *, FINT);

   // Google-local: Use the function version of these, so that we don't need
   // the built-in Fortran wrappers.
   float F77_sdot(FINT, const float *, FINT, const float *, FINT);
   float F77_sdsdot( FINT, const float *, const float *, FINT, const float *, FINT);
   float F77_snrm2( FINT, const float *, FINT);
   float F77_sasum( FINT, const float *, FINT);
   int F77_isamax( FINT, const float *, FINT);

/* Double Precision */

   void F77_drot(FINT, double *, FINT, double *, FINT, const double *, const double *);
   void F77_drotg(double *,double *,double *,double *);    
   void F77_drotm( FINT, double *, FINT, double *, FINT, const double *);
   void F77_drotmg(double *,double *,double *,const double *, double *);
   void F77_dswap( FINT, double *, FINT, double *, FINT);
   void F77_dcopy( FINT, const double *, FINT, double *, FINT);
   void F77_daxpy( FINT, const double *, const double *, FINT, double *, FINT);
   void F77_dswap( FINT, double *, FINT, double *, FINT);
   void F77_dscal( FINT, const double *, double *, FINT);

   // Google-local: Use the function version of these, so that we don't need
   // the built-in Fortran wrappers.
   double F77_ddot(FINT, const double *, FINT, const double *, FINT);
   double F77_dsdot(FINT, const float *, FINT, const float *, FINT);
   double F77_dnrm2( FINT, const double *, FINT);
   double F77_dasum( FINT, const double *, FINT);
   int F77_idamax( FINT, const double * , FINT);

/* Single Complex Precision */

   void F77_cswap( FINT, void *, FINT, void *, FINT);
   void F77_ccopy( FINT, const void *, FINT, void *, FINT);
   void F77_caxpy( FINT, const void *, const void *, FINT, void *, FINT);
   void F77_cswap( FINT, void *, FINT, void *, FINT);
   void F77_cdotc_sub( FINT, const void *, FINT, const void *, FINT, void *);
   void F77_cdotu_sub( FINT, const void *, FINT, const void *, FINT, void *);
   void F77_cscal( FINT, const void *, void *, FINT);
   void F77_csscal( FINT, const float *, void *, FINT);

   // Google-local: Use the function version of these, so that we don't need
   // the built-in Fortran wrappers.
   int F77_icamax( FINT, const void *, FINT);
   float F77_scnrm2( FINT, const void *, FINT);
   float F77_scasum( FINT, const void *, FINT);

/* Double Complex Precision */

   void F77_zswap( FINT, void *, FINT, void *, FINT);
   void F77_zcopy( FINT, const void *, FINT, void *, FINT);
   void F77_zaxpy( FINT, const void *, const void *, FINT, void *, FINT);
   void F77_zswap( FINT, void *, FINT, void *, FINT);
   void F77_zdotc_sub( FINT, const void *, FINT, const void *, FINT, void *);
   void F77_zdotu_sub( FINT, const void *, FINT, const void *, FINT, void *);
   void F77_zdscal( FINT, const double *, void *, FINT);
   void F77_zscal( FINT, const void *, void *, FINT);

   // Google-local: Use the function version of these, so that we don't need
   // the built-in Fortran wrappers.
   int F77_izamax( FINT, const void *, FINT);
   double F77_dznrm2( FINT, const void *, FINT);
   double F77_dzasum( FINT, const void *, FINT);

/*
 * Level 2 Fortran Prototypes
 */

/* Single Precision */

   void F77_sgemv(FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_sgbmv(FCHAR, FINT, FINT, FINT, FINT, const float *,  const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_ssymv(FCHAR, FINT, const float *, const float *, FINT, const float *,  FINT, const float *, float *, FINT);
   void F77_ssbmv(FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_sspmv(FCHAR, FINT, const float *, const float *, const float *, FINT, const float *, float *, FINT);
   void F77_strmv( FCHAR, FCHAR, FCHAR, FINT, const float *, FINT, float *, FINT);
   void F77_stbmv( FCHAR, FCHAR, FCHAR, FINT, FINT, const float *, FINT, float *, FINT);
   void F77_strsv( FCHAR, FCHAR, FCHAR, FINT, const float *, FINT, float *, FINT);
   void F77_stbsv( FCHAR, FCHAR, FCHAR, FINT, FINT, const float *, FINT, float *, FINT);
   void F77_stpmv( FCHAR, FCHAR, FCHAR, FINT, const float *, float *, FINT);
   void F77_stpsv( FCHAR, FCHAR, FCHAR, FINT, const float *, float *, FINT);
   void F77_sger( FINT, FINT, const float *, const float *, FINT, const float *, FINT, float *, FINT);
   void F77_ssyr(FCHAR, FINT, const float *, const float *, FINT, float *, FINT);
   void F77_sspr(FCHAR, FINT, const float *, const float *, FINT, float *); 
   void F77_sspr2(FCHAR, FINT, const float *, const float *, FINT, const float *, FINT,  float *); 
   void F77_ssyr2(FCHAR, FINT, const float *, const float *, FINT, const float *, FINT,  float *, FINT);

/* Double Precision */

   void F77_dgemv(FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_dgbmv(FCHAR, FINT, FINT, FINT, FINT, const double *,  const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_dsymv(FCHAR, FINT, const double *, const double *, FINT, const double *,  FINT, const double *, double *, FINT);
   void F77_dsbmv(FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_dspmv(FCHAR, FINT, const double *, const double *, const double *, FINT, const double *, double *, FINT);
   void F77_dtrmv( FCHAR, FCHAR, FCHAR, FINT, const double *, FINT, double *, FINT);
   void F77_dtbmv( FCHAR, FCHAR, FCHAR, FINT, FINT, const double *, FINT, double *, FINT);
   void F77_dtrsv( FCHAR, FCHAR, FCHAR, FINT, const double *, FINT, double *, FINT);
   void F77_dtbsv( FCHAR, FCHAR, FCHAR, FINT, FINT, const double *, FINT, double *, FINT);
   void F77_dtpmv( FCHAR, FCHAR, FCHAR, FINT, const double *, double *, FINT);
   void F77_dtpsv( FCHAR, FCHAR, FCHAR, FINT, const double *, double *, FINT);
   void F77_dger( FINT, FINT, const double *, const double *, FINT, const double *, FINT, double *, FINT);
   void F77_dsyr(FCHAR, FINT, const double *, const double *, FINT, double *, FINT);
   void F77_dspr(FCHAR, FINT, const double *, const double *, FINT, double *); 
   void F77_dspr2(FCHAR, FINT, const double *, const double *, FINT, const double *, FINT,  double *); 
   void F77_dsyr2(FCHAR, FINT, const double *, const double *, FINT, const double *, FINT,  double *, FINT);

/* Single Complex Precision */

   void F77_cgemv(FCHAR, FINT, FINT, const void *, const void *, FINT, const void *, FINT, const void *, void *, FINT);
   void F77_cgbmv(FCHAR, FINT, FINT, FINT, FINT, const void *,  const void *, FINT, const void *, FINT, const void *, void *, FINT);
   void F77_chemv(FCHAR, FINT, const void *, const void *, FINT, const void *, FINT, const void *, void *, FINT);
   void F77_chbmv(FCHAR, FINT, FINT, const void *, const void *, FINT, const void *, FINT, const void *, void *, FINT);
   void F77_chpmv(FCHAR, FINT, const void *, const void *, const void *, FINT, const void *, void *, FINT);
   void F77_ctrmv( FCHAR, FCHAR, FCHAR, FINT, const void *, FINT, void *, FINT);
   void F77_ctbmv( FCHAR, FCHAR, FCHAR, FINT, FINT, const void *, FINT, void *, FINT);
   void F77_ctpmv( FCHAR, FCHAR, FCHAR, FINT, const void *, void *, FINT);
   void F77_ctrsv( FCHAR, FCHAR, FCHAR, FINT, const void *, FINT, void *, FINT);
   void F77_ctbsv( FCHAR, FCHAR, FCHAR, FINT, FINT, const void *, FINT, void *, FINT);
   void F77_ctpsv( FCHAR, FCHAR, FCHAR, FINT, const void *, void *,FINT);
   void F77_cgerc( FINT, FINT, const void *, const void *, FINT, const void *, FINT, void *, FINT);
   void F77_cgeru( FINT, FINT, const void *, const void *, FINT, const void *, FINT, void *,  FINT);
   void F77_cher(FCHAR, FINT, const float *, const void *, FINT, void *, FINT);
   void F77_cher2(FCHAR, FINT, const void *, const void *, FINT, const void *, FINT, void *, FINT);
   void F77_chpr(FCHAR, FINT, const float *, const void *, FINT, void *);
   void F77_chpr2(FCHAR, FINT, const float *, const void *, FINT, const void *, FINT, void *);

/* Double Complex Precision */

   void F77_zgemv(FCHAR, FINT, FINT, const void *, const void *, FINT, const void *, FINT, const void *, void *, FINT);
   void F77_zgbmv(FCHAR, FINT, FINT, FINT, FINT, const void *,  const void *, FINT, const void *, FINT, const void *, void *, FINT);
   void F77_zhemv(FCHAR, FINT, const void *, const void *, FINT, const void *, FINT, const void *, void *, FINT);
   void F77_zhbmv(FCHAR, FINT, FINT, const void *, const void *, FINT, const void *, FINT, const void *, void *, FINT);
   void F77_zhpmv(FCHAR, FINT, const void *, const void *, const void *, FINT, const void *, void *, FINT);
   void F77_ztrmv( FCHAR, FCHAR, FCHAR, FINT, const void *, FINT, void *, FINT);
   void F77_ztbmv( FCHAR, FCHAR, FCHAR, FINT, FINT, const void *, FINT, void *, FINT);
   void F77_ztpmv( FCHAR, FCHAR, FCHAR, FINT, const void *, void *, FINT);
   void F77_ztrsv( FCHAR, FCHAR, FCHAR, FINT, const void *, FINT, void *, FINT);
   void F77_ztbsv( FCHAR, FCHAR, FCHAR, FINT, FINT, const void *, FINT, void *, FINT);
   void F77_ztpsv( FCHAR, FCHAR, FCHAR, FINT, const void *, void *,FINT);
   void F77_zgerc( FINT, FINT, const void *, const void *, FINT, const void *, FINT, void *, FINT);
   void F77_zgeru( FINT, FINT, const void *, const void *, FINT, const void *, FINT, void *,  FINT);
   void F77_zher(FCHAR, FINT, const double *, const void *, FINT, void *, FINT);
   void F77_zher2(FCHAR, FINT, const void *, const void *, FINT, const void *, FINT, void *, FINT);
   void F77_zhpr(FCHAR, FINT, const double *, const void *, FINT, void *);
   void F77_zhpr2(FCHAR, FINT, const double *, const void *, FINT, const void *, FINT, void *);

/*
 * Level 3 Fortran Prototypes
 */

/* Single Precision */

   void F77_sgemm(FCHAR, FCHAR, FINT, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_ssymm(FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_ssyrk(FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, float *, FINT);
   void F77_ssyr2k(FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_strmm(FCHAR, FCHAR, FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, float *, FINT);
   void F77_strsm(FCHAR, FCHAR, FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, float *, FINT);

/* Double Precision */

   void F77_dgemm(FCHAR, FCHAR, FINT, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_dsymm(FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_dsyrk(FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, double *, FINT);
   void F77_dsyr2k(FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_dtrmm(FCHAR, FCHAR, FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, double *, FINT);
   void F77_dtrsm(FCHAR, FCHAR, FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, double *, FINT);

/* Single Complex Precision */

   void F77_cgemm(FCHAR, FCHAR, FINT, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_csymm(FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_chemm(FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_csyrk(FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, float *, FINT);
   void F77_cherk(FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, float *, FINT);
   void F77_csyr2k(FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_cher2k(FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, const float *, FINT, const float *, float *, FINT);
   void F77_ctrmm(FCHAR, FCHAR, FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, float *, FINT);
   void F77_ctrsm(FCHAR, FCHAR, FCHAR, FCHAR, FINT, FINT, const float *, const float *, FINT, float *, FINT);

/* Double Complex Precision */

   void F77_zgemm(FCHAR, FCHAR, FINT, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_zsymm(FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_zhemm(FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_zsyrk(FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, double *, FINT);
   void F77_zherk(FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, double *, FINT);
   void F77_zsyr2k(FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_zher2k(FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, const double *, FINT, const double *, double *, FINT);
   void F77_ztrmm(FCHAR, FCHAR, FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, double *, FINT);
   void F77_ztrsm(FCHAR, FCHAR, FCHAR, FCHAR, FINT, FINT, const double *, const double *, FINT, double *, FINT);

#ifdef __cplusplus
}
#endif

#endif /*  CBLAS_F77_H */