Anasazi Version of the Day
Tsqr_Blas.cpp
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //                 Anasazi: Block Eigensolvers Package
00005 //                 Copyright (2010) 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 <Tsqr_Config.hpp>
00031 #include <complex>
00032 
00035 
00036 // mfh 28 Apr 2010
00037 //
00038 // C doesn't allow 'extern "C"' declarations inside a class' member
00039 // functions, which means I have to list them all up here.
00040 
00041 extern "C" void F77_BLAS_MANGLE(dgemv, DGEMV) 
00042   (const char* const TRANS,
00043    const int* const M,
00044    const int* const N,
00045    const double* const ALPHA,
00046    const double A[],
00047    const int* const LDA,
00048    const double X[],
00049    const int* const INCX,
00050    const double* const BETA,
00051    double Y[],
00052    const int* const INCY);
00053 
00054 extern "C" void F77_BLAS_MANGLE(sgemv, SGEMV)
00055   (const char* const TRANS,
00056    const int* const M,
00057    const int* const N,
00058    const float* const ALPHA,
00059    const float A[],
00060    const int* const LDA,
00061    const float X[],
00062    const int* const INCX,
00063    const float* const BETA,
00064    float Y[],
00065    const int* const INCY);
00066 
00067 extern "C" void F77_BLAS_MANGLE(zgemv, ZGEMV)
00068   (const char* const TRANS,
00069    const int* const M,
00070    const int* const N,
00071    const std::complex<double>* const ALPHA,
00072    const std::complex<double> A[],
00073    const int* const LDA,
00074    const std::complex<double> X[],
00075    const int* const INCX,
00076    const std::complex<double>* const BETA,
00077    std::complex<double> Y[],
00078    const int* const INCY);
00079 
00080 extern "C" void F77_BLAS_MANGLE(cgemv, CGEMV)
00081   (const char* const TRANS,
00082    const int* const M,
00083    const int* const N,
00084    const std::complex<float>* const ALPHA,
00085    const std::complex<float> A[],
00086    const int* const LDA,
00087    const std::complex<float> X[],
00088    const int* const INCX,
00089    const std::complex<float>* const BETA,
00090    std::complex<float> Y[],
00091    const int* const INCY);
00092 
00093 extern "C" void F77_BLAS_MANGLE(dgemm, DGEMM)
00094   (const char* const TRANSA,
00095    const char* const TRANSB,
00096    const int* const M,
00097    const int* const N,
00098    const int* const K,
00099    const double* const ALPHA,
00100    const double A[],
00101    const int* const LDA,
00102    const double B[],
00103    const int* const LDB,
00104    const double* const BETA,
00105    double C[],
00106    const int* const LDC);
00107 
00108 extern "C" void F77_BLAS_MANGLE(sgemm, SGEMM)
00109   (const char* const TRANSA,
00110    const char* const TRANSB,
00111    const int* const M,
00112    const int* const N,
00113    const int* const K,
00114    const float* const ALPHA,
00115    const float A[],
00116    const int* const LDA,
00117    const float B[],
00118    const int* const LDB,
00119    const float* const BETA,
00120    float C[],
00121    const int* const LDC);
00122 
00123 extern "C" void F77_BLAS_MANGLE(zgemm, ZGEMM)
00124   (const char* const TRANSA,
00125    const char* const TRANSB,
00126    const int* const M,
00127    const int* const N,
00128    const int* const K,
00129    const std::complex<double>* const ALPHA,
00130    const std::complex<double> A[],
00131    const int* const LDA,
00132    const std::complex<double> B[],
00133    const int* const LDB,
00134    const std::complex<double>* const BETA,
00135    std::complex<double> C[],
00136    const int* const LDC);
00137 
00138 extern "C" void F77_BLAS_MANGLE(cgemm, CGEMM)
00139   (const char* const TRANSA,
00140    const char* const TRANSB,
00141    const int* const M,
00142    const int* const N,
00143    const int* const K,
00144    const std::complex<float>* const ALPHA,
00145    const std::complex<float> A[],
00146    const int* const LDA,
00147    const std::complex<float> B[],
00148    const int* const LDB,
00149    const std::complex<float>* const BETA,
00150    std::complex<float> C[],
00151    const int* const LDC);
00152 
00153 extern "C" void F77_BLAS_MANGLE(dger, DGER)
00154   (const int* const M,
00155    const int* const N,
00156    const double* const ALPHA,
00157    const double X[],
00158    const int* const INCX,
00159    const double Y[],
00160    const int* const INCY,
00161    double A[],
00162    const int* const LDA);
00163 
00164 extern "C" void F77_BLAS_MANGLE(sger, SGER)
00165   (const int* const M,
00166    const int* const N,
00167    const float* const ALPHA,
00168    const float X[],
00169    const int* const INCX,
00170    const float Y[],
00171    const int* const INCY,
00172    float A[],
00173    const int* const LDA);
00174 
00175 extern "C" void F77_BLAS_MANGLE(zgerc, ZGERC)
00176   (const int* const M,
00177    const int* const N,
00178    const std::complex<double>* const ALPHA,
00179    const std::complex<double> X[],
00180    const int* const INCX,
00181    const std::complex<double> Y[],
00182    const int* const INCY,
00183    std::complex<double> A[],
00184    const int* const LDA);
00185 
00186 extern "C" void F77_BLAS_MANGLE(cgerc, CGERC)
00187   (const int* const M,
00188    const int* const N,
00189    const std::complex<float>* const ALPHA,
00190    const std::complex<float> X[],
00191    const int* const INCX,
00192    const std::complex<float> Y[],
00193    const int* const INCY,
00194    std::complex<float> A[],
00195    const int* const LDA);
00196 
00197 extern "C" void F77_BLAS_MANGLE(dtrsm, DTRSM)
00198   (const char* const SIDE,
00199    const char* const UPLO,
00200    const char* const TRANSA,
00201    const char* const DIAG,
00202    const int* const M,
00203    const int* const N,
00204    const double* const ALPHA,
00205    const double A[],
00206    const int* const LDA,
00207    double B[],
00208    const int* const LDB);
00209 
00210 extern "C" void F77_BLAS_MANGLE(strsm, STRSM)
00211   (const char* const SIDE,
00212    const char* const UPLO,
00213    const char* const TRANSA,
00214    const char* const DIAG,
00215    const int* const M,
00216    const int* const N,
00217    const float* const ALPHA,
00218    const float A[],
00219    const int* const LDA,
00220    float B[],
00221    const int* const LDB);
00222 
00223 extern "C" void F77_BLAS_MANGLE(ztrsm, ZTRSM)
00224   (const char* const SIDE,
00225    const char* const UPLO,
00226    const char* const TRANSA,
00227    const char* const DIAG,
00228    const int* const M,
00229    const int* const N,
00230    const std::complex<double>* const ALPHA,
00231    const std::complex<double> A[],
00232    const int* const LDA,
00233    std::complex<double> B[],
00234    const int* const LDB);
00235 
00236 extern "C" void F77_BLAS_MANGLE(ctrsm, CTRSM)
00237   (const char* const SIDE,
00238    const char* const UPLO,
00239    const char* const TRANSA,
00240    const char* const DIAG,
00241    const int* const M,
00242    const int* const N,
00243    const std::complex<float>* const ALPHA,
00244    const std::complex<float> A[],
00245    const int* const LDA,
00246    std::complex<float> B[],
00247    const int* const LDB);
00248 
00249 namespace TSQR {
00250 
00251   template<>
00252   void
00253   BLAS<int, double>::
00254   GEMV (const char* const trans, 
00255   const int m, 
00256   const int n,
00257   const double alpha,
00258   const double A[],
00259   const int lda,
00260   const double x[],
00261   const int incx,
00262   const double beta,
00263   double y[],
00264   const int incy)
00265   {
00266     F77_BLAS_MANGLE(dgemv, DGEMV) 
00267       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00268   }
00269 
00270   template<>
00271   void
00272   BLAS<int, float>::
00273   GEMV (const char* const trans, 
00274   const int m, 
00275   const int n,
00276   const float alpha,
00277   const float A[],
00278   const int lda,
00279   const float x[],
00280   const int incx,
00281   const float beta,
00282   float y[],
00283   const int incy)
00284   {
00285     F77_BLAS_MANGLE(sgemv, SGEMV) 
00286       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00287   }
00288 
00289   template<>
00290   void
00291   BLAS<int, std::complex<double> >::
00292   GEMV (const char* const trans, 
00293   const int m, 
00294   const int n,
00295   const std::complex<double> alpha,
00296   const std::complex<double> A[],
00297   const int lda,
00298   const std::complex<double> x[],
00299   const int incx,
00300   const std::complex<double> beta,
00301   std::complex<double> y[],
00302   const int incy)
00303   {
00304     F77_BLAS_MANGLE(zgemv, ZGEMV) 
00305       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00306   }
00307 
00308   template<>
00309   void
00310   BLAS<int, std::complex<float> >::
00311   GEMV (const char* const trans, 
00312   const int m, 
00313   const int n,
00314   const std::complex<float> alpha,
00315   const std::complex<float> A[],
00316   const int lda,
00317   const std::complex<float> x[],
00318   const int incx,
00319   const std::complex<float> beta,
00320   std::complex<float> y[],
00321   const int incy)
00322   {
00323     F77_BLAS_MANGLE(cgemv, CGEMV) 
00324       (trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy);
00325   }
00326 
00327   template<>
00328   void
00329   BLAS<int, double>::
00330   GEMM (const char* const transa,
00331   const char* const transb,
00332   const int m,
00333   const int n,
00334   const int k,
00335   const double alpha,
00336   const double A[],
00337   const int lda,
00338   const double B[],
00339   const int ldb,
00340   const double beta,
00341   double C[],
00342   const int ldc)
00343   {
00344     F77_BLAS_MANGLE(dgemm, DGEMM) 
00345       (transa, transb, &m, &n, &k, &alpha,
00346        A, &lda, B, &ldb, &beta, C, &ldc);
00347   }
00348 
00349   template<>
00350   void
00351   BLAS<int, float>::
00352   GEMM (const char* const transa,
00353   const char* const transb,
00354   const int m,
00355   const int n,
00356   const int k,
00357   const float alpha,
00358   const float A[],
00359   const int lda,
00360   const float B[],
00361   const int ldb,
00362   const float beta,
00363   float C[],
00364   const int ldc)
00365   {
00366     F77_BLAS_MANGLE(sgemm, SGEMM) 
00367       (transa, transb, &m, &n, &k, &alpha,
00368        A, &lda, B, &ldb, &beta, C, &ldc);
00369   }
00370 
00371   template<>
00372   void
00373   BLAS<int, std::complex<double> >::
00374   GEMM (const char* const transa,
00375   const char* const transb,
00376   const int m,
00377   const int n,
00378   const int k,
00379   const std::complex<double> alpha,
00380   const std::complex<double> A[],
00381   const int lda,
00382   const std::complex<double> B[],
00383   const int ldb,
00384   const std::complex<double> beta,
00385   std::complex<double> C[],
00386   const int ldc)
00387   {
00388     F77_BLAS_MANGLE(zgemm, ZGEMM) 
00389       (transa, transb, &m, &n, &k, &alpha,
00390        A, &lda, B, &ldb, &beta, C, &ldc);
00391   }
00392 
00393   template<>
00394   void
00395   BLAS<int, std::complex<float> >::
00396   GEMM (const char* const transa,
00397   const char* const transb,
00398   const int m,
00399   const int n,
00400   const int k,
00401   const std::complex<float> alpha,
00402   const std::complex<float> A[],
00403   const int lda,
00404   const std::complex<float> B[],
00405   const int ldb,
00406   const std::complex<float> beta,
00407   std::complex<float> C[],
00408   const int ldc)
00409   {
00410     F77_BLAS_MANGLE(cgemm, CGEMM) 
00411       (transa, transb, &m, &n, &k, &alpha, 
00412        A, &lda, B, &ldb, &beta, C, &ldc);
00413   }
00414 
00415   template<>
00416   void
00417   BLAS<int, double>::
00418   GER (const int m,
00419        const int n,
00420        const double alpha,
00421        const double x[],
00422        const int incx,
00423        const double y[],
00424        const int incy,
00425        double A[],
00426        const int lda)
00427   {
00428     F77_BLAS_MANGLE(dger, DGER) 
00429       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00430   }
00431 
00432   template<>
00433   void
00434   BLAS<int, float>::
00435   GER (const int m,
00436        const int n,
00437        const float alpha,
00438        const float x[],
00439        const int incx,
00440        const float y[],
00441        const int incy,
00442        float A[],
00443        const int lda)
00444   {
00445     F77_BLAS_MANGLE(sger, SGER) 
00446       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00447   }
00448 
00449   template<>
00450   void
00451   BLAS<int, std::complex<double> >::
00452   GER (const int m,
00453        const int n,
00454        const std::complex<double> alpha,
00455        const std::complex<double> x[],
00456        const int incx,
00457        const std::complex<double> y[],
00458        const int incy,
00459        std::complex<double> A[],
00460        const int lda)
00461   {
00462     F77_BLAS_MANGLE(zgerc, ZGERC) 
00463       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00464   }
00465 
00466   template<>
00467   void
00468   BLAS<int, std::complex<float> >::
00469   GER (const int m,
00470        const int n,
00471        const std::complex<float> alpha,
00472        const std::complex<float> x[],
00473        const int incx,
00474        const std::complex<float> y[],
00475        const int incy,
00476        std::complex<float> A[],
00477        const int lda)
00478   {
00479     F77_BLAS_MANGLE(cgerc, CGERC) 
00480       (&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
00481   }
00482 
00483   template<>
00484   void
00485   BLAS<int, double >::
00486   TRSM (const char* const side,
00487   const char* const uplo,
00488   const char* const transa,
00489   const char* const diag,
00490   const int m,
00491   const int n,
00492   const double alpha,
00493   const double A[],
00494   const int lda,
00495   double B[],
00496   const int ldb)
00497   {
00498     F77_BLAS_MANGLE(dtrsm, DTRSM) 
00499       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00500   }
00501 
00502   template<>
00503   void
00504   BLAS<int, float >::
00505   TRSM (const char* const side,
00506   const char* const uplo,
00507   const char* const transa,
00508   const char* const diag,
00509   const int m,
00510   const int n,
00511   const float alpha,
00512   const float A[],
00513   const int lda,
00514   float B[],
00515   const int ldb)
00516   {
00517     F77_BLAS_MANGLE(strsm, STRSM) 
00518       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00519   }
00520 
00521   template<>
00522   void
00523   BLAS<int, std::complex<double> >::
00524   TRSM (const char* const side,
00525   const char* const uplo,
00526   const char* const transa,
00527   const char* const diag,
00528   const int m,
00529   const int n,
00530   const std::complex<double> alpha,
00531   const std::complex<double> A[],
00532   const int lda,
00533   std::complex<double> B[],
00534   const int ldb)
00535   {
00536     F77_BLAS_MANGLE(ztrsm, ZTRSM) 
00537       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00538   }
00539 
00540   template<>
00541   void
00542   BLAS<int, std::complex<float> >::
00543   TRSM (const char* const side,
00544   const char* const uplo,
00545   const char* const transa,
00546   const char* const diag,
00547   const int m,
00548   const int n,
00549   const std::complex<float> alpha,
00550   const std::complex<float> A[],
00551   const int lda,
00552   std::complex<float> B[],
00553   const int ldb)
00554   {
00555     F77_BLAS_MANGLE(ctrsm, CTRSM) 
00556       (side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
00557   }
00558 
00559 } // namespace TSQR
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends