wrapper.h
00001 /* Copyright (C) 2007  Martin Förg, Jan Clauberg
00002 
00003  * This library is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU Lesser General Public
00005  * License as published by the Free Software Foundation; either
00006  * version 2.1 of the License, or (at your option) any later version.
00007  * 
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Lesser General Public License for more details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public
00014  * License along with this library; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00016  *
00017  * Contact:
00018  *   martin.o.foerg@googlemail.com
00019  *
00020  */
00021 
00022 #ifndef wrapper_h
00023 #define wrapper_h
00024 
00025 #ifndef HAVE_LIBMKL_INTEL_LP64
00026 #ifndef CBLAS_ENUM_DEFINED_H
00027    #define CBLAS_ENUM_DEFINED_H
00028    enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102 };
00029    enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113,
00030                          AtlasConj=114};
00031    enum CBLAS_UPLO  {CblasUpper=121, CblasLower=122};
00032    enum CBLAS_DIAG  {CblasNonUnit=131, CblasUnit=132};
00033    enum CBLAS_SIDE  {CblasLeft=141, CblasRight=142};
00034 #endif
00035 #define CBLAS_INDEX int
00036 
00037 #ifndef ATLAS_ENUM_H
00038    #define ATLAS_ENUM_H
00039    #define ATLAS_ORDER CBLAS_ORDER
00040       #define AtlasRowMajor CblasRowMajor
00041       #define AtlasColMajor CblasColMajor
00042    #define ATLAS_TRANS CBLAS_TRANSPOSE
00043       #define AtlasNoTrans CblasNoTrans
00044       #define AtlasTrans CblasTrans
00045       #define AtlasConjTrans CblasConjTrans
00046    #define ATLAS_UPLO CBLAS_UPLO
00047       #define AtlasUpper CblasUpper
00048       #define AtlasLower CblasLower
00049    #define ATLAS_DIAG CBLAS_DIAG
00050       #define AtlasNonUnit CblasNonUnit
00051       #define AtlasUnit CblasUnit
00052    #define ATLAS_SIDE CBLAS_SIDE
00053       #define AtlasLeft  CblasLeft
00054       #define AtlasRight CblasRight
00055 #endif
00056 #else
00057 #include "mkl_cblas.h"
00058 #endif
00059 
00060 #if defined(HAVE_LIBBLAS)
00061 namespace fmatvec {
00062   void dscal(const int N, const double alpha, double *X, const int incX) ;
00063   void dgemm(const CBLAS_ORDER Order, const CBLAS_TRANSPOSE TransA,
00064                  const CBLAS_TRANSPOSE TransB, const int M, const int N,
00065                  const int K, const double alpha, const double *A,
00066                  const int lda, const double *B, const int ldb,
00067                  const double beta, double *C, const int ldc);
00068   void dsymm(const CBLAS_ORDER Order, const CBLAS_SIDE Side,
00069                  const CBLAS_UPLO Uplo, const int M, const int N,
00070                  const double alpha, const double *A, const int lda,
00071                  const double *B, const int ldb, const double beta,
00072                  double *C, const int ldc);
00073   void daxpy(const int N, const double alpha, const double *X,
00074                  const int incX, double *Y, const int incY);
00075   void dcopy(const int N, const double *X, const int incX,
00076                  double *Y, const int incY);
00077   void dgemv(const CBLAS_ORDER Order,
00078                  const CBLAS_TRANSPOSE TransA, const int M, const int N,
00079                  const double alpha, const double *A, const int lda,
00080                  const double *X, const int incX, const double beta,
00081                  double *Y, const int incY);
00082   void dsymv(const CBLAS_ORDER Order, const CBLAS_UPLO Uplo,
00083                  const int N, const double alpha, const double *A,
00084                  const int lda, const double *X, const int incX,
00085                  const double beta, double *Y, const int incY);
00086   double ddot(const int N, const double *X, const int incX,
00087                   const double *Y, const int incY);
00088   double dasum(const int N, const double *X, const int incX);
00089   CBLAS_INDEX idamax(const int N, const double *X, const int incX);
00090   double dnrm2(const int N, const double *X, const int incX);
00091   int dgesv(const CBLAS_ORDER Order, const int N, const int NRHS,
00092                   double *A, const int lda, int *ipiv,
00093                   double *B, const int ldb);
00094   int dgetrs(const CBLAS_ORDER Order, const CBLAS_TRANSPOSE Trans,
00095     const int N, const int NRHS, const double *A, const int lda,
00096     const int *ipiv, double *B, const int ldb);
00097   int dgetrf(const CBLAS_ORDER Order, const int M, const int N,
00098                    double *A, const int lda, int *ipiv);
00099   int dgetri(const CBLAS_ORDER Order, const int N, double *A,
00100                    const int lda, const int *ipiv);
00101   int dpotrf(const ATLAS_ORDER Order, const ATLAS_UPLO Uplo, const int N, double *A, const int lda);
00102   int dpotri(const ATLAS_ORDER Order, const ATLAS_UPLO Uplo,
00103                    const int N, double *A, const int lda);
00104   int dposv(const ATLAS_ORDER Order, const ATLAS_UPLO Uplo,
00105                   const int N, const int NRHS, double *A, const int lda,
00106                   double *B, const int ldb);
00107   int dpotrs(const CBLAS_ORDER Order, const CBLAS_UPLO Uplo,
00108                    const int N, const int NRHS, const double *A, const int lda,
00109                    double *B, const int ldb);
00110 }
00111 #endif
00112 
00113 #if defined(HAVE_LIBATLAS)
00114 namespace fmatvec {
00115 
00116 extern "C" {
00117 #include "cblas.h"
00118 #include "clapack.h"
00119 }
00120 
00121 #define dscal  cblas_dscal
00122 #define dcopy  cblas_dcopy
00123 #define ddot   cblas_ddot
00124 #define dnrm2  cblas_dnrm2
00125 #define dasum  cblas_dasum
00126 #define idamax cblas_idamax
00127 #define daxpy  cblas_daxpy
00128 #define dgemv  cblas_dgemv
00129 #define dsymv  cblas_dsymv
00130 #define dgemm  cblas_dgemm
00131 #define dsymm  cblas_dsymm
00132 
00133 #define dgesv  clapack_dgesv
00134 #define dgetrs clapack_dgetrs
00135 #define dgetrf clapack_dgetrf
00136 #define dgetri clapack_dgetri
00137 #define dpotrf clapack_dpotrf
00138 #define dpotri clapack_dpotri
00139 #define dpotrs clapack_dpotrs
00140 #define dposv  clapack_dposv
00141 
00142 }
00143 #endif
00144 
00145 #if defined(HAVE_LIBMKL_INTEL_LP64)
00146 extern "C" {
00147 #include "mkl_cblas.h"
00148 #include "mkl_lapacke.h"
00149 #include "mkl_lapack.h"  
00150 }
00151 
00152 #define dscal  cblas_dscal
00153 #define dcopy  cblas_dcopy
00154 #define ddot   cblas_ddot
00155 #define dnrm2  cblas_dnrm2
00156 #define dasum  cblas_dasum
00157 #define idamax cblas_idamax
00158 #define daxpy  cblas_daxpy
00159 #define dgemv  cblas_dgemv
00160 #define dsymv  cblas_dsymv
00161 #define dgemm  cblas_dgemm
00162 #define dsymm  cblas_dsymm
00163 
00164 #define dgesv  LAPACKE_dgesv
00165 #define dgetrs LAPACKE_dgetrs
00166 #define dgetrf LAPACKE_dgetrf
00167 #define dgetri LAPACKE_dgetri
00168 #define dpotrf LAPACKE_dpotrf
00169 #define dpotri LAPACKE_dpotri
00170 #define dpotrs LAPACKE_dpotrs
00171 #define dposv  LAPACKE_dposv
00172 
00173 #endif
00174 
00175 namespace fmatvec {
00176 
00177 #ifndef HAVE_LIBMKL_INTEL_LP64
00178   int dsyevx(const char jobz, const char range, const CBLAS_UPLO cuplo, const int n, double *a, const int lda, const double vl, const double vu, const int il, const int iu, const double abstol, const int *m, double *w, double *z, const int ldz);
00179 #else
00180    int dsyevx(const char jobz, const char range, const CBLAS_UPLO cuplo, const int n, double *a, const int lda, const double vl, const double vu, const int il, const int iu, const double abstol, int *m, double *w, double *z, const int ldz); 
00181 #endif
00182 
00183   int dgels( const CBLAS_TRANSPOSE ctr, const int m, const int n, const int nhrs, double* a, const int lda, double* b, const int ldb);
00184 
00185   int dgelss(const int m, const int n, const int nrhs, double *a, const int lda, double *b, const int ldb, const double rcond);
00186 
00187   int dgeev(const char jobvl, const char jobvr, const int n, double *a, const int lda, double *wr, double *wi, double *vl, const int ldvl, double *vr, const int ldvr);
00188 
00189   int dsygv(const int itype, const char jobz, const char uplo, const int n, double *a, const int lda, double *b, const int ldb, double *w);
00190   
00191   int dgesvd(const char jobu, const char jobvt, const int m, const int n, double *a, const int lda, double *s, double *u, const int ldu, double *vt, const int ldvt);
00192 
00193   int dsyev(const char jobz, const char ul, const int n, double *a, const int lda, double *w);
00194 
00195   double dlange(const char norm , const int m, const int n, const double* a, const int lda);
00196 }
00197 #endif