Epetra Package Browser (Single Doxygen Collection) Development
Epetra_BLAS.cpp
Go to the documentation of this file.
00001 
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2001 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 
00043 /* for INTEL_CXML, the second arg may need to be changed to 'one'.  If so
00044 the appropriate declaration of one will need to be added back into
00045 functions that include the macro:
00046 #if defined (INTEL_CXML)
00047   unsigned int one=1;
00048 #endif
00049 */
00050 
00051 #ifdef CHAR_MACRO
00052 #undef CHAR_MACRO
00053 #endif
00054 #if defined (INTEL_CXML)
00055 #define CHAR_MACRO(char_var) &char_var, 1
00056 #else
00057 #define CHAR_MACRO(char_var) &char_var
00058 #endif
00059 
00060 #include "Epetra_BLAS.h"
00061 #include "Epetra_BLAS_wrappers.h"
00062 
00063 
00064 //=============================================================================
00065 float Epetra_BLAS::ASUM(const int N, const float * X, const int INCX) const {
00066  return(SASUM_F77(&N, X, &INCX));
00067 }
00068 //=============================================================================
00069 double Epetra_BLAS::ASUM(const int N, const double * X, const int INCX) const {
00070   return(DASUM_F77(&N, X, &INCX));
00071 }
00072 //=============================================================================
00073 float Epetra_BLAS::DOT(const int N, const float * X, const float * Y, const int INCX, const int INCY) const {
00074   return(SDOT_F77(&N, X, &INCX, Y, &INCY));
00075 }
00076 //=============================================================================
00077 double Epetra_BLAS::DOT(const int N, const double * X, const double * Y, const int INCX, const int INCY) const {
00078   return(DDOT_F77(&N, X, &INCX, Y, &INCY));
00079 }
00080 //=============================================================================
00081 float Epetra_BLAS::NRM2(const int N, const float * X, const int INCX) const {
00082   return(SNRM2_F77(&N, X, &INCX));
00083 }
00084 //=============================================================================
00085 double Epetra_BLAS::NRM2(const int N, const double * X, const int INCX) const {
00086   return(DNRM2_F77(&N, X, &INCX));
00087 }
00088 //=============================================================================
00089 void Epetra_BLAS::SCAL(const int N, const float ALPHA, float * X, const int INCX) const {
00090   SSCAL_F77(&N, &ALPHA, X, &INCX);
00091   return;
00092 }
00093 //=============================================================================
00094 void Epetra_BLAS::SCAL(const int N, const double ALPHA, double * X, const int INCX) const {
00095   DSCAL_F77(&N, &ALPHA, X, &INCX);
00096   return;
00097 }
00098 //=============================================================================
00099 void Epetra_BLAS::COPY(const int N, const float * X, float * Y, const int INCX, const int INCY) const {
00100   SCOPY_F77(&N, X, &INCX, Y, &INCY);
00101   return;
00102 }
00103 //=============================================================================
00104 void Epetra_BLAS::COPY(const int N, const double * X, double * Y, const int INCX, const int INCY) const {
00105   DCOPY_F77(&N, X, &INCX, Y, &INCY);
00106   return;
00107 }
00108 //=============================================================================
00109 int Epetra_BLAS::IAMAX(const int N, const float * X, const int INCX) const {
00110   return(ISAMAX_F77(&N, X, &INCX)-1);// Note that we return base zero result
00111 }
00112 //=============================================================================
00113 int Epetra_BLAS::IAMAX(const int N, const double * X, const int INCX) const {
00114   return(IDAMAX_F77(&N, X, &INCX)-1);// Note that we return base zero result
00115 }
00116 //=============================================================================
00117 void Epetra_BLAS::AXPY(const int N, const float ALPHA, const float * X, float * Y, const int INCX, const int INCY) const {
00118   SAXPY_F77(&N, &ALPHA, X, &INCX, Y, &INCY);
00119 }
00120 //=============================================================================
00121 void Epetra_BLAS::AXPY(const int N, const double ALPHA, const double * X, double * Y, const int INCX, const int INCY) const {
00122   DAXPY_F77(&N, &ALPHA, X, &INCX, Y, &INCY);
00123 }
00124 //=============================================================================
00125 void Epetra_BLAS::GEMV(const char TRANS, const int M, const int N,
00126           const float ALPHA, const float * A, const int LDA, const float * X,
00127           const float BETA, float * Y, const int INCX, const int INCY) const {
00128   SGEMV_F77(CHAR_MACRO(TRANS), &M, &N, &ALPHA,
00129    A, &LDA, X, &INCX, &BETA, Y, &INCY);
00130 }
00131 //=============================================================================
00132 void Epetra_BLAS::GEMV(const char TRANS, const int M, const int N,
00133           const double ALPHA, const double * A, const int LDA, const double * X,
00134           const double BETA, double * Y, const int INCX, const int INCY) const {
00135   DGEMV_F77(CHAR_MACRO(TRANS), &M, &N, &ALPHA,
00136    A, &LDA, X, &INCX, &BETA, Y, &INCY);
00137 }
00138 
00139 //=============================================================================
00140 void Epetra_BLAS::GEMM(const char TRANSA, const char TRANSB, const int M, const int N, const int K,
00141            const float ALPHA, const float * A, const int LDA, const float * B,
00142            const int LDB, const float BETA, float * C, const int LDC) const {
00143 
00144   SGEMM_F77(CHAR_MACRO(TRANSA), CHAR_MACRO(TRANSB), &M, &N, &K, &ALPHA,
00145          A, &LDA, B, &LDB, &BETA, C, &LDC);
00146 }
00147 
00148 //=============================================================================
00149 void Epetra_BLAS::GEMM(const char TRANSA, const char TRANSB, const int M, const int N, const int K,
00150       const double ALPHA, const double * A, const int LDA, const double * B,
00151       const int LDB, const double BETA, double * C, const int LDC) const {
00152 
00153   DGEMM_F77(CHAR_MACRO(TRANSA), CHAR_MACRO(TRANSB), &M, &N, &K, &ALPHA,
00154    A, &LDA, B, &LDB, &BETA, C, &LDC);
00155 }
00156 //=============================================================================
00157 void Epetra_BLAS::SYMM(const char SIDE, const char UPLO, const int M, const int N,
00158       const float ALPHA, const float * A, const int LDA, const float * B,
00159       const int LDB, const float BETA, float * C, const int LDC) const {
00160 
00161   SSYMM_F77(CHAR_MACRO(SIDE), CHAR_MACRO(UPLO), &M, &N, &ALPHA,
00162          A, &LDA, B, &LDB, &BETA, C, &LDC);
00163 }
00164 
00165 //=============================================================================
00166 void Epetra_BLAS::SYMM(const char SIDE, const char UPLO, const int M, const int N,
00167       const double ALPHA, const double * A, const int LDA, const double * B,
00168       const int LDB, const double BETA, double * C, const int LDC) const {
00169 
00170   DSYMM_F77(CHAR_MACRO(SIDE), CHAR_MACRO(UPLO), &M, &N, &ALPHA,
00171          A, &LDA, B, &LDB, &BETA, C, &LDC);
00172 }
00173 //=============================================================================
00174 void Epetra_BLAS::TRMM(const char SIDE, const char UPLO, const char TRANSA, const char DIAG, const int M, const int N,
00175       const float ALPHA, const float * A, const int LDA, float * B,
00176       const int LDB) const {
00177 
00178   STRMM_F77(CHAR_MACRO(SIDE), CHAR_MACRO(UPLO), CHAR_MACRO(TRANSA), CHAR_MACRO(DIAG), 
00179     &M, &N, &ALPHA, A, &LDA, B, &LDB);
00180 }
00181 //=============================================================================
00182 void Epetra_BLAS::TRMM(const char SIDE, const char UPLO, const char TRANSA, const char DIAG, const int M, const int N,
00183       const double ALPHA, const double * A, const int LDA, double * B,
00184       const int LDB) const {
00185 
00186   DTRMM_F77(CHAR_MACRO(SIDE), CHAR_MACRO(UPLO), CHAR_MACRO(TRANSA), CHAR_MACRO(DIAG), 
00187       &M, &N, &ALPHA, A, &LDA, B, &LDB);
00188 }
00189 //=============================================================================
00190 void Epetra_BLAS::SYRK(const char UPLO, const char TRANS, const int N, const int K, const float ALPHA, const float *A,
00191                        const int LDA, const float BETA, float *C, const int LDC) const{
00192   SSYRK_F77(CHAR_MACRO(UPLO), CHAR_MACRO(TRANS), &N, &K, &ALPHA, A, &LDA, &BETA, C, &LDC);
00193 }
00194 //=============================================================================
00195 void Epetra_BLAS::SYRK(const char UPLO, const char TRANS, const int N, const int K, const double ALPHA, const double *A,
00196                        const int LDA, const double BETA, double *C, const int LDC) const{
00197   DSYRK_F77(CHAR_MACRO(UPLO), CHAR_MACRO(TRANS), &N, &K, &ALPHA, A, &LDA, &BETA, C, &LDC);
00198 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines