Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FadLAPACKUnitTests.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Sacado Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
25 // (etphipp@sandia.gov).
26 //
27 // ***********************************************************************
28 // @HEADER
29 
30 #ifndef FADLAPACKUNITTESTS_HPP
31 #define FADLAPACKUNITTESTS_HPP
32 
33 // Sacado includes
34 #include "Sacado_No_Kokkos.hpp"
35 #include "Sacado_Fad_LAPACK.hpp"
36 #include "Sacado_Random.hpp"
37 
38 // gtest includes
39 #include <gtest/gtest.h>
40 
41 #include "GTestUtils.hpp"
42 
43 #define COMPARE_FAD_VECTORS(X1, X2, n) \
44  ASSERT_TRUE(X1.size() == std::size_t(n)); \
45  ASSERT_TRUE(X2.size() == std::size_t(n)); \
46  for (unsigned int i=0; i<n; i++) { \
47  COMPARE_FADS(X1[i], X2[i]); \
48  } \
49  ;
50 
51 // A class for testing differentiated LAPACK operations for general Fad types
52 template <class FadType>
54 protected:
57 
58  // Random number generator
60 
61  // Real random number generator for derivative components
63 
64  // Number of matrix rows
65  unsigned int m;
66 
67  // Number of matrix columns
68  unsigned int n;
69 
70  // Number of matrix columns for level 3 blas
71  unsigned int l;
72 
73  // Number of derivative components
74  unsigned int ndot;
75 
76  // Tolerances to which fad objects should be the same
77  double tol_a, tol_r;
78 
80 
82  urand(), real_urand(), m(5), n(6), l(4), ndot(7),
83  tol_a(1.0e-11), tol_r(1.0e-11) {}
84 
85 }; // class FadLAPACKUnitTests
86 
88 
89 // What is the purpose of this test? It doesn't test Fad at all.
91  const int n = 2;
92  const int nrhs = 1;
93  double A[] = { 1.1, 0.1, .01, 0.9 };
94  const int lda = 2;
95  int IPIV[] = {0, 0};
96  double B[] = { 0.1, 0.2 };
97  const int ldb = 2;
98  int info(0);
99 
100  const double refX[] = {0.088978766430738, 0.212335692618807};
101 
102  Teuchos::LAPACK<int,double> teuchos_lapack;
103  teuchos_lapack.GESV(n, nrhs, &A[0], lda, &IPIV[0], &B[0], ldb, &info);
104 
105  COMPARE_VALUES(B[0],refX[0]);
106  COMPARE_VALUES(B[1],refX[1]);
107 
108  //Teuchos::LAPACK<int,FadType> sacado_lapack(false);
109  //sacado_blas.SCAL(m, alpha, &x2[0], 1);
110  //COMPARE_VALUES(1,0);
111 }
112 
115  testGESV
116  );
117 
118 #endif // FADLAPACKUNITTESTS_HPP
REGISTER_TYPED_TEST_SUITE_P(FadBLASUnitTests, testSCAL1, testSCAL2, testSCAL3, testSCAL4, testCOPY1, testCOPY2, testCOPY3, testCOPY4, testAXPY1, testAXPY2, testAXPY3, testAXPY4, testDOT1, testDOT2, testDOT3, testDOT4, testNRM21, testNRM22, testGEMV1, testGEMV2, testGEMV3, testGEMV4, testGEMV5, testGEMV6, testGEMV7, testGEMV8, testGEMV9, testTRMV1, testTRMV2, testTRMV3, testTRMV4, testGER1, testGER2, testGER3, testGER4, testGER5, testGER6, testGER7, testGEMM1, testGEMM2, testGEMM3, testGEMM4, testGEMM5, testGEMM6, testGEMM7, testGEMM8, testGEMM9, testGEMM10, testSYMM1, testSYMM2, testSYMM3, testSYMM4, testSYMM5, testSYMM6, testSYMM7, testSYMM8, testSYMM9, testTRMM1, testTRMM2, testTRMM3, testTRMM4, testTRMM5, testTRMM6, testTRMM7, testTRSM1, testTRSM2, testTRSM3, testTRSM4, testTRSM5, testTRSM6, testTRSM7)
TYPED_TEST_P(FadBLASUnitTests, testSCAL1)
#define COMPARE_VALUES(a, b)
Definition: GTestUtils.hpp:109
A class for storing a contiguously allocated array of Fad objects. This is a general definition that ...
Sacado::Fad::Vector< unsigned int, FadType > VectorType
Sacado::ScalarType< FadType >::type ScalarType
Sacado::Random< double > real_urand
TYPED_TEST_SUITE_P(FadBLASUnitTests)
void GESV(const OrdinalType &n, const OrdinalType &nrhs, ScalarType *A, const OrdinalType &lda, OrdinalType *IPIV, ScalarType *B, const OrdinalType &ldb, OrdinalType *info) const
Sacado::Random< ScalarType > urand
A random number generator that generates random numbers uniformly distributed in the interval (a...
int n