Sacado Package Browser (Single Doxygen Collection)  Version of the Day
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
#define COMPARE_VALUES(a, b)
Definition: GTestUtils.hpp:109
TYPED_TEST_SUITE_P(FadLAPACKUnitTests)
TYPED_TEST_P(FadLAPACKUnitTests, testGESV)
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
#define A
Definition: Sacado_rad.hpp:572
Sacado::Random< double > real_urand
REGISTER_TYPED_TEST_SUITE_P(FadLAPACKUnitTests, testGESV)
Sacado::Random< ScalarType > urand
A random number generator that generates random numbers uniformly distributed in the interval (a...