Kokkos Node API and Local Linear Algebra Kernels Version of the Day
Tsqr_Blas.cpp
00001 //@HEADER
00002 // ************************************************************************
00003 // 
00004 //          Kokkos: Node API and Parallel Node Kernels
00005 //              Copyright (2008) Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00038 // 
00039 // ************************************************************************
00040 //@HEADER
00041 
00042 #include <Tsqr_Blas.hpp>
00043 #include <complex>
00044 
00045 // C doesn't allow 'extern "C"' declarations inside a class' member
00046 // functions, so we have to list all the 'extern "C"' declarations up
00047 // here.
00048 
00049 extern "C" void F77_BLAS_MANGLE(dgemv, DGEMV) 
00050   (const char* const TRANS,
00051    const int* const M,
00052    const int* const N,
00053    const double* const ALPHA,
00054    const double A[],
00055    const int* const LDA,
00056    const double X[],
00057    const int* const INCX,
00058    const double* const BETA,
00059    double Y[],
00060    const int* const INCY);
00061 
00062 extern "C" void F77_BLAS_MANGLE(sgemv, SGEMV)
00063   (const char* const TRANS,
00064    const int* const M,
00065    const int* const N,
00066    const float* const ALPHA,
00067    const float A[],
00068    const int* const LDA,
00069    const float X[],
00070    const int* const INCX,
00071    const float* const BETA,
00072    float Y[],
00073    const int* const INCY);
00074 
00075 extern "C" void F77_BLAS_MANGLE(zgemv, ZGEMV)
00076   (const char* const TRANS,
00077    const int* const M,
00078    const int* const N,
00079    const std::complex<double>* const ALPHA,
00080    const std::complex<double> A[],
00081    const int* const LDA,
00082    const std::complex<double> X[],
00083    const int* const INCX,
00084    const std::complex<double>* const BETA,
00085    std::complex<double> Y[],
00086    const int* const INCY);
00087 
00088 extern "C" void F77_BLAS_MANGLE(cgemv, CGEMV)
00089   (const char* const TRANS,
00090    const int* const M,
00091    const int* const N,
00092    const std::complex<float>* const ALPHA,
00093    const std::complex<float> A[],
00094    const int* const LDA,
00095    const std::complex<float> X[],
00096    const int* const INCX,
00097    const std::complex<float>* const BETA,
00098    std::complex<float> Y[],
00099    const int* const INCY);
00100 
00101 extern "C" void F77_BLAS_MANGLE(dgemm, DGEMM)
00102   (const char* const TRANSA,
00103    const char* const TRANSB,
00104    const int* const M,
00105    const int* const N,
00106    const int* const K,
00107    const double* const ALPHA,
00108    const double A[],
00109    const int* const LDA,
00110    const double B[],
00111    const int* const LDB,
00112    const double* const BETA,
00113    double C[],
00114    const int* const LDC);
00115 
00116 extern "C" void F77_BLAS_MANGLE(sgemm, SGEMM)
00117   (const char* const TRANSA,
00118    const char* const TRANSB,
00119    const int* const M,
00120    const int* const N,
00121    const int* const K,
00122    const float* const ALPHA,
00123    const float A[],
00124    const int* const LDA,
00125    const float B[],
00126    const int* const LDB,
00127    const float* const BETA,
00128    float C[],
00129    const int* const LDC);
00130 
00131 extern "C" void F77_BLAS_MANGLE(zgemm, ZGEMM)
00132   (const char* const TRANSA,
00133    const char* const TRANSB,
00134    const int* const M,
00135    const int* const N,
00136    const int* const K,
00137    const std::complex<double>* const ALPHA,
00138    const std::complex<double> A[],
00139    const int* const LDA,
00140    const std::complex<double> B[],
00141    const int* const LDB,
00142    const std::complex<double>* const BETA,
00143    std::complex<double> C[],
00144    const int* const LDC);
00145 
00146 extern "C" void F77_BLAS_MANGLE(cgemm, CGEMM)
00147   (const char* const TRANSA,
00148    const char* const TRANSB,
00149    const int* const M,
00150    const int* const N,
00151    const int* const K,
00152    const std::complex<float>* const ALPHA,
00153    const std::complex<float> A[],
00154    const int* const LDA,
00155    const std::complex<float> B[],
00156    const int* const LDB,
00157    const std::complex<float>* const BETA,
00158    std::complex<float> C[],
00159    const int* const LDC);
00160 
00161 extern "C" void F77_BLAS_MANGLE(dger, DGER)
00162   (const int* const M,
00163    const int* const N,
00164    const double* const ALPHA,
00165    const double X[],
00166    const int* const INCX,
00167    const double Y[],
00168    const int* const INCY,
00169    double A[],
00170    const int* const LDA);
00171 
00172 extern "C" void F77_BLAS_MANGLE(sger, SGER)
00173   (const int* const M,
00174    const int* const N,
00175    const float* const ALPHA,
00176    const float X[],
00177    const int* const INCX,
00178    const float Y[],
00179    const int* const INCY,
00180    float A[],
00181    const int* const LDA);
00182 
00183 extern "C" void F77_BLAS_MANGLE(zgerc, ZGERC)
00184   (const int* const M,
00185    const int* const N,
00186    const std::complex<double>* const ALPHA,
00187    const std::complex<double> X[],
00188    const int* const INCX,
00189    const std::complex<double> Y[],
00190    const int* const INCY,
00191    std::complex<double> A[],
00192    const int* const LDA);
00193 
00194 extern "C" void F77_BLAS_MANGLE(cgerc, CGERC)
00195   (const int* const M,
00196    const int* const N,
00197    const std::complex<float>* const ALPHA,
00198    const std::complex<float> X[],
00199    const int* const INCX,
00200    const std::complex<float> Y[],
00201    const int* const INCY,
00202    std::complex<float> A[],
00203    const int* const LDA);
00204 
00205 extern "C" void F77_BLAS_MANGLE(dtrsm, DTRSM)
00206   (const char* const SIDE,
00207    const char* const UPLO,
00208    const char* const TRANSA,
00209    const char* const DIAG,
00210    const int* const M,
00211    const int* const N,
00212    const double* const ALPHA,
00213    const double A[],
00214    const int* const LDA,
00215    double B[],
00216    const int* const LDB);
00217 
00218 extern "C" void F77_BLAS_MANGLE(strsm, STRSM)
00219   (const char* const SIDE,
00220    const char* const UPLO,
00221    const char* const TRANSA,
00222    const char* const DIAG,
00223    const int* const M,
00224    const int* const N,
00225    const float* const ALPHA,
00226    const float A[],
00227    const int* const LDA,
00228    float B[],
00229    const int* const LDB);
00230 
00231 extern "C" void F77_BLAS_MANGLE(ztrsm, ZTRSM)
00232   (const char* const SIDE,
00233    const char* const UPLO,
00234    const char* const TRANSA,
00235    const char* const DIAG,
00236    const int* const M,
00237    const int* const N,
00238    const std::complex<double>* const ALPHA,
00239    const std::complex<double> A[],
00240    const int* const LDA,
00241    std::complex<double> B[],
00242    const int* const LDB);
00243 
00244 extern "C" void F77_BLAS_MANGLE(ctrsm, CTRSM)
00245   (const char* const SIDE,
00246    const char* const UPLO,
00247    const char* const TRANSA,
00248    const char* const DIAG,
00249    const int* const M,
00250    const int* const N,
00251    const std::complex<float>* const ALPHA,
00252    const std::complex<float> A[],
00253    const int* const LDA,
00254    std::complex<float> B[],
00255    const int* const LDB);
00256 
00257 namespace TSQR {
00258 
00259   template<>
00260   void
00261   BLAS<int, double>::
00262   GEMV (const char* const trans, 
00263   const int m, 
00264   const int n,
00265   const double alpha,
00266   const double A[],
00267   const int lda,
00268   const double x[],
00269   const int incx,
00270   const double beta,
00271   double y[],
00272   const int incy)
00273   {
00274     F77_BLAS_MANGLE(dgemv, DGEMV) 
00275       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00276   }
00277 
00278   template<>
00279   void
00280   BLAS<int, float>::
00281   GEMV (const char* const trans, 
00282   const int m, 
00283   const int n,
00284   const float alpha,
00285   const float A[],
00286   const int lda,
00287   const float x[],
00288   const int incx,
00289   const float beta,
00290   float y[],
00291   const int incy)
00292   {
00293     F77_BLAS_MANGLE(sgemv, SGEMV) 
00294       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00295   }
00296 
00297   template<>
00298   void
00299   BLAS<int, std::complex<double> >::
00300   GEMV (const char* const trans, 
00301   const int m, 
00302   const int n,
00303   const std::complex<double> alpha,
00304   const std::complex<double> A[],
00305   const int lda,
00306   const std::complex<double> x[],
00307   const int incx,
00308   const std::complex<double> beta,
00309   std::complex<double> y[],
00310   const int incy)
00311   {
00312     F77_BLAS_MANGLE(zgemv, ZGEMV) 
00313       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00314   }
00315 
00316   template<>
00317   void
00318   BLAS<int, std::complex<float> >::
00319   GEMV (const char* const trans, 
00320   const int m, 
00321   const int n,
00322   const std::complex<float> alpha,
00323   const std::complex<float> A[],
00324   const int lda,
00325   const std::complex<float> x[],
00326   const int incx,
00327   const std::complex<float> beta,
00328   std::complex<float> y[],
00329   const int incy)
00330   {
00331     F77_BLAS_MANGLE(cgemv, CGEMV) 
00332       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00333   }
00334 
00335   template<>
00336   void
00337   BLAS<int, double>::
00338   GEMM (const char* const transa,
00339   const char* const transb,
00340   const int m,
00341   const int n,
00342   const int k,
00343   const double alpha,
00344   const double A[],
00345   const int lda,
00346   const double B[],
00347   const int ldb,
00348   const double beta,
00349   double C[],
00350   const int ldc)
00351   {
00352     F77_BLAS_MANGLE(dgemm, DGEMM) 
00353       (transa, transb, &m, &n, &k, &alpha,
00354        A, &lda, B, &ldb, &beta, C, &ldc);
00355   }
00356 
00357   template<>
00358   void
00359   BLAS<int, float>::
00360   GEMM (const char* const transa,
00361   const char* const transb,
00362   const int m,
00363   const int n,
00364   const int k,
00365   const float alpha,
00366   const float A[],
00367   const int lda,
00368   const float B[],
00369   const int ldb,
00370   const float beta,
00371   float C[],
00372   const int ldc)
00373   {
00374     F77_BLAS_MANGLE(sgemm, SGEMM) 
00375       (transa, transb, &m, &n, &k, &alpha,
00376        A, &lda, B, &ldb, &beta, C, &ldc);
00377   }
00378 
00379   template<>
00380   void
00381   BLAS<int, std::complex<double> >::
00382   GEMM (const char* const transa,
00383   const char* const transb,
00384   const int m,
00385   const int n,
00386   const int k,
00387   const std::complex<double> alpha,
00388   const std::complex<double> A[],
00389   const int lda,
00390   const std::complex<double> B[],
00391   const int ldb,
00392   const std::complex<double> beta,
00393   std::complex<double> C[],
00394   const int ldc)
00395   {
00396     F77_BLAS_MANGLE(zgemm, ZGEMM) 
00397       (transa, transb, &m, &n, &k, &alpha,
00398        A, &lda, B, &ldb, &beta, C, &ldc);
00399   }
00400 
00401   template<>
00402   void
00403   BLAS<int, std::complex<float> >::
00404   GEMM (const char* const transa,
00405   const char* const transb,
00406   const int m,
00407   const int n,
00408   const int k,
00409   const std::complex<float> alpha,
00410   const std::complex<float> A[],
00411   const int lda,
00412   const std::complex<float> B[],
00413   const int ldb,
00414   const std::complex<float> beta,
00415   std::complex<float> C[],
00416   const int ldc)
00417   {
00418     F77_BLAS_MANGLE(cgemm, CGEMM) 
00419       (transa, transb, &m, &n, &k, &alpha, 
00420        A, &lda, B, &ldb, &beta, C, &ldc);
00421   }
00422 
00423   template<>
00424   void
00425   BLAS<int, double>::
00426   GER (const int m,
00427        const int n,
00428        const double alpha,
00429        const double x[],
00430        const int incx,
00431        const double y[],
00432        const int incy,
00433        double A[],
00434        const int lda)
00435   {
00436     F77_BLAS_MANGLE(dger, DGER) 
00437       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00438   }
00439 
00440   template<>
00441   void
00442   BLAS<int, float>::
00443   GER (const int m,
00444        const int n,
00445        const float alpha,
00446        const float x[],
00447        const int incx,
00448        const float y[],
00449        const int incy,
00450        float A[],
00451        const int lda)
00452   {
00453     F77_BLAS_MANGLE(sger, SGER) 
00454       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00455   }
00456 
00457   template<>
00458   void
00459   BLAS<int, std::complex<double> >::
00460   GER (const int m,
00461        const int n,
00462        const std::complex<double> alpha,
00463        const std::complex<double> x[],
00464        const int incx,
00465        const std::complex<double> y[],
00466        const int incy,
00467        std::complex<double> A[],
00468        const int lda)
00469   {
00470     F77_BLAS_MANGLE(zgerc, ZGERC) 
00471       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00472   }
00473 
00474   template<>
00475   void
00476   BLAS<int, std::complex<float> >::
00477   GER (const int m,
00478        const int n,
00479        const std::complex<float> alpha,
00480        const std::complex<float> x[],
00481        const int incx,
00482        const std::complex<float> y[],
00483        const int incy,
00484        std::complex<float> A[],
00485        const int lda)
00486   {
00487     F77_BLAS_MANGLE(cgerc, CGERC) 
00488       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00489   }
00490 
00491   template<>
00492   void
00493   BLAS<int, double >::
00494   TRSM (const char* const side,
00495   const char* const uplo,
00496   const char* const transa,
00497   const char* const diag,
00498   const int m,
00499   const int n,
00500   const double alpha,
00501   const double A[],
00502   const int lda,
00503   double B[],
00504   const int ldb)
00505   {
00506     F77_BLAS_MANGLE(dtrsm, DTRSM) 
00507       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00508   }
00509 
00510   template<>
00511   void
00512   BLAS<int, float >::
00513   TRSM (const char* const side,
00514   const char* const uplo,
00515   const char* const transa,
00516   const char* const diag,
00517   const int m,
00518   const int n,
00519   const float alpha,
00520   const float A[],
00521   const int lda,
00522   float B[],
00523   const int ldb)
00524   {
00525     F77_BLAS_MANGLE(strsm, STRSM) 
00526       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00527   }
00528 
00529   template<>
00530   void
00531   BLAS<int, std::complex<double> >::
00532   TRSM (const char* const side,
00533   const char* const uplo,
00534   const char* const transa,
00535   const char* const diag,
00536   const int m,
00537   const int n,
00538   const std::complex<double> alpha,
00539   const std::complex<double> A[],
00540   const int lda,
00541   std::complex<double> B[],
00542   const int ldb)
00543   {
00544     F77_BLAS_MANGLE(ztrsm, ZTRSM) 
00545       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00546   }
00547 
00548   template<>
00549   void
00550   BLAS<int, std::complex<float> >::
00551   TRSM (const char* const side,
00552   const char* const uplo,
00553   const char* const transa,
00554   const char* const diag,
00555   const int m,
00556   const int n,
00557   const std::complex<float> alpha,
00558   const std::complex<float> A[],
00559   const int lda,
00560   std::complex<float> B[],
00561   const int ldb)
00562   {
00563     F77_BLAS_MANGLE(ctrsm, CTRSM) 
00564       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00565   }
00566 
00567 } // namespace TSQR
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends