cblas.h

00001 /****************************************************************************
00002  * Copyright 2006 Evan Drumwright
00003  * This library is distributed under the terms of the GNU General Public 
00004  * License (found in COPYING).
00005  ****************************************************************************/
00006 
00007 /* This is a copy of the CBLAS standard header. */
00008 
00009 #ifndef __PHYSSIM_CBLAS_H__
00010 #define __PHYSSIM_CBLAS_H__
00011 #include <stddef.h>
00012 
00013 #undef __BEGIN_DECLS
00014 #undef __END_DECLS
00015 #ifdef __cplusplus
00016 #include <iostream>
00017 #include <cmath>
00018 #define __BEGIN_DECLS extern "C" {
00019 #define __END_DECLS }
00020 #else
00021 #define __BEGIN_DECLS           /* empty */
00022 #define __END_DECLS             /* empty */
00023 #endif
00024 
00025 __BEGIN_DECLS
00026 
00027 /*
00028  * Enumerated and derived types
00029  */
00030 #define CBLAS_INDEX size_t  /* this may vary between platforms */
00031 
00032 enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102};
00033 enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113};
00034 enum CBLAS_UPLO {CblasUpper=121, CblasLower=122};
00035 enum CBLAS_DIAG {CblasNonUnit=131, CblasUnit=132};
00036 enum CBLAS_SIDE {CblasLeft=141, CblasRight=142};
00037 
00038 /*
00039  * ===========================================================================
00040  * Prototypes for level 1 BLAS functions (complex are recast as routines)
00041  * ===========================================================================
00042  */
00043 float  cblas_sdsdot(const int N, const float alpha, const float *X,
00044                     const int incX, const float *Y, const int incY);
00045 double cblas_dsdot(const int N, const float *X, const int incX, const float *Y,
00046                    const int incY);
00047 float  cblas_sdot(const int N, const float  *X, const int incX,
00048                   const float  *Y, const int incY);
00049 double cblas_ddot(const int N, const double *X, const int incX,
00050                   const double *Y, const int incY);
00051 
00052 /*
00053  * Functions having prefixes Z and C only
00054  */
00055 void   cblas_cdotu_sub(const int N, const void *X, const int incX,
00056                        const void *Y, const int incY, void *dotu);
00057 void   cblas_cdotc_sub(const int N, const void *X, const int incX,
00058                        const void *Y, const int incY, void *dotc);
00059 
00060 void   cblas_zdotu_sub(const int N, const void *X, const int incX,
00061                        const void *Y, const int incY, void *dotu);
00062 void   cblas_zdotc_sub(const int N, const void *X, const int incX,
00063                        const void *Y, const int incY, void *dotc);
00064 
00065 
00066 /*
00067  * Functions having prefixes S D SC DZ
00068  */
00069 float  cblas_snrm2(const int N, const float *X, const int incX);
00070 float  cblas_sasum(const int N, const float *X, const int incX);
00071 
00072 double cblas_dnrm2(const int N, const double *X, const int incX);
00073 double cblas_dasum(const int N, const double *X, const int incX);
00074 
00075 float  cblas_scnrm2(const int N, const void *X, const int incX);
00076 float  cblas_scasum(const int N, const void *X, const int incX);
00077 
00078 double cblas_dznrm2(const int N, const void *X, const int incX);
00079 double cblas_dzasum(const int N, const void *X, const int incX);
00080 
00081 
00082 /*
00083  * Functions having standard 4 prefixes (S D C Z)
00084  */
00085 CBLAS_INDEX cblas_isamax(const int N, const float  *X, const int incX);
00086 CBLAS_INDEX cblas_idamax(const int N, const double *X, const int incX);
00087 CBLAS_INDEX cblas_icamax(const int N, const void   *X, const int incX);
00088 CBLAS_INDEX cblas_izamax(const int N, const void   *X, const int incX);
00089 
00090 /*
00091  * ===========================================================================
00092  * Prototypes for level 1 BLAS routines
00093  * ===========================================================================
00094  */
00095 
00096 /* 
00097  * Routines with standard 4 prefixes (s, d, c, z)
00098  */
00099 void cblas_sswap(const int N, float *X, const int incX, 
00100                  float *Y, const int incY);
00101 void cblas_scopy(const int N, const float *X, const int incX, 
00102                  float *Y, const int incY);
00103 void cblas_saxpy(const int N, const float alpha, const float *X,
00104                  const int incX, float *Y, const int incY);
00105 
00106 void cblas_dswap(const int N, double *X, const int incX, 
00107                  double *Y, const int incY);
00108 void cblas_dcopy(const int N, const double *X, const int incX, 
00109                  double *Y, const int incY);
00110 void cblas_daxpy(const int N, const double alpha, const double *X,
00111                  const int incX, double *Y, const int incY);
00112 
00113 void cblas_cswap(const int N, void *X, const int incX, 
00114                  void *Y, const int incY);
00115 void cblas_ccopy(const int N, const void *X, const int incX, 
00116                  void *Y, const int incY);
00117 void cblas_caxpy(const int N, const void *alpha, const void *X,
00118                  const int incX, void *Y, const int incY);
00119 
00120 void cblas_zswap(const int N, void *X, const int incX, 
00121                  void *Y, const int incY);
00122 void cblas_zcopy(const int N, const void *X, const int incX, 
00123                  void *Y, const int incY);
00124 void cblas_zaxpy(const int N, const void *alpha, const void *X,
00125                  const int incX, void *Y, const int incY);
00126 
00127 
00128 /* 
00129  * Routines with S and D prefix only
00130  */
00131 void cblas_srotg(float *a, float *b, float *c, float *s);
00132 void cblas_srotmg(float *d1, float *d2, float *b1, const float b2, float *P);
00133 void cblas_srot(const int N, float *X, const int incX,
00134                 float *Y, const int incY, const float c, const float s);
00135 void cblas_srotm(const int N, float *X, const int incX,
00136                 float *Y, const int incY, const float *P);
00137 
00138 void cblas_drotg(double *a, double *b, double *c, double *s);
00139 void cblas_drotmg(double *d1, double *d2, double *b1, const double b2, double *P);
00140 void cblas_drot(const int N, double *X, const int incX,
00141                 double *Y, const int incY, const double c, const double  s);
00142 void cblas_drotm(const int N, double *X, const int incX,
00143                 double *Y, const int incY, const double *P);
00144 
00145 
00146 /* 
00147  * Routines with S D C Z CS and ZD prefixes
00148  */
00149 void cblas_sscal(const int N, const float alpha, float *X, const int incX);
00150 void cblas_dscal(const int N, const double alpha, double *X, const int incX);
00151 void cblas_cscal(const int N, const void *alpha, void *X, const int incX);
00152 void cblas_zscal(const int N, const void *alpha, void *X, const int incX);
00153 void cblas_csscal(const int N, const float alpha, void *X, const int incX);
00154 void cblas_zdscal(const int N, const double alpha, void *X, const int incX);
00155 
00156 /*
00157  * ===========================================================================
00158  * Prototypes for level 2 BLAS
00159  * ===========================================================================
00160  */
00161 
00162 /* 
00163  * Routines with standard 4 prefixes (S, D, C, Z)
00164  */
00165 void cblas_sgemv(const enum CBLAS_ORDER order,
00166                  const enum CBLAS_TRANSPOSE TransA, const int M, const int N,
00167                  const float alpha, const float *A, const int lda,
00168                  const float *X, const int incX, const float beta,
00169                  float *Y, const int incY);
00170 void cblas_sgbmv(const enum CBLAS_ORDER order,
00171                  const enum CBLAS_TRANSPOSE TransA, const int M, const int N,
00172                  const int KL, const int KU, const float alpha,
00173                  const float *A, const int lda, const float *X,
00174                  const int incX, const float beta, float *Y, const int incY);
00175 void cblas_strmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00176                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00177                  const int N, const float *A, const int lda, 
00178                  float *X, const int incX);
00179 void cblas_stbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00180                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00181                  const int N, const int K, const float *A, const int lda, 
00182                  float *X, const int incX);
00183 void cblas_stpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00184                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00185                  const int N, const float *Ap, float *X, const int incX);
00186 void cblas_strsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00187                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00188                  const int N, const float *A, const int lda, float *X,
00189                  const int incX);
00190 void cblas_stbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00191                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00192                  const int N, const int K, const float *A, const int lda,
00193                  float *X, const int incX);
00194 void cblas_stpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00195                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00196                  const int N, const float *Ap, float *X, const int incX);
00197 
00198 void cblas_dgemv(const enum CBLAS_ORDER order,
00199                  const enum CBLAS_TRANSPOSE TransA, const int M, const int N,
00200                  const double alpha, const double *A, const int lda,
00201                  const double *X, const int incX, const double beta,
00202                  double *Y, const int incY);
00203 void cblas_dgbmv(const enum CBLAS_ORDER order,
00204                  const enum CBLAS_TRANSPOSE TransA, const int M, const int N,
00205                  const int KL, const int KU, const double alpha,
00206                  const double *A, const int lda, const double *X,
00207                  const int incX, const double beta, double *Y, const int incY);
00208 void cblas_dtrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00209                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00210                  const int N, const double *A, const int lda, 
00211                  double *X, const int incX);
00212 void cblas_dtbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00213                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00214                  const int N, const int K, const double *A, const int lda, 
00215                  double *X, const int incX);
00216 void cblas_dtpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00217                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00218                  const int N, const double *Ap, double *X, const int incX);
00219 void cblas_dtrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00220                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00221                  const int N, const double *A, const int lda, double *X,
00222                  const int incX);
00223 void cblas_dtbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00224                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00225                  const int N, const int K, const double *A, const int lda,
00226                  double *X, const int incX);
00227 void cblas_dtpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00228                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00229                  const int N, const double *Ap, double *X, const int incX);
00230 
00231 void cblas_cgemv(const enum CBLAS_ORDER order,
00232                  const enum CBLAS_TRANSPOSE TransA, const int M, const int N,
00233                  const void *alpha, const void *A, const int lda,
00234                  const void *X, const int incX, const void *beta,
00235                  void *Y, const int incY);
00236 void cblas_cgbmv(const enum CBLAS_ORDER order,
00237                  const enum CBLAS_TRANSPOSE TransA, const int M, const int N,
00238                  const int KL, const int KU, const void *alpha,
00239                  const void *A, const int lda, const void *X,
00240                  const int incX, const void *beta, void *Y, const int incY);
00241 void cblas_ctrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00242                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00243                  const int N, const void *A, const int lda, 
00244                  void *X, const int incX);
00245 void cblas_ctbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00246                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00247                  const int N, const int K, const void *A, const int lda, 
00248                  void *X, const int incX);
00249 void cblas_ctpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00250                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00251                  const int N, const void *Ap, void *X, const int incX);
00252 void cblas_ctrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00253                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00254                  const int N, const void *A, const int lda, void *X,
00255                  const int incX);
00256 void cblas_ctbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00257                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00258                  const int N, const int K, const void *A, const int lda,
00259                  void *X, const int incX);
00260 void cblas_ctpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00261                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00262                  const int N, const void *Ap, void *X, const int incX);
00263 
00264 void cblas_zgemv(const enum CBLAS_ORDER order,
00265                  const enum CBLAS_TRANSPOSE TransA, const int M, const int N,
00266                  const void *alpha, const void *A, const int lda,
00267                  const void *X, const int incX, const void *beta,
00268                  void *Y, const int incY);
00269 void cblas_zgbmv(const enum CBLAS_ORDER order,
00270                  const enum CBLAS_TRANSPOSE TransA, const int M, const int N,
00271                  const int KL, const int KU, const void *alpha,
00272                  const void *A, const int lda, const void *X,
00273                  const int incX, const void *beta, void *Y, const int incY);
00274 void cblas_ztrmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00275                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00276                  const int N, const void *A, const int lda, 
00277                  void *X, const int incX);
00278 void cblas_ztbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00279                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00280                  const int N, const int K, const void *A, const int lda, 
00281                  void *X, const int incX);
00282 void cblas_ztpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00283                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00284                  const int N, const void *Ap, void *X, const int incX);
00285 void cblas_ztrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00286                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00287                  const int N, const void *A, const int lda, void *X,
00288                  const int incX);
00289 void cblas_ztbsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00290                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00291                  const int N, const int K, const void *A, const int lda,
00292                  void *X, const int incX);
00293 void cblas_ztpsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00294                  const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag,
00295                  const int N, const void *Ap, void *X, const int incX);
00296 
00297 
00298 /* 
00299  * Routines with S and D prefixes only
00300  */
00301 void cblas_ssymv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00302                  const int N, const float alpha, const float *A,
00303                  const int lda, const float *X, const int incX,
00304                  const float beta, float *Y, const int incY);
00305 void cblas_ssbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00306                  const int N, const int K, const float alpha, const float *A,
00307                  const int lda, const float *X, const int incX,
00308                  const float beta, float *Y, const int incY);
00309 void cblas_sspmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00310                  const int N, const float alpha, const float *Ap,
00311                  const float *X, const int incX,
00312                  const float beta, float *Y, const int incY);
00313 void cblas_sger(const enum CBLAS_ORDER order, const int M, const int N,
00314                 const float alpha, const float *X, const int incX,
00315                 const float *Y, const int incY, float *A, const int lda);
00316 void cblas_ssyr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00317                 const int N, const float alpha, const float *X,
00318                 const int incX, float *A, const int lda);
00319 void cblas_sspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00320                 const int N, const float alpha, const float *X,
00321                 const int incX, float *Ap);
00322 void cblas_ssyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00323                 const int N, const float alpha, const float *X,
00324                 const int incX, const float *Y, const int incY, float *A,
00325                 const int lda);
00326 void cblas_sspr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00327                 const int N, const float alpha, const float *X,
00328                 const int incX, const float *Y, const int incY, float *A);
00329 
00330 void cblas_dsymv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00331                  const int N, const double alpha, const double *A,
00332                  const int lda, const double *X, const int incX,
00333                  const double beta, double *Y, const int incY);
00334 void cblas_dsbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00335                  const int N, const int K, const double alpha, const double *A,
00336                  const int lda, const double *X, const int incX,
00337                  const double beta, double *Y, const int incY);
00338 void cblas_dspmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00339                  const int N, const double alpha, const double *Ap,
00340                  const double *X, const int incX,
00341                  const double beta, double *Y, const int incY);
00342 void cblas_dger(const enum CBLAS_ORDER order, const int M, const int N,
00343                 const double alpha, const double *X, const int incX,
00344                 const double *Y, const int incY, double *A, const int lda);
00345 void cblas_dsyr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00346                 const int N, const double alpha, const double *X,
00347                 const int incX, double *A, const int lda);
00348 void cblas_dspr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00349                 const int N, const double alpha, const double *X,
00350                 const int incX, double *Ap);
00351 void cblas_dsyr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00352                 const int N, const double alpha, const double *X,
00353                 const int incX, const double *Y, const int incY, double *A,
00354                 const int lda);
00355 void cblas_dspr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00356                 const int N, const double alpha, const double *X,
00357                 const int incX, const double *Y, const int incY, double *A);
00358 
00359 
00360 /* 
00361  * Routines with C and Z prefixes only
00362  */
00363 void cblas_chemv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00364                  const int N, const void *alpha, const void *A,
00365                  const int lda, const void *X, const int incX,
00366                  const void *beta, void *Y, const int incY);
00367 void cblas_chbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00368                  const int N, const int K, const void *alpha, const void *A,
00369                  const int lda, const void *X, const int incX,
00370                  const void *beta, void *Y, const int incY);
00371 void cblas_chpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00372                  const int N, const void *alpha, const void *Ap,
00373                  const void *X, const int incX,
00374                  const void *beta, void *Y, const int incY);
00375 void cblas_cgeru(const enum CBLAS_ORDER order, const int M, const int N,
00376                  const void *alpha, const void *X, const int incX,
00377                  const void *Y, const int incY, void *A, const int lda);
00378 void cblas_cgerc(const enum CBLAS_ORDER order, const int M, const int N,
00379                  const void *alpha, const void *X, const int incX,
00380                  const void *Y, const int incY, void *A, const int lda);
00381 void cblas_cher(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00382                 const int N, const float alpha, const void *X, const int incX,
00383                 void *A, const int lda);
00384 void cblas_chpr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00385                 const int N, const float alpha, const void *X,
00386                 const int incX, void *A);
00387 void cblas_cher2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,
00388                 const void *alpha, const void *X, const int incX,
00389                 const void *Y, const int incY, void *A, const int lda);
00390 void cblas_chpr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,
00391                 const void *alpha, const void *X, const int incX,
00392                 const void *Y, const int incY, void *Ap);
00393 
00394 void cblas_zhemv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00395                  const int N, const void *alpha, const void *A,
00396                  const int lda, const void *X, const int incX,
00397                  const void *beta, void *Y, const int incY);
00398 void cblas_zhbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00399                  const int N, const int K, const void *alpha, const void *A,
00400                  const int lda, const void *X, const int incX,
00401                  const void *beta, void *Y, const int incY);
00402 void cblas_zhpmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00403                  const int N, const void *alpha, const void *Ap,
00404                  const void *X, const int incX,
00405                  const void *beta, void *Y, const int incY);
00406 void cblas_zgeru(const enum CBLAS_ORDER order, const int M, const int N,
00407                  const void *alpha, const void *X, const int incX,
00408                  const void *Y, const int incY, void *A, const int lda);
00409 void cblas_zgerc(const enum CBLAS_ORDER order, const int M, const int N,
00410                  const void *alpha, const void *X, const int incX,
00411                  const void *Y, const int incY, void *A, const int lda);
00412 void cblas_zher(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00413                 const int N, const double alpha, const void *X, const int incX,
00414                 void *A, const int lda);
00415 void cblas_zhpr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00416                 const int N, const double alpha, const void *X,
00417                 const int incX, void *A);
00418 void cblas_zher2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,
00419                 const void *alpha, const void *X, const int incX,
00420                 const void *Y, const int incY, void *A, const int lda);
00421 void cblas_zhpr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const int N,
00422                 const void *alpha, const void *X, const int incX,
00423                 const void *Y, const int incY, void *Ap);
00424 
00425 /*
00426  * ===========================================================================
00427  * Prototypes for level 3 BLAS
00428  * ===========================================================================
00429  */
00430 
00431 /* 
00432  * Routines with standard 4 prefixes (S, D, C, Z)
00433  */
00434 void cblas_sgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
00435                  const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
00436                  const int K, const float alpha, const float *A,
00437                  const int lda, const float *B, const int ldb,
00438                  const float beta, float *C, const int ldc);
00439 void cblas_ssymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00440                  const enum CBLAS_UPLO Uplo, const int M, const int N,
00441                  const float alpha, const float *A, const int lda,
00442                  const float *B, const int ldb, const float beta,
00443                  float *C, const int ldc);
00444 void cblas_ssyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00445                  const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00446                  const float alpha, const float *A, const int lda,
00447                  const float beta, float *C, const int ldc);
00448 void cblas_ssyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00449                   const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00450                   const float alpha, const float *A, const int lda,
00451                   const float *B, const int ldb, const float beta,
00452                   float *C, const int ldc);
00453 void cblas_strmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00454                  const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,
00455                  const enum CBLAS_DIAG Diag, const int M, const int N,
00456                  const float alpha, const float *A, const int lda,
00457                  float *B, const int ldb);
00458 void cblas_strsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00459                  const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,
00460                  const enum CBLAS_DIAG Diag, const int M, const int N,
00461                  const float alpha, const float *A, const int lda,
00462                  float *B, const int ldb);
00463 
00464 void cblas_dgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
00465                  const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
00466                  const int K, const double alpha, const double *A,
00467                  const int lda, const double *B, const int ldb,
00468                  const double beta, double *C, const int ldc);
00469 void cblas_dsymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00470                  const enum CBLAS_UPLO Uplo, const int M, const int N,
00471                  const double alpha, const double *A, const int lda,
00472                  const double *B, const int ldb, const double beta,
00473                  double *C, const int ldc);
00474 void cblas_dsyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00475                  const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00476                  const double alpha, const double *A, const int lda,
00477                  const double beta, double *C, const int ldc);
00478 void cblas_dsyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00479                   const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00480                   const double alpha, const double *A, const int lda,
00481                   const double *B, const int ldb, const double beta,
00482                   double *C, const int ldc);
00483 void cblas_dtrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00484                  const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,
00485                  const enum CBLAS_DIAG Diag, const int M, const int N,
00486                  const double alpha, const double *A, const int lda,
00487                  double *B, const int ldb);
00488 void cblas_dtrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00489                  const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,
00490                  const enum CBLAS_DIAG Diag, const int M, const int N,
00491                  const double alpha, const double *A, const int lda,
00492                  double *B, const int ldb);
00493 
00494 void cblas_cgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
00495                  const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
00496                  const int K, const void *alpha, const void *A,
00497                  const int lda, const void *B, const int ldb,
00498                  const void *beta, void *C, const int ldc);
00499 void cblas_csymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00500                  const enum CBLAS_UPLO Uplo, const int M, const int N,
00501                  const void *alpha, const void *A, const int lda,
00502                  const void *B, const int ldb, const void *beta,
00503                  void *C, const int ldc);
00504 void cblas_csyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00505                  const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00506                  const void *alpha, const void *A, const int lda,
00507                  const void *beta, void *C, const int ldc);
00508 void cblas_csyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00509                   const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00510                   const void *alpha, const void *A, const int lda,
00511                   const void *B, const int ldb, const void *beta,
00512                   void *C, const int ldc);
00513 void cblas_ctrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00514                  const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,
00515                  const enum CBLAS_DIAG Diag, const int M, const int N,
00516                  const void *alpha, const void *A, const int lda,
00517                  void *B, const int ldb);
00518 void cblas_ctrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00519                  const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,
00520                  const enum CBLAS_DIAG Diag, const int M, const int N,
00521                  const void *alpha, const void *A, const int lda,
00522                  void *B, const int ldb);
00523 
00524 void cblas_zgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
00525                  const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
00526                  const int K, const void *alpha, const void *A,
00527                  const int lda, const void *B, const int ldb,
00528                  const void *beta, void *C, const int ldc);
00529 void cblas_zsymm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00530                  const enum CBLAS_UPLO Uplo, const int M, const int N,
00531                  const void *alpha, const void *A, const int lda,
00532                  const void *B, const int ldb, const void *beta,
00533                  void *C, const int ldc);
00534 void cblas_zsyrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00535                  const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00536                  const void *alpha, const void *A, const int lda,
00537                  const void *beta, void *C, const int ldc);
00538 void cblas_zsyr2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00539                   const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00540                   const void *alpha, const void *A, const int lda,
00541                   const void *B, const int ldb, const void *beta,
00542                   void *C, const int ldc);
00543 void cblas_ztrmm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00544                  const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,
00545                  const enum CBLAS_DIAG Diag, const int M, const int N,
00546                  const void *alpha, const void *A, const int lda,
00547                  void *B, const int ldb);
00548 void cblas_ztrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00549                  const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA,
00550                  const enum CBLAS_DIAG Diag, const int M, const int N,
00551                  const void *alpha, const void *A, const int lda,
00552                  void *B, const int ldb);
00553 
00554 
00555 /* 
00556  * Routines with prefixes C and Z only
00557  */
00558 void cblas_chemm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00559                  const enum CBLAS_UPLO Uplo, const int M, const int N,
00560                  const void *alpha, const void *A, const int lda,
00561                  const void *B, const int ldb, const void *beta,
00562                  void *C, const int ldc);
00563 void cblas_cherk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00564                  const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00565                  const float alpha, const void *A, const int lda,
00566                  const float beta, void *C, const int ldc);
00567 void cblas_cher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00568                   const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00569                   const void *alpha, const void *A, const int lda,
00570                   const void *B, const int ldb, const float beta,
00571                   void *C, const int ldc);
00572 
00573 void cblas_zhemm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side,
00574                  const enum CBLAS_UPLO Uplo, const int M, const int N,
00575                  const void *alpha, const void *A, const int lda,
00576                  const void *B, const int ldb, const void *beta,
00577                  void *C, const int ldc);
00578 void cblas_zherk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00579                  const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00580                  const double alpha, const void *A, const int lda,
00581                  const double beta, void *C, const int ldc);
00582 void cblas_zher2k(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
00583                   const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
00584                   const void *alpha, const void *A, const int lda,
00585                   const void *B, const int ldb, const double beta,
00586                   void *C, const int ldc);
00587 
00588 void cblas_xerbla(int p, const char *rout, const char *form, ...);
00589 
00590 __END_DECLS
00591 
00592 class CBLAS
00593 {
00594         public:
00595                 template <class T>
00596                 static void scal(int N, T alpha, T* X, int incX);
00597 
00598                 template <class T>
00599                 static void copy(int N, const T* X, int incX, T* Y, int incY);
00600 
00601                 template <class T>
00602                 static void axpy(int N, T alpha, const T* X, int incX, T* Y, int incY);
00603 
00604                 template <class T>
00605                 static T dot(int N, const T* X, int incX, const T* Y, int incY);
00606 
00607                 template <class T>
00608                 static T nrm2(int N, const T* X, int incX);             
00609 
00610                 template <class T>
00611                 static void ger(enum CBLAS_ORDER order, int M, int N, T alpha, const T* X, int incX, const T* Y, int incY, T* A, int lda);
00612 
00613                 template <class T>
00614                 static void gemv(enum CBLAS_ORDER order, CBLAS_TRANSPOSE transA, int M, int N, T alpha, const T* A, int lda, const T* X, int incX, T beta, T* Y, int incY);
00615 
00616                 template <class T>
00617                 static void gemm(enum CBLAS_ORDER order, CBLAS_TRANSPOSE transA, CBLAS_TRANSPOSE transB, int M, int N, int K, T alpha, const T* A, int lda, const T* B, int ldb, T beta, T* C, int ldc);
00618 };
00619 
00620 /*
00621 template <class T>
00622 void CBLAS::scal(int N, T alpha, T* X, int incX)
00623 {
00624         #ifndef _DISABLE_SLOW_CBLAS_WARNING_
00625         std::cout << "CBLAS::scal() warning- using slow version!" << std::endl;
00626         #endif
00627 
00628         // if increment is 1, use simple version
00629         if (incX == 1)
00630                 for (int i=0; i< N; i++)
00631                         X[i] *= alpha;
00632         else
00633         {
00634                 int ix = 1;
00635                 if (incX < 0)
00636                         ix = (-N+1)*incX + 1;
00637                 for (int i=0; i< N; i++, ix += incX)
00638                         X[ix] *= alpha;
00639         }
00640 }
00641 
00642 template <class T>
00643 void CBLAS::copy(int N, const T* X, int incX, T* Y, int incY)
00644 {
00645         // if both increments are 1, use memcpy
00646         if (incX == 1 && incY == 1)
00647                 memcpy(Y, X, sizeof(T) * N);
00648         else
00649         {
00650                 int ix = 1, iy = 1;
00651                 if (incX < 0)
00652                         ix = (-N+1)*incX + 1;
00653                 if (incY < 0)
00654                         iy = (-N+1)*incY + 1;
00655                 for (int i=0; i< N; i++, ix+= incX, iy += incY)
00656                         Y[iy] = X[ix];
00657         }
00658 }
00659 
00660 template <class T>
00661 void CBLAS::axpy(int N, T alpha, const T* X, int incX, T* Y, int incY)
00662 {
00663         #ifndef _DISABLE_SLOW_CBLAS_WARNING_
00664         std::cout << "CBLAS::axpy() warning- using slow version!" << std::endl;
00665         #endif
00666 
00667         // if increments are both 1, use simple version
00668         if (incX == 1 && incY == 1)
00669                 for (int i=0; i< N; i++)
00670                         Y[i] += X[i] * alpha;
00671         else
00672         {
00673                 int ix = 1, iy = 1;
00674                 if (incX < 0)
00675                         ix = (-N+1)*incX + 1;
00676                 if (incY < 0)
00677                         iy = (-N+1)*incY + 1;
00678                 for (int i=0; i< N; i++, ix+= incX, iy += incY)
00679                         Y[iy] += X[ix] * alpha;
00680         }
00681 }
00682 
00683 template <class T>
00684 T CBLAS::dot(int N, const T* X, int incX, const T* Y, int incY)
00685 {
00686         #ifndef _DISABLE_SLOW_CBLAS_WARNING_
00687         std::cout << "CBLAS::dot() warning- using slow version!" << std::endl;
00688         #endif
00689 
00690         T inner_prod = 0;
00691 
00692         // if increments are both 1, use simple version
00693         if (incX == 1 && incY == 1)
00694                 for (int i=0; i< N; i++)
00695                         inner_prod += X[i] * Y[i];
00696         else
00697         {
00698                 int ix = 1, iy = 1;
00699                 if (incX < 0)
00700                         ix = (-N+1)*incX + 1;
00701                 if (incY < 0)
00702                         iy = (-N+1)*incY + 1;
00703                 for (int i=0; i< N; i++, ix+= incX, iy += incY)
00704                         inner_prod += X[ix] * Y[iy];
00705         }
00706 
00707         return inner_prod;
00708 }
00709 
00710 template <class T>
00711 T CBLAS::nrm2(int N, const T* X, int incX)
00712 {
00713         #ifndef _DISABLE_SLOW_CBLAS_WARNING_
00714         std::cout << "CBLAS::nrm2() warning- using slow version!" << std::endl;
00715         #endif
00716 
00717         T norm = 0;
00718 
00719         // if increment is 1, use simple version
00720         if (incX == 1)
00721                 for (int i=0; i< N; i++)
00722                         norm += X[i] * X[i];
00723         else
00724         {
00725                 int ix = 1;
00726                 if (incX < 0)
00727                         ix = (-N+1)*incX + 1;
00728                 for (int i=0; i< N; i++, ix += incX)
00729                         norm += X[ix] * X[ix];
00730         }
00731 
00732         return std::sqrt(norm);
00733 }
00734 
00735 template <class T>
00736 void CBLAS::ger(enum CBLAS_ORDER order, int M, int N, T alpha, const T* X, int incX, const T* Y, int incY, T* A, int lda)
00737 {
00738         #ifndef _DISABLE_SLOW_CBLAS_WARNING_
00739         std::cout << "CBLAS::ger() warning- using slow version!" << std::endl;
00740         #endif
00741 
00742         // if incX and incY are both 1, use simpler version
00743         if (incX == 1 && incY == 1)
00744         {
00745                 for (int i=0; i< M; i++)
00746                         for (int j=0; j< N; j++)
00747                         {
00748                                 if (order == CblasRowMajor)
00749                                         A[i*N+j] = X[i] * Y[j];
00750                                 else
00751                                         A[j*M+i] = X[i] * Y[j];
00752                         }
00753         }
00754         else
00755         {
00756                 int ix = 1;
00757                 if (incX < 0)
00758                         ix = (-M+1)*incX + 1;
00759                 for (int i=0; i< M; i++, ix+= incX)
00760                 {
00761                         int iy = 1;
00762                         if (incY < 0)
00763                                 iy = (-N+1)*incY + 1;
00764                         for (int j=0; j< N; j++, iy += incY)
00765                         {
00766                                 if (order == CblasRowMajor)
00767                                         A[i*N+j] = X[ix] * Y[iy];
00768                                 else
00769                                         A[j*M+i] = X[ix] * Y[iy];
00770                         }
00771                 }
00772         }
00773 }
00774 
00775 template <class T>
00776 void CBLAS::gemv(enum CBLAS_ORDER order, CBLAS_TRANSPOSE transA, int M, int N, T alpha, const T* A, int lda, const T* X, int incX, T beta, T* Y, int incY)
00777 {
00778         #ifndef _DISABLE_SLOW_CBLAS_WARNING_
00779         std::cout << "CBLAS::gemv() warning- using slow version!" << std::endl;
00780         #endif
00781 
00782         bool trans = ((order == CblasColMajor && transA == CblasTrans) ||
00783                                                                 (order == CblasRowMajor && transA == CblasNoTrans));
00784 
00785         int iy = 1;
00786         if (incY < 0)
00787                 iy = (-N+1)*incY + 1;
00788         for (int i=0; i< lda; i++, iy+= incY)
00789         {
00790                 if (!trans)
00791                                 Y[iy] = beta*Y[iy] + alpha * dot(N, A+i, lda, X, incX);
00792                 else
00793                                 Y[iy] = beta*Y[iy] + alpha * dot(N, A+lda*i, 1, X, incX);
00794         }
00795 }
00796 
00797 template <class T>
00798 void CBLAS::gemm(enum CBLAS_ORDER order, CBLAS_TRANSPOSE transA, CBLAS_TRANSPOSE transB, int M, int N, int K, T alpha, const T* A, int lda, const T* B, int ldb, T beta, T* C, int ldc)
00799 {
00800         #ifndef _DISABLE_SLOW_CBLAS_WARNING_
00801         std::cout << "CBLAS::gemm() warning- using slow version!" << std::endl;
00802         #endif
00803 
00804         std::cerr << "CBLAS::gemm() error- not yet implemented!" << std::endl;
00805 }
00806 */
00807 
00808 #endif /* __GSL_CBLAS_H__ */
00809 

Generated on Wed Oct 24 14:54:22 2007 for Physsim by  doxygen 1.5.1