Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
test
UnitTest
Stokhos_SacadoTraitsUnitTest.cpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Stokhos Package
5
// Copyright (2009) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#include <type_traits>
43
44
#include "Teuchos_UnitTestHarness.hpp"
45
#include "Teuchos_TestingHelpers.hpp"
46
#include "Teuchos_UnitTestRepository.hpp"
47
#include "Teuchos_GlobalMPISession.hpp"
48
49
#include "
Stokhos_UnitTestHelpers.hpp
"
50
51
#include "
Stokhos_Sacado.hpp
"
52
#include "
Stokhos_Sacado_Kokkos.hpp
"
53
54
#include <Kokkos_Core.hpp>
55
56
#if defined( KOKKOS_ENABLE_OPENMP )
57
typedef
Kokkos::OpenMP
node_type
;
58
#elif defined( KOKKOS_ENABLE_THREADS )
59
typedef
Kokkos::Threads
node_type
;
60
#else
61
typedef
Kokkos::Serial
node_type
;
62
#endif
63
64
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL
( Traits, ScalarType, ad_type, scalar_type )
65
{
66
const
bool
is_same =
67
std::is_same< typename Sacado::ScalarType<ad_type>::type, scalar_type >::value;
68
69
TEUCHOS_TEST_EQUALITY(is_same,
true
, out, success);
70
}
71
72
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL
( Traits, ValueType, ad_type, value_type )
73
{
74
const
bool
is_same =
75
std::is_same< typename Sacado::ValueType<ad_type>::type, value_type >::value;
76
TEUCHOS_TEST_EQUALITY(is_same,
true
, out, success);
77
}
78
79
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL
( Traits, IsADType, ad_type )
80
{
81
const
bool
is_ad = Sacado::IsADType<ad_type>::value;
82
TEUCHOS_TEST_EQUALITY(is_ad,
true
, out, success);
83
}
84
85
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL
( Traits, IsScalarType, ad_type )
86
{
87
const
bool
is_scalar = Sacado::IsScalarType<ad_type>::value;
88
TEUCHOS_TEST_EQUALITY(is_scalar,
false
, out, success);
89
}
90
91
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL
( Traits, Value, ad_type, value_type )
92
{
93
value_type v(1.0);
94
ad_type a(v);
95
TEUCHOS_TEST_EQUALITY(Sacado::Value<ad_type>::eval(a), v, out, success);
96
}
97
98
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL
( Traits, ScalarValue, ad_type, scalar_type )
99
{
100
scalar_type v(1.0);
101
ad_type a(v);
102
TEUCHOS_TEST_EQUALITY(Sacado::ScalarValue<ad_type>::eval(a), v, out, success);
103
}
104
105
#ifdef HAVE_STOKHOS_PCE_SCALAR_TYPE
106
//
107
// Sacado::ETPCE::OrthogPoly
108
//
109
typedef
Stokhos::StandardStorage<int,double>
storage_type
;
110
typedef
Sacado::ETPCE::OrthogPoly<double,storage_type>
pce_type
;
111
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, ScalarType,
pce_type
,
double
)
112
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, ValueType,
pce_type
,
double
)
113
TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Traits, IsADType,
pce_type
)
114
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, Value,
pce_type
,
double
)
115
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, ScalarValue,
pce_type
,
double
)
116
117
typedef
Sacado::ETPCE::Expr< Sacado::ETPCE::OrthogPolyImpl<double,storage_type>
> pce_expr_type;
118
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, ScalarType, pce_expr_type,
double
)
119
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, ValueType, pce_expr_type,
double
)
120
TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Traits, IsADType, pce_expr_type )
121
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, Value, pce_expr_type,
double
)
122
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, ScalarValue, pce_expr_type,
double
)
123
#endif
124
125
#ifdef HAVE_STOKHOS_ENSEMBLE_SCALAR_TYPE
126
//
127
// Sacado::MP::Vector
128
//
129
typedef
Stokhos::DynamicStorage<int,double,node_type>
kokkos_storage_type;
130
typedef
Sacado::MP::Vector<kokkos_storage_type>
mp_type;
131
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, ScalarType, mp_type,
double
)
132
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, ValueType, mp_type,
double
)
133
TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Traits, IsADType, mp_type )
134
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, Value, mp_type,
double
)
135
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
( Traits, ScalarValue, mp_type,
double
)
136
#endif
137
138
// Can't test Expr because there is no way to actually create one
139
140
int
main
(
int
argc,
char
*
argv
[] ) {
141
Teuchos::GlobalMPISession mpiSession(&argc, &
argv
);
142
return
Teuchos::UnitTestRepository::runUnitTestsFromMain(argc,
argv
);
143
}
argv
char * argv[]
Definition
Stokhos_HouseTriDiagUnitTest.cpp:286
storage_type
Stokhos::StandardStorage< int, double > storage_type
Definition
Stokhos_SacadoETPCEUnitTest.cpp:50
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(Traits, ScalarType, ad_type, scalar_type)
Definition
Stokhos_SacadoTraitsUnitTest.cpp:64
main
int main(int argc, char *argv[])
Definition
Stokhos_SacadoTraitsUnitTest.cpp:140
node_type
Kokkos::Serial node_type
Definition
Stokhos_SacadoTraitsUnitTest.cpp:61
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Traits, IsADType, ad_type)
Definition
Stokhos_SacadoTraitsUnitTest.cpp:79
Stokhos_Sacado.hpp
Stokhos_Sacado_Kokkos.hpp
Stokhos_UnitTestHelpers.hpp
Sacado::ETPCE::Expr
Definition
Sacado_ETPCE_ExpressionTraits.hpp:50
Sacado::ETPCE::OrthogPoly
Definition
Sacado_ETPCE_OrthogPolyTraits.hpp:50
Sacado::MP::Vector
Definition
Belos_SolverManager_MP_Vector.hpp:48
Stokhos::DynamicStorage
Definition
Stokhos_DynamicStorage.hpp:56
Stokhos::StandardStorage
Definition
Stokhos_StandardStorage.hpp:53
pce_type
Sacado::ETPCE::OrthogPoly< double, Stokhos::StandardStorage< int, double > > pce_type
Definition
gram_schmidt_example3.cpp:95
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(Tpetra_CrsMatrix, MatVec, double, Node) TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(Tpetra_CrsMatrix
Generated by
1.17.0