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 (2009) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ************************************************************************
00027 //@HEADER
00028 
00029 #include <Tsqr_Blas.hpp>
00030 #include <complex>
00031 
00032 // C doesn't allow 'extern "C"' declarations inside a class' member
00033 // functions, so we have to list all the 'extern "C"' declarations up
00034 // here.
00035 
00036 extern "C" void F77_BLAS_MANGLE(dgemv, DGEMV) 
00037   (const char* const TRANS,
00038    const int* const M,
00039    const int* const N,
00040    const double* const ALPHA,
00041    const double A[],
00042    const int* const LDA,
00043    const double X[],
00044    const int* const INCX,
00045    const double* const BETA,
00046    double Y[],
00047    const int* const INCY);
00048 
00049 extern "C" void F77_BLAS_MANGLE(sgemv, SGEMV)
00050   (const char* const TRANS,
00051    const int* const M,
00052    const int* const N,
00053    const float* const ALPHA,
00054    const float A[],
00055    const int* const LDA,
00056    const float X[],
00057    const int* const INCX,
00058    const float* const BETA,
00059    float Y[],
00060    const int* const INCY);
00061 
00062 extern "C" void F77_BLAS_MANGLE(zgemv, ZGEMV)
00063   (const char* const TRANS,
00064    const int* const M,
00065    const int* const N,
00066    const std::complex<double>* const ALPHA,
00067    const std::complex<double> A[],
00068    const int* const LDA,
00069    const std::complex<double> X[],
00070    const int* const INCX,
00071    const std::complex<double>* const BETA,
00072    std::complex<double> Y[],
00073    const int* const INCY);
00074 
00075 extern "C" void F77_BLAS_MANGLE(cgemv, CGEMV)
00076   (const char* const TRANS,
00077    const int* const M,
00078    const int* const N,
00079    const std::complex<float>* const ALPHA,
00080    const std::complex<float> A[],
00081    const int* const LDA,
00082    const std::complex<float> X[],
00083    const int* const INCX,
00084    const std::complex<float>* const BETA,
00085    std::complex<float> Y[],
00086    const int* const INCY);
00087 
00088 extern "C" void F77_BLAS_MANGLE(dgemm, DGEMM)
00089   (const char* const TRANSA,
00090    const char* const TRANSB,
00091    const int* const M,
00092    const int* const N,
00093    const int* const K,
00094    const double* const ALPHA,
00095    const double A[],
00096    const int* const LDA,
00097    const double B[],
00098    const int* const LDB,
00099    const double* const BETA,
00100    double C[],
00101    const int* const LDC);
00102 
00103 extern "C" void F77_BLAS_MANGLE(sgemm, SGEMM)
00104   (const char* const TRANSA,
00105    const char* const TRANSB,
00106    const int* const M,
00107    const int* const N,
00108    const int* const K,
00109    const float* const ALPHA,
00110    const float A[],
00111    const int* const LDA,
00112    const float B[],
00113    const int* const LDB,
00114    const float* const BETA,
00115    float C[],
00116    const int* const LDC);
00117 
00118 extern "C" void F77_BLAS_MANGLE(zgemm, ZGEMM)
00119   (const char* const TRANSA,
00120    const char* const TRANSB,
00121    const int* const M,
00122    const int* const N,
00123    const int* const K,
00124    const std::complex<double>* const ALPHA,
00125    const std::complex<double> A[],
00126    const int* const LDA,
00127    const std::complex<double> B[],
00128    const int* const LDB,
00129    const std::complex<double>* const BETA,
00130    std::complex<double> C[],
00131    const int* const LDC);
00132 
00133 extern "C" void F77_BLAS_MANGLE(cgemm, CGEMM)
00134   (const char* const TRANSA,
00135    const char* const TRANSB,
00136    const int* const M,
00137    const int* const N,
00138    const int* const K,
00139    const std::complex<float>* const ALPHA,
00140    const std::complex<float> A[],
00141    const int* const LDA,
00142    const std::complex<float> B[],
00143    const int* const LDB,
00144    const std::complex<float>* const BETA,
00145    std::complex<float> C[],
00146    const int* const LDC);
00147 
00148 extern "C" void F77_BLAS_MANGLE(dger, DGER)
00149   (const int* const M,
00150    const int* const N,
00151    const double* const ALPHA,
00152    const double X[],
00153    const int* const INCX,
00154    const double Y[],
00155    const int* const INCY,
00156    double A[],
00157    const int* const LDA);
00158 
00159 extern "C" void F77_BLAS_MANGLE(sger, SGER)
00160   (const int* const M,
00161    const int* const N,
00162    const float* const ALPHA,
00163    const float X[],
00164    const int* const INCX,
00165    const float Y[],
00166    const int* const INCY,
00167    float A[],
00168    const int* const LDA);
00169 
00170 extern "C" void F77_BLAS_MANGLE(zgerc, ZGERC)
00171   (const int* const M,
00172    const int* const N,
00173    const std::complex<double>* const ALPHA,
00174    const std::complex<double> X[],
00175    const int* const INCX,
00176    const std::complex<double> Y[],
00177    const int* const INCY,
00178    std::complex<double> A[],
00179    const int* const LDA);
00180 
00181 extern "C" void F77_BLAS_MANGLE(cgerc, CGERC)
00182   (const int* const M,
00183    const int* const N,
00184    const std::complex<float>* const ALPHA,
00185    const std::complex<float> X[],
00186    const int* const INCX,
00187    const std::complex<float> Y[],
00188    const int* const INCY,
00189    std::complex<float> A[],
00190    const int* const LDA);
00191 
00192 extern "C" void F77_BLAS_MANGLE(dtrsm, DTRSM)
00193   (const char* const SIDE,
00194    const char* const UPLO,
00195    const char* const TRANSA,
00196    const char* const DIAG,
00197    const int* const M,
00198    const int* const N,
00199    const double* const ALPHA,
00200    const double A[],
00201    const int* const LDA,
00202    double B[],
00203    const int* const LDB);
00204 
00205 extern "C" void F77_BLAS_MANGLE(strsm, STRSM)
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 float* const ALPHA,
00213    const float A[],
00214    const int* const LDA,
00215    float B[],
00216    const int* const LDB);
00217 
00218 extern "C" void F77_BLAS_MANGLE(ztrsm, ZTRSM)
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 std::complex<double>* const ALPHA,
00226    const std::complex<double> A[],
00227    const int* const LDA,
00228    std::complex<double> B[],
00229    const int* const LDB);
00230 
00231 extern "C" void F77_BLAS_MANGLE(ctrsm, CTRSM)
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<float>* const ALPHA,
00239    const std::complex<float> A[],
00240    const int* const LDA,
00241    std::complex<float> B[],
00242    const int* const LDB);
00243 
00244 namespace TSQR {
00245 
00246   template<>
00247   void
00248   BLAS<int, double>::
00249   GEMV (const char* const trans, 
00250   const int m, 
00251   const int n,
00252   const double alpha,
00253   const double A[],
00254   const int lda,
00255   const double x[],
00256   const int incx,
00257   const double beta,
00258   double y[],
00259   const int incy)
00260   {
00261     F77_BLAS_MANGLE(dgemv, DGEMV) 
00262       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00263   }
00264 
00265   template<>
00266   void
00267   BLAS<int, float>::
00268   GEMV (const char* const trans, 
00269   const int m, 
00270   const int n,
00271   const float alpha,
00272   const float A[],
00273   const int lda,
00274   const float x[],
00275   const int incx,
00276   const float beta,
00277   float y[],
00278   const int incy)
00279   {
00280     F77_BLAS_MANGLE(sgemv, SGEMV) 
00281       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00282   }
00283 
00284   template<>
00285   void
00286   BLAS<int, std::complex<double> >::
00287   GEMV (const char* const trans, 
00288   const int m, 
00289   const int n,
00290   const std::complex<double> alpha,
00291   const std::complex<double> A[],
00292   const int lda,
00293   const std::complex<double> x[],
00294   const int incx,
00295   const std::complex<double> beta,
00296   std::complex<double> y[],
00297   const int incy)
00298   {
00299     F77_BLAS_MANGLE(zgemv, ZGEMV) 
00300       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00301   }
00302 
00303   template<>
00304   void
00305   BLAS<int, std::complex<float> >::
00306   GEMV (const char* const trans, 
00307   const int m, 
00308   const int n,
00309   const std::complex<float> alpha,
00310   const std::complex<float> A[],
00311   const int lda,
00312   const std::complex<float> x[],
00313   const int incx,
00314   const std::complex<float> beta,
00315   std::complex<float> y[],
00316   const int incy)
00317   {
00318     F77_BLAS_MANGLE(cgemv, CGEMV) 
00319       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00320   }
00321 
00322   template<>
00323   void
00324   BLAS<int, double>::
00325   GEMM (const char* const transa,
00326   const char* const transb,
00327   const int m,
00328   const int n,
00329   const int k,
00330   const double alpha,
00331   const double A[],
00332   const int lda,
00333   const double B[],
00334   const int ldb,
00335   const double beta,
00336   double C[],
00337   const int ldc)
00338   {
00339     F77_BLAS_MANGLE(dgemm, DGEMM) 
00340       (transa, transb, &m, &n, &k, &alpha,
00341        A, &lda, B, &ldb, &beta, C, &ldc);
00342   }
00343 
00344   template<>
00345   void
00346   BLAS<int, float>::
00347   GEMM (const char* const transa,
00348   const char* const transb,
00349   const int m,
00350   const int n,
00351   const int k,
00352   const float alpha,
00353   const float A[],
00354   const int lda,
00355   const float B[],
00356   const int ldb,
00357   const float beta,
00358   float C[],
00359   const int ldc)
00360   {
00361     F77_BLAS_MANGLE(sgemm, SGEMM) 
00362       (transa, transb, &m, &n, &k, &alpha,
00363        A, &lda, B, &ldb, &beta, C, &ldc);
00364   }
00365 
00366   template<>
00367   void
00368   BLAS<int, std::complex<double> >::
00369   GEMM (const char* const transa,
00370   const char* const transb,
00371   const int m,
00372   const int n,
00373   const int k,
00374   const std::complex<double> alpha,
00375   const std::complex<double> A[],
00376   const int lda,
00377   const std::complex<double> B[],
00378   const int ldb,
00379   const std::complex<double> beta,
00380   std::complex<double> C[],
00381   const int ldc)
00382   {
00383     F77_BLAS_MANGLE(zgemm, ZGEMM) 
00384       (transa, transb, &m, &n, &k, &alpha,
00385        A, &lda, B, &ldb, &beta, C, &ldc);
00386   }
00387 
00388   template<>
00389   void
00390   BLAS<int, std::complex<float> >::
00391   GEMM (const char* const transa,
00392   const char* const transb,
00393   const int m,
00394   const int n,
00395   const int k,
00396   const std::complex<float> alpha,
00397   const std::complex<float> A[],
00398   const int lda,
00399   const std::complex<float> B[],
00400   const int ldb,
00401   const std::complex<float> beta,
00402   std::complex<float> C[],
00403   const int ldc)
00404   {
00405     F77_BLAS_MANGLE(cgemm, CGEMM) 
00406       (transa, transb, &m, &n, &k, &alpha, 
00407        A, &lda, B, &ldb, &beta, C, &ldc);
00408   }
00409 
00410   template<>
00411   void
00412   BLAS<int, double>::
00413   GER (const int m,
00414        const int n,
00415        const double alpha,
00416        const double x[],
00417        const int incx,
00418        const double y[],
00419        const int incy,
00420        double A[],
00421        const int lda)
00422   {
00423     F77_BLAS_MANGLE(dger, DGER) 
00424       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00425   }
00426 
00427   template<>
00428   void
00429   BLAS<int, float>::
00430   GER (const int m,
00431        const int n,
00432        const float alpha,
00433        const float x[],
00434        const int incx,
00435        const float y[],
00436        const int incy,
00437        float A[],
00438        const int lda)
00439   {
00440     F77_BLAS_MANGLE(sger, SGER) 
00441       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00442   }
00443 
00444   template<>
00445   void
00446   BLAS<int, std::complex<double> >::
00447   GER (const int m,
00448        const int n,
00449        const std::complex<double> alpha,
00450        const std::complex<double> x[],
00451        const int incx,
00452        const std::complex<double> y[],
00453        const int incy,
00454        std::complex<double> A[],
00455        const int lda)
00456   {
00457     F77_BLAS_MANGLE(zgerc, ZGERC) 
00458       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00459   }
00460 
00461   template<>
00462   void
00463   BLAS<int, std::complex<float> >::
00464   GER (const int m,
00465        const int n,
00466        const std::complex<float> alpha,
00467        const std::complex<float> x[],
00468        const int incx,
00469        const std::complex<float> y[],
00470        const int incy,
00471        std::complex<float> A[],
00472        const int lda)
00473   {
00474     F77_BLAS_MANGLE(cgerc, CGERC) 
00475       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00476   }
00477 
00478   template<>
00479   void
00480   BLAS<int, double >::
00481   TRSM (const char* const side,
00482   const char* const uplo,
00483   const char* const transa,
00484   const char* const diag,
00485   const int m,
00486   const int n,
00487   const double alpha,
00488   const double A[],
00489   const int lda,
00490   double B[],
00491   const int ldb)
00492   {
00493     F77_BLAS_MANGLE(dtrsm, DTRSM) 
00494       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00495   }
00496 
00497   template<>
00498   void
00499   BLAS<int, float >::
00500   TRSM (const char* const side,
00501   const char* const uplo,
00502   const char* const transa,
00503   const char* const diag,
00504   const int m,
00505   const int n,
00506   const float alpha,
00507   const float A[],
00508   const int lda,
00509   float B[],
00510   const int ldb)
00511   {
00512     F77_BLAS_MANGLE(strsm, STRSM) 
00513       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00514   }
00515 
00516   template<>
00517   void
00518   BLAS<int, std::complex<double> >::
00519   TRSM (const char* const side,
00520   const char* const uplo,
00521   const char* const transa,
00522   const char* const diag,
00523   const int m,
00524   const int n,
00525   const std::complex<double> alpha,
00526   const std::complex<double> A[],
00527   const int lda,
00528   std::complex<double> B[],
00529   const int ldb)
00530   {
00531     F77_BLAS_MANGLE(ztrsm, ZTRSM) 
00532       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00533   }
00534 
00535   template<>
00536   void
00537   BLAS<int, std::complex<float> >::
00538   TRSM (const char* const side,
00539   const char* const uplo,
00540   const char* const transa,
00541   const char* const diag,
00542   const int m,
00543   const int n,
00544   const std::complex<float> alpha,
00545   const std::complex<float> A[],
00546   const int lda,
00547   std::complex<float> B[],
00548   const int ldb)
00549   {
00550     F77_BLAS_MANGLE(ctrsm, CTRSM) 
00551       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00552   }
00553 
00554 } // namespace TSQR
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends