test/LAPACK/cxx_main.cpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) 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 <iostream>
00030 #include "Teuchos_LAPACK.hpp"
00031 #include "Teuchos_Version.hpp"
00032 
00033 int main(int argc, char* argv[])
00034 {
00035   int numberFailedTests = 0;
00036   bool verbose = 0;
00037   if (argc>1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true;
00038 
00039   if (verbose)
00040     std::cout << Teuchos::Teuchos_Version() << std::endl << std::endl;
00041 
00042   Teuchos::LAPACK<int,double> L;
00043   Teuchos::LAPACK<int,float> M;
00044 
00045   double Ad[16];
00046   double xd[4];
00047   double bd[4];
00048   float Af[16];
00049   float xf[4];
00050   float bf[4];
00051 
00052   int IPIV[4];
00053   int info;
00054 
00055   int i;
00056   for(i = 0; i < 16; i++)
00057     {
00058       Ad[i] = 0;
00059       Af[i] = 0;
00060     }
00061   for(i = 0; i < 4; i++)
00062     {
00063       xd[i] = 0;
00064       bd[i] = 0;
00065       xf[i] = 0;
00066       bf[i] = 0;
00067     }
00068 
00069   Ad[0] = 1; Ad[2] = 1; Ad[5] = 1; Ad[8] = 2; Ad[9] = 1; Ad[10] = 1; Ad[14] = 2; Ad[15] = 2;
00070   xd[0] = -2; xd[1] = 1; xd[2] = 1; xd[3] = 1;
00071   bd[1] = 2; bd[2] = 1; bd[3] = 2;
00072   Af[0] = 1; Af[2] = 1; Af[5] = 1; Af[8] = 2; Af[9] = 1; Af[10] = 1; Af[14] = 2; Af[15] = 2;
00073   xf[0] = -2; xf[1] = 1; xf[2] = 1; xf[3] = 1;
00074   bf[1] = 2; bf[2] = 1; bf[3] = 2;
00075 
00076   if (verbose) std::cout << "GESV test ... ";
00077   L.GESV(4, 1, Ad, 4, IPIV, bd, 4, &info);
00078   M.GESV(4, 1, Af, 4, IPIV, bf, 4, &info);
00079   for(i = 0; i < 4; i++)
00080     {
00081       if (bd[i] == bf[i]) {
00082         if (verbose && i==3) std::cout << "passed!" << std::endl;
00083       } else {
00084         if (verbose) std::cout << "FAILED" << std::endl;
00085         numberFailedTests++;  
00086   break;
00087       }
00088     }
00089 
00090   if (verbose) std::cout << "LAPY2 test ... ";
00091   float fx = 3, fy = 4;
00092   float flapy = M.LAPY2(fx, fy);
00093   double dx = 3, dy = 4;
00094   double dlapy = L.LAPY2(dx, dy);
00095   if ( dlapy == flapy ) {
00096     if (verbose) std::cout << "passed!" << std::endl;
00097   } else {
00098     if (verbose) std::cout << "FAILED" << std::endl;
00099     numberFailedTests++;
00100   }  
00101 
00102 #if ! (defined(__INTEL_COMPILER) && defined(_WIN32) )
00103     
00104   // Check ILAENV with similarity transformation routine:  dsytrd
00105   // NOTE:  Do not need to put floating point specifier [s,d,c,z] before routine name, 
00106   //        this is handled through templating.
00107   if (verbose) std::cout << "ILAENV test ... ";
00108   int n1 = 100;
00109   int size = L.ILAENV(1, "sytrd", "u", n1);
00110   if (size > 0) {
00111     if (verbose) std::cout << "passed!" << std::endl;
00112   } else {
00113     if (verbose) std::cout << "FAILED!" << std::endl;
00114     numberFailedTests++;
00115   }
00116 
00117 #endif
00118 
00119   if(numberFailedTests > 0)
00120     {
00121       if (verbose) {
00122         std::cout << "Number of failed tests: " << numberFailedTests << std::endl;
00123         std::cout << "End Result: TEST FAILED" << std::endl;
00124         return -1;
00125       }
00126     }
00127   if(numberFailedTests==0)
00128     std::cout << "End Result: TEST PASSED" << std::endl;
00129   return 0;
00130 
00131 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 09:57:28 2011 for Teuchos Package Browser (Single Doxygen Collection) by  doxygen 1.6.3