Amesos Package Browser (Single Doxygen Collection) Development
amesos_cholmod_blas.h
Go to the documentation of this file.
00001 /* ========================================================================== */
00002 /* === Include/cholmod_blas.h =============================================== */
00003 /* ========================================================================== */
00004 
00005 /* -----------------------------------------------------------------------------
00006  * CHOLMOD/Include/cholmod_blas.h.
00007  * Copyright (C) 2005-2006, Univ. of Florida.  Author: Timothy A. Davis
00008  * CHOLMOD/Include/cholmod_blas.h is licensed under Version 2.1 of the GNU
00009  * Lesser General Public License.  See lesser.txt for a text of the license.
00010  * CHOLMOD is also available under other licenses; contact authors for details.
00011  * http://www.cise.ufl.edu/research/sparse
00012  * -------------------------------------------------------------------------- */
00013 
00014 /* This does not need to be included in the user's program. */
00015 
00016 #ifndef AMESOS_CHOLMOD_BLAS_H
00017 #define AMESOS_CHOLMOD_BLAS_H
00018 
00019 /* ========================================================================== */
00020 /* === Architecture ========================================================= */
00021 /* ========================================================================== */
00022 
00023 #if defined (__sun) || defined (MSOL2) || defined (ARCH_SOL2)
00024 #define CHOLMOD_SOL2
00025 #define CHOLMOD_ARCHITECTURE "Sun Solaris"
00026 
00027 #elif defined (__sgi) || defined (MSGI) || defined (ARCH_SGI)
00028 #define CHOLMOD_SGI
00029 #define CHOLMOD_ARCHITECTURE "SGI Irix"
00030 
00031 #elif defined (__linux) || defined (MGLNX86) || defined (ARCH_GLNX86)
00032 #define CHOLMOD_LINUX
00033 #define CHOLMOD_ARCHITECTURE "Linux"
00034 
00035 #elif defined (_AIX) || defined (MIBM_RS) || defined (ARCH_IBM_RS)
00036 #define CHOLMOD_AIX
00037 #define CHOLMOD_ARCHITECTURE "IBM AIX"
00038 #define BLAS_NO_UNDERSCORE
00039 
00040 #elif defined (__alpha) || defined (MALPHA) || defined (ARCH_ALPHA)
00041 #define CHOLMOD_ALPHA
00042 #define CHOLMOD_ARCHITECTURE "Compaq Alpha"
00043 
00044 #elif defined (_WIN32) || defined (WIN32) || defined (_WIN64) || defined (WIN64)
00045 #if defined (__MINGW32__) || defined (__MINGW32__)
00046 #define CHOLMOD_MINGW
00047 #elif defined (__CYGWIN32__) || defined (__CYGWIN32__)
00048 #define CHOLMOD_CYGWIN
00049 #else
00050 #define CHOLMOD_WINDOWS
00051 #define BLAS_NO_UNDERSCORE
00052 #endif
00053 #define CHOLMOD_ARCHITECTURE "Microsoft Windows"
00054 
00055 #elif defined (__hppa) || defined (__hpux) || defined (MHPUX) || defined (ARCH_HPUX)
00056 #define CHOLMOD_HP
00057 #define CHOLMOD_ARCHITECTURE "HP Unix"
00058 #define BLAS_NO_UNDERSCORE
00059 
00060 #elif defined (__hp700) || defined (MHP700) || defined (ARCH_HP700)
00061 #define CHOLMOD_HP
00062 #define CHOLMOD_ARCHITECTURE "HP 700 Unix"
00063 #define BLAS_NO_UNDERSCORE
00064 
00065 #else
00066 /* If the architecture is unknown, and you call the BLAS, you may need to */
00067 /* define BLAS_BY_VALUE, BLAS_NO_UNDERSCORE, and/or BLAS_CHAR_ARG yourself. */
00068 #define CHOLMOD_ARCHITECTURE "unknown"
00069 #endif
00070 
00071 
00072 /* ========================================================================== */
00073 /* === BLAS and LAPACK names ================================================ */
00074 /* ========================================================================== */
00075 
00076 /* Prototypes for the various versions of the BLAS.  */
00077 
00078 /* Determine if the 64-bit Sun Performance BLAS is to be used */
00079 #if defined(CHOLMOD_SOL2) && !defined(NSUNPERF) && defined(LONG) && defined(LONGBLAS)
00080 #define SUN64
00081 #endif
00082 
00083 #ifdef SUN64
00084 
00085 #define BLAS_DTRSV dtrsv_64_
00086 #define BLAS_DGEMV dgemv_64_
00087 #define BLAS_DTRSM dtrsm_64_
00088 #define BLAS_DGEMM dgemm_64_
00089 #define BLAS_DSYRK dsyrk_64_
00090 #define BLAS_DGER  dger_64_
00091 #define BLAS_DSCAL dscal_64_
00092 #define LAPACK_DPOTRF dpotrf_64_
00093 
00094 #define BLAS_ZTRSV ztrsv_64_
00095 #define BLAS_ZGEMV zgemv_64_
00096 #define BLAS_ZTRSM ztrsm_64_
00097 #define BLAS_ZGEMM zgemm_64_
00098 #define BLAS_ZHERK zherk_64_
00099 #define BLAS_ZGER  zgeru_64_
00100 #define BLAS_ZSCAL zscal_64_
00101 #define LAPACK_ZPOTRF zpotrf_64_
00102 
00103 #elif defined (BLAS_NO_UNDERSCORE)
00104 
00105 #define BLAS_DTRSV dtrsv
00106 #define BLAS_DGEMV dgemv
00107 #define BLAS_DTRSM dtrsm
00108 #define BLAS_DGEMM dgemm
00109 #define BLAS_DSYRK dsyrk
00110 #define BLAS_DGER  dger
00111 #define BLAS_DSCAL dscal
00112 #define LAPACK_DPOTRF dpotrf
00113 
00114 #define BLAS_ZTRSV ztrsv
00115 #define BLAS_ZGEMV zgemv
00116 #define BLAS_ZTRSM ztrsm
00117 #define BLAS_ZGEMM zgemm
00118 #define BLAS_ZHERK zherk
00119 #define BLAS_ZGER  zgeru
00120 #define BLAS_ZSCAL zscal
00121 #define LAPACK_ZPOTRF zpotrf
00122 
00123 #else
00124 
00125 #define BLAS_DTRSV dtrsv_
00126 #define BLAS_DGEMV dgemv_
00127 #define BLAS_DTRSM dtrsm_
00128 #define BLAS_DGEMM dgemm_
00129 #define BLAS_DSYRK dsyrk_
00130 #define BLAS_DGER  dger_
00131 #define BLAS_DSCAL dscal_
00132 #define LAPACK_DPOTRF dpotrf_
00133 
00134 #define BLAS_ZTRSV ztrsv_
00135 #define BLAS_ZGEMV zgemv_
00136 #define BLAS_ZTRSM ztrsm_
00137 #define BLAS_ZGEMM zgemm_
00138 #define BLAS_ZHERK zherk_
00139 #define BLAS_ZGER  zgeru_
00140 #define BLAS_ZSCAL zscal_
00141 #define LAPACK_ZPOTRF zpotrf_
00142 
00143 #endif
00144 
00145 /* ========================================================================== */
00146 /* === BLAS and LAPACK integer arguments ==================================== */
00147 /* ========================================================================== */
00148 
00149 /* CHOLMOD can be compiled with -D'LONGBLAS=long' for the Sun Performance
00150  * Library, or -D'LONGBLAS=long long' for SGI's SCSL BLAS.  This defines the
00151  * integer used in the BLAS for the cholmod_l_* routines.
00152  *
00153  * The "int" version of CHOLMOD always uses the "int" version of the BLAS.
00154  */
00155 
00156 #if defined (LONGBLAS) && defined (LONG)
00157 #define BLAS_INT LONGBLAS
00158 #else
00159 #define BLAS_INT int
00160 #endif
00161 
00162 /* If the BLAS integer is smaller than the basic CHOLMOD integer, then we need
00163  * to check for integer overflow when converting from one to the other.  If
00164  * any integer overflows, the externally-defined blas_ok variable is set to
00165  * FALSE.  blas_ok should be set to TRUE before calling any BLAS_* macro.
00166  */
00167 
00168 #define CHECK_BLAS_INT (sizeof (BLAS_INT) < sizeof (Int))
00169 #define EQ(K,k) (((BLAS_INT) K) == ((Int) k))
00170 
00171 /* ========================================================================== */
00172 /* === BLAS and LAPACK prototypes and macros ================================ */
00173 /* ========================================================================== */
00174 
00175 void BLAS_DGEMV (char *trans, BLAS_INT *m, BLAS_INT *n, double *alpha,
00176   double *A, BLAS_INT *lda, double *X, BLAS_INT *incx, double *beta,
00177   double *Y, BLAS_INT *incy) ;
00178 
00179 #define BLAS_dgemv(trans,m,n,alpha,A,lda,X,incx,beta,Y,incy) \
00180 { \
00181     BLAS_INT M = m, N = n, LDA = lda, INCX = incx, INCY = incy ; \
00182     if (CHECK_BLAS_INT) \
00183     { \
00184   blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) \
00185     && EQ (INCY,incy) ; \
00186     } \
00187     if (blas_ok) \
00188     { \
00189   BLAS_DGEMV (trans, &M, &N, alpha, A, &LDA, X, &INCX, beta, Y, &INCY) ; \
00190     } \
00191 }
00192 
00193 void BLAS_ZGEMV (char *trans, BLAS_INT *m, BLAS_INT *n, double *alpha,
00194   double *A, BLAS_INT *lda, double *X, BLAS_INT *incx, double *beta,
00195   double *Y, BLAS_INT *incy) ;
00196 
00197 #define BLAS_zgemv(trans,m,n,alpha,A,lda,X,incx,beta,Y,incy) \
00198 { \
00199     BLAS_INT M = m, N = n, LDA = lda, INCX = incx, INCY = incy ; \
00200     if (CHECK_BLAS_INT) \
00201     { \
00202   blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) \
00203     && EQ (INCY,incy) ; \
00204     } \
00205     if (blas_ok) \
00206     { \
00207   BLAS_ZGEMV (trans, &M, &N, alpha, A, &LDA, X, &INCX, beta, Y, &INCY) ; \
00208     } \
00209 }
00210 
00211 void BLAS_DTRSV (char *uplo, char *trans, char *diag, BLAS_INT *n, double *A,
00212   BLAS_INT *lda, double *X, BLAS_INT *incx) ;
00213 
00214 #define BLAS_dtrsv(uplo,trans,diag,n,A,lda,X,incx) \
00215 { \
00216     BLAS_INT N = n, LDA = lda, INCX = incx ; \
00217     if (CHECK_BLAS_INT) \
00218     { \
00219   blas_ok &= EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) ; \
00220     } \
00221     if (blas_ok) \
00222     { \
00223   BLAS_DTRSV (uplo, trans, diag, &N, A, &LDA, X, &INCX) ; \
00224     } \
00225 }
00226 
00227 void BLAS_ZTRSV (char *uplo, char *trans, char *diag, BLAS_INT *n, double *A,
00228   BLAS_INT *lda, double *X, BLAS_INT *incx) ;
00229 
00230 #define BLAS_ztrsv(uplo,trans,diag,n,A,lda,X,incx) \
00231 { \
00232     BLAS_INT N = n, LDA = lda, INCX = incx ; \
00233     if (CHECK_BLAS_INT) \
00234     { \
00235   blas_ok &= EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) ; \
00236     } \
00237     if (blas_ok) \
00238     { \
00239   BLAS_ZTRSV (uplo, trans, diag, &N, A, &LDA, X, &INCX) ; \
00240     } \
00241 }
00242 
00243 void BLAS_DTRSM (char *side, char *uplo, char *transa, char *diag, BLAS_INT *m,
00244   BLAS_INT *n, double *alpha, double *A, BLAS_INT *lda, double *B,
00245   BLAS_INT *ldb) ;
00246 
00247 #define BLAS_dtrsm(side,uplo,transa,diag,m,n,alpha,A,lda,B,ldb) \
00248 { \
00249     BLAS_INT M = m, N = n, LDA = lda, LDB = ldb ; \
00250     if (CHECK_BLAS_INT) \
00251     { \
00252   blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (LDB,ldb) ; \
00253     } \
00254     if (blas_ok) \
00255     { \
00256   BLAS_DTRSM (side, uplo, transa, diag, &M, &N, alpha, A, &LDA, B, &LDB);\
00257     } \
00258 }
00259 
00260 void BLAS_ZTRSM (char *side, char *uplo, char *transa, char *diag, BLAS_INT *m,
00261   BLAS_INT *n, double *alpha, double *A, BLAS_INT *lda, double *B,
00262   BLAS_INT *ldb) ;
00263 
00264 #define BLAS_ztrsm(side,uplo,transa,diag,m,n,alpha,A,lda,B,ldb) \
00265 { \
00266     BLAS_INT M = m, N = n, LDA = lda, LDB = ldb ; \
00267     if (CHECK_BLAS_INT) \
00268     { \
00269   blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (LDB,ldb) ; \
00270     } \
00271     if (blas_ok) \
00272     { \
00273   BLAS_ZTRSM (side, uplo, transa, diag, &M, &N, alpha, A, &LDA, B, &LDB);\
00274     } \
00275 }
00276 
00277 void BLAS_DGEMM (char *transa, char *transb, BLAS_INT *m, BLAS_INT *n,
00278   BLAS_INT *k, double *alpha, double *A, BLAS_INT *lda, double *B,
00279   BLAS_INT *ldb, double *beta, double *C, BLAS_INT *ldc) ;
00280 
00281 #define BLAS_dgemm(transa,transb,m,n,k,alpha,A,lda,B,ldb,beta,C,ldc) \
00282 { \
00283     BLAS_INT M = m, N = n, K = k, LDA = lda, LDB = ldb, LDC = ldc ; \
00284     if (CHECK_BLAS_INT) \
00285     { \
00286   blas_ok &= EQ (M,m) && EQ (N,n) && EQ (K,k) && EQ (LDA,lda) \
00287     && EQ (LDB,ldb) && EQ (LDC,ldc) ; \
00288     } \
00289     if (blas_ok) \
00290     { \
00291   BLAS_DGEMM (transa, transb, &M, &N, &K, alpha, A, &LDA, B, &LDB, beta, \
00292       C, &LDC) ; \
00293     } \
00294 }
00295 
00296 void BLAS_ZGEMM (char *transa, char *transb, BLAS_INT *m, BLAS_INT *n,
00297   BLAS_INT *k, double *alpha, double *A, BLAS_INT *lda, double *B,
00298   BLAS_INT *ldb, double *beta, double *C, BLAS_INT *ldc) ;
00299 
00300 #define BLAS_zgemm(transa,transb,m,n,k,alpha,A,lda,B,ldb,beta,C,ldc) \
00301 { \
00302     BLAS_INT M = m, N = n, K = k, LDA = lda, LDB = ldb, LDC = ldc ; \
00303     if (CHECK_BLAS_INT) \
00304     { \
00305   blas_ok &= EQ (M,m) && EQ (N,n) && EQ (K,k) && EQ (LDA,lda) \
00306     && EQ (LDB,ldb) && EQ (LDC,ldc) ; \
00307     } \
00308     if (blas_ok) \
00309     { \
00310   BLAS_ZGEMM (transa, transb, &M, &N, &K, alpha, A, &LDA, B, &LDB, beta, \
00311       C, &LDC) ; \
00312     } \
00313 }
00314 
00315 void BLAS_DSYRK (char *uplo, char *trans, BLAS_INT *n, BLAS_INT *k,
00316   double *alpha, double *A, BLAS_INT *lda, double *beta, double *C,
00317   BLAS_INT *ldc) ;
00318 
00319 #define BLAS_dsyrk(uplo,trans,n,k,alpha,A,lda,beta,C,ldc) \
00320 { \
00321     BLAS_INT N = n, K = k, LDA = lda, LDC = ldc ; \
00322     if (CHECK_BLAS_INT) \
00323     { \
00324   blas_ok &= EQ (N,n) && EQ (K,k) && EQ (LDA,lda) && EQ (LDC,ldc) ; \
00325     } \
00326     if (blas_ok) \
00327     { \
00328   BLAS_DSYRK (uplo, trans, &N, &K, alpha, A, &LDA, beta, C, &LDC) ; \
00329     } \
00330 } \
00331 
00332 void BLAS_ZHERK (char *uplo, char *trans, BLAS_INT *n, BLAS_INT *k,
00333   double *alpha, double *A, BLAS_INT *lda, double *beta, double *C,
00334   BLAS_INT *ldc) ;
00335 
00336 #define BLAS_zherk(uplo,trans,n,k,alpha,A,lda,beta,C,ldc) \
00337 { \
00338     BLAS_INT N = n, K = k, LDA = lda, LDC = ldc ; \
00339     if (CHECK_BLAS_INT) \
00340     { \
00341   blas_ok &= EQ (N,n) && EQ (K,k) && EQ (LDA,lda) && EQ (LDC,ldc) ; \
00342     } \
00343     if (blas_ok) \
00344     { \
00345   BLAS_ZHERK (uplo, trans, &N, &K, alpha, A, &LDA, beta, C, &LDC) ; \
00346     } \
00347 } \
00348 
00349 void LAPACK_DPOTRF (char *uplo, BLAS_INT *n, double *A, BLAS_INT *lda,
00350   BLAS_INT *info) ;
00351 
00352 #define LAPACK_dpotrf(uplo,n,A,lda,info) \
00353 { \
00354     BLAS_INT N = n, LDA = lda, INFO = 1 ; \
00355     if (CHECK_BLAS_INT) \
00356     { \
00357   blas_ok &= EQ (N,n) && EQ (LDA,lda) ; \
00358     } \
00359     if (blas_ok) \
00360     { \
00361   LAPACK_DPOTRF (uplo, &N, A, &LDA, &INFO) ; \
00362     } \
00363     info = INFO ; \
00364 }
00365 
00366 void LAPACK_ZPOTRF (char *uplo, BLAS_INT *n, double *A, BLAS_INT *lda,
00367   BLAS_INT *info) ;
00368 
00369 #define LAPACK_zpotrf(uplo,n,A,lda,info) \
00370 { \
00371     BLAS_INT N = n, LDA = lda, INFO = 1 ; \
00372     if (CHECK_BLAS_INT) \
00373     { \
00374   blas_ok &= EQ (N,n) && EQ (LDA,lda) ; \
00375     } \
00376     if (blas_ok) \
00377     { \
00378   LAPACK_ZPOTRF (uplo, &N, A, &LDA, &INFO) ; \
00379     } \
00380     info = INFO ; \
00381 }
00382 
00383 /* ========================================================================== */
00384 
00385 void BLAS_DSCAL (BLAS_INT *n, double *alpha, double *Y, BLAS_INT *incy) ;
00386 
00387 #define BLAS_dscal(n,alpha,Y,incy) \
00388 { \
00389     BLAS_INT N = n, INCY = incy ; \
00390     if (CHECK_BLAS_INT) \
00391     { \
00392   blas_ok &= EQ (N,n) && EQ (INCY,incy) ; \
00393     } \
00394     if (blas_ok) \
00395     { \
00396   BLAS_DSCAL (&N, alpha, Y, &INCY) ; \
00397     } \
00398 }
00399 
00400 void BLAS_ZSCAL (BLAS_INT *n, double *alpha, double *Y, BLAS_INT *incy) ;
00401 
00402 #define BLAS_zscal(n,alpha,Y,incy) \
00403 { \
00404     BLAS_INT N = n, INCY = incy ; \
00405     if (CHECK_BLAS_INT) \
00406     { \
00407   blas_ok &= EQ (N,n) && EQ (INCY,incy) ; \
00408     } \
00409     if (blas_ok) \
00410     { \
00411   BLAS_ZSCAL (&N, alpha, Y, &INCY) ; \
00412     } \
00413 }
00414 
00415 void BLAS_DGER (BLAS_INT *m, BLAS_INT *n, double *alpha,
00416   double *X, BLAS_INT *incx, double *Y, BLAS_INT *incy,
00417   double *A, BLAS_INT *lda) ;
00418 
00419 #define BLAS_dger(m,n,alpha,X,incx,Y,incy,A,lda) \
00420 { \
00421     BLAS_INT M = m, N = n, LDA = lda, INCX = incx, INCY = incy ; \
00422     if (CHECK_BLAS_INT) \
00423     { \
00424   blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) \
00425     && EQ (INCY,incy) ; \
00426     } \
00427     if (blas_ok) \
00428     { \
00429   BLAS_DGER (&M, &N, alpha, X, &INCX, Y, &INCY, A, &LDA) ; \
00430     } \
00431 }
00432 
00433 void BLAS_ZGERU (BLAS_INT *m, BLAS_INT *n, double *alpha,
00434   double *X, BLAS_INT *incx, double *Y, BLAS_INT *incy,
00435   double *A, BLAS_INT *lda) ;
00436 
00437 #define BLAS_zgeru(m,n,alpha,X,incx,Y,incy,A,lda) \
00438 { \
00439     BLAS_INT M = m, N = n, LDA = lda, INCX = incx, INCY = incy ; \
00440     if (CHECK_BLAS_INT) \
00441     { \
00442   blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) \
00443     && EQ (INCY,incy) ; \
00444     } \
00445     if (blas_ok) \
00446     { \
00447   BLAS_ZGER (&M, &N, alpha, X, &INCX, Y, &INCY, A, &LDA) ; \
00448     } \
00449 }
00450 
00451 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines