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 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef FADLAPACKUNITTESTS_HPP
11 #define FADLAPACKUNITTESTS_HPP
12 
13 // Sacado includes
14 #include "Sacado_No_Kokkos.hpp"
15 #include "Sacado_Fad_LAPACK.hpp"
16 #include "Sacado_Random.hpp"
17 
18 // gtest includes
19 #include <gtest/gtest.h>
20 
21 #include "GTestUtils.hpp"
22 
23 #define COMPARE_FAD_VECTORS(X1, X2, n) \
24  ASSERT_TRUE(X1.size() == std::size_t(n)); \
25  ASSERT_TRUE(X2.size() == std::size_t(n)); \
26  for (unsigned int i=0; i<n; i++) { \
27  COMPARE_FADS(X1[i], X2[i]); \
28  } \
29  ;
30 
31 // A class for testing differentiated LAPACK operations for general Fad types
32 template <class FadType>
34 protected:
37 
38  // Random number generator
40 
41  // Real random number generator for derivative components
43 
44  // Number of matrix rows
45  unsigned int m;
46 
47  // Number of matrix columns
48  unsigned int n;
49 
50  // Number of matrix columns for level 3 blas
51  unsigned int l;
52 
53  // Number of derivative components
54  unsigned int ndot;
55 
56  // Tolerances to which fad objects should be the same
57  double tol_a, tol_r;
58 
60 
62  urand(), real_urand(), m(5), n(6), l(4), ndot(7),
63  tol_a(1.0e-11), tol_r(1.0e-11) {}
64 
65 }; // class FadLAPACKUnitTests
66 
68 
69 // What is the purpose of this test? It doesn't test Fad at all.
71  const int n = 2;
72  const int nrhs = 1;
73  double A[] = { 1.1, 0.1, .01, 0.9 };
74  const int lda = 2;
75  int IPIV[] = {0, 0};
76  double B[] = { 0.1, 0.2 };
77  const int ldb = 2;
78  int info(0);
79 
80  const double refX[] = {0.088978766430738, 0.212335692618807};
81 
82  Teuchos::LAPACK<int,double> teuchos_lapack;
83  teuchos_lapack.GESV(n, nrhs, &A[0], lda, &IPIV[0], &B[0], ldb, &info);
84 
85  COMPARE_VALUES(B[0],refX[0]);
86  COMPARE_VALUES(B[1],refX[1]);
87 
88  //Teuchos::LAPACK<int,FadType> sacado_lapack(false);
89  //sacado_blas.SCAL(m, alpha, &x2[0], 1);
90  //COMPARE_VALUES(1,0);
91 }
92 
95  testGESV
96  );
97 
98 #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:89
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