Sacado Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
test
GTestSuite
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>
53
class
FadLAPACKUnitTests
:
public
::testing::Test
{
54
protected
:
55
typedef
typename
Sacado::ScalarType<FadType>::type
ScalarType
;
56
typedef
Sacado::Fad::Vector<unsigned int,FadType>
VectorType
;
57
58
// Random number generator
59
Sacado::Random<ScalarType>
urand
;
60
61
// Real random number generator for derivative components
62
Sacado::Random<double>
real_urand
;
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
79
FadType
fad
;
80
81
FadLAPACKUnitTests
() :
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
87
TYPED_TEST_SUITE_P
(
FadLAPACKUnitTests
);
88
89
// What is the purpose of this test? It doesn't test Fad at all.
90
TYPED_TEST_P
(
FadLAPACKUnitTests
, testGESV) {
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
113
REGISTER_TYPED_TEST_SUITE_P
(
114
FadLAPACKUnitTests
,
115
testGESV
116
);
117
118
#endif
// FADLAPACKUNITTESTS_HPP
TYPED_TEST_SUITE_P
TYPED_TEST_SUITE_P(FadLAPACKUnitTests)
REGISTER_TYPED_TEST_SUITE_P
REGISTER_TYPED_TEST_SUITE_P(FadLAPACKUnitTests, testGESV)
TYPED_TEST_P
TYPED_TEST_P(FadLAPACKUnitTests, testGESV)
Definition
FadLAPACKUnitTests.hpp:90
GTestUtils.hpp
COMPARE_VALUES
#define COMPARE_VALUES(a, b)
Definition
GTestUtils.hpp:109
Sacado_Fad_LAPACK.hpp
Sacado_No_Kokkos.hpp
Sacado_Random.hpp
A
#define A
Definition
Sacado_rad.hpp:572
FadType
Sacado::Fad::DFad< double > FadType
Definition
blas_example.cpp:49
FadLAPACKUnitTests
Definition
FadLAPACKUnitTests.hpp:53
FadLAPACKUnitTests::ndot
unsigned int ndot
Definition
FadLAPACKUnitTests.hpp:74
FadLAPACKUnitTests::urand
Sacado::Random< ScalarType > urand
Definition
FadLAPACKUnitTests.hpp:59
FadLAPACKUnitTests::VectorType
Sacado::Fad::Vector< unsigned int, FadType > VectorType
Definition
FadLAPACKUnitTests.hpp:56
FadLAPACKUnitTests::real_urand
Sacado::Random< double > real_urand
Definition
FadLAPACKUnitTests.hpp:62
FadLAPACKUnitTests::tol_a
double tol_a
Definition
FadLAPACKUnitTests.hpp:77
FadLAPACKUnitTests::FadLAPACKUnitTests
FadLAPACKUnitTests()
Definition
FadLAPACKUnitTests.hpp:81
FadLAPACKUnitTests::n
unsigned int n
Definition
FadLAPACKUnitTests.hpp:68
FadLAPACKUnitTests::tol_r
double tol_r
Definition
FadLAPACKUnitTests.hpp:77
FadLAPACKUnitTests::m
unsigned int m
Definition
FadLAPACKUnitTests.hpp:65
FadLAPACKUnitTests::fad
FadType fad
Definition
FadLAPACKUnitTests.hpp:79
FadLAPACKUnitTests::ScalarType
Sacado::ScalarType< FadType >::type ScalarType
Definition
FadLAPACKUnitTests.hpp:55
FadLAPACKUnitTests::l
unsigned int l
Definition
FadLAPACKUnitTests.hpp:71
Sacado::Fad::Vector
A class for storing a contiguously allocated array of Fad objects. This is a general definition that ...
Definition
Sacado_Fad_Vector.hpp:55
Sacado::Random
A random number generator that generates random numbers uniformly distributed in the interval (a,...
Definition
Sacado_Random.hpp:46
testing::Test
Definition
gtest.h:414
gtest.h
B
Definition
ConversionTests.cpp:44
Sacado::ScalarType::type
T type
Definition
Sacado_Traits.hpp:304
Generated by
1.17.0