|
Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
|
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 // 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 <iostream> 00043 #include "Teuchos_LAPACK.hpp" 00044 #include "Teuchos_Version.hpp" 00045 00046 int main(int argc, char* argv[]) 00047 { 00048 int numberFailedTests = 0; 00049 bool verbose = 0; 00050 if (argc>1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true; 00051 00052 if (verbose) 00053 std::cout << Teuchos::Teuchos_Version() << std::endl << std::endl; 00054 00055 Teuchos::LAPACK<int,double> L; 00056 Teuchos::LAPACK<int,float> M; 00057 00058 double Ad[16]; 00059 //double xd[4]; 00060 double bd[4]; 00061 float Af[16]; 00062 //float xf[4]; 00063 float bf[4]; 00064 00065 int IPIV[4]; 00066 int info; 00067 00068 int i; 00069 for(i = 0; i < 16; i++) 00070 { 00071 Ad[i] = 0; 00072 Af[i] = 0; 00073 } 00074 for(i = 0; i < 4; i++) 00075 { 00076 //xd[i] = 0; 00077 bd[i] = 0; 00078 //xf[i] = 0; 00079 bf[i] = 0; 00080 } 00081 00082 Ad[0] = 1; Ad[2] = 1; Ad[5] = 1; Ad[8] = 2; Ad[9] = 1; Ad[10] = 1; Ad[14] = 2; Ad[15] = 2; 00083 //xd[0] = -2; xd[1] = 1; xd[2] = 1; xd[3] = 1; 00084 bd[1] = 2; bd[2] = 1; bd[3] = 2; 00085 Af[0] = 1; Af[2] = 1; Af[5] = 1; Af[8] = 2; Af[9] = 1; Af[10] = 1; Af[14] = 2; Af[15] = 2; 00086 //xf[0] = -2; xf[1] = 1; xf[2] = 1; xf[3] = 1; 00087 bf[1] = 2; bf[2] = 1; bf[3] = 2; 00088 00089 if (verbose) std::cout << "GESV test ... "; 00090 L.GESV(4, 1, Ad, 4, IPIV, bd, 4, &info); 00091 M.GESV(4, 1, Af, 4, IPIV, bf, 4, &info); 00092 for(i = 0; i < 4; i++) 00093 { 00094 if (bd[i] == bf[i]) { 00095 if (verbose && i==3) std::cout << "passed!" << std::endl; 00096 } else { 00097 if (verbose) std::cout << "FAILED" << std::endl; 00098 numberFailedTests++; 00099 break; 00100 } 00101 } 00102 00103 if (verbose) std::cout << "LAPY2 test ... "; 00104 float fx = 3, fy = 4; 00105 float flapy = M.LAPY2(fx, fy); 00106 double dx = 3, dy = 4; 00107 double dlapy = L.LAPY2(dx, dy); 00108 if ( dlapy == flapy && dlapy == 5.0 && flapy == 5.0f ) { 00109 if (verbose) std::cout << "passed!" << std::endl; 00110 } else { 00111 if (verbose) std::cout << "FAILED (" << dlapy << " != " << flapy << ")" << std::endl; 00112 numberFailedTests++; 00113 } 00114 00115 #if ! (defined(__INTEL_COMPILER) && defined(_WIN32) ) 00116 00117 // Check ILAENV with similarity transformation routine: dsytrd 00118 // NOTE: Do not need to put floating point specifier [s,d,c,z] before routine name, 00119 // this is handled through templating. 00120 if (verbose) std::cout << "ILAENV test ... "; 00121 int n1 = 100; 00122 int size = L.ILAENV(1, "sytrd", "u", n1); 00123 if (size > 0) { 00124 if (verbose) std::cout << "passed!" << std::endl; 00125 } else { 00126 if (verbose) std::cout << "FAILED!" << std::endl; 00127 numberFailedTests++; 00128 } 00129 00130 #endif 00131 00132 if(numberFailedTests > 0) 00133 { 00134 if (verbose) { 00135 std::cout << "Number of failed tests: " << numberFailedTests << std::endl; 00136 std::cout << "End Result: TEST FAILED" << std::endl; 00137 return -1; 00138 } 00139 } 00140 if(numberFailedTests==0) 00141 std::cout << "End Result: TEST PASSED" << std::endl; 00142 return 0; 00143 00144 }
1.7.6.1