Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_SacadoTraitsUnitTest.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include <type_traits>
11 
16 
18 
19 #include "Stokhos_Sacado.hpp"
21 
22 #include <Kokkos_Core.hpp>
23 
24 #if defined( KOKKOS_ENABLE_OPENMP )
25 typedef Kokkos::OpenMP node_type;
26 #elif defined( KOKKOS_ENABLE_THREADS )
27 typedef Kokkos::Threads node_type;
28 #else
29 typedef Kokkos::Serial node_type;
30 #endif
31 
32 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Traits, ScalarType, ad_type, scalar_type )
33 {
34  const bool is_same =
35  std::is_same< typename Sacado::ScalarType<ad_type>::type, scalar_type >::value;
36 
37  TEUCHOS_TEST_EQUALITY(is_same, true, out, success);
38 }
39 
40 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Traits, ValueType, ad_type, value_type )
41 {
42  const bool is_same =
43  std::is_same< typename Sacado::ValueType<ad_type>::type, value_type >::value;
44  TEUCHOS_TEST_EQUALITY(is_same, true, out, success);
45 }
46 
47 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Traits, IsADType, ad_type )
48 {
49  const bool is_ad = Sacado::IsADType<ad_type>::value;
50  TEUCHOS_TEST_EQUALITY(is_ad, true, out, success);
51 }
52 
53 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Traits, IsScalarType, ad_type )
54 {
55  const bool is_scalar = Sacado::IsScalarType<ad_type>::value;
56  TEUCHOS_TEST_EQUALITY(is_scalar, false, out, success);
57 }
58 
60 {
61  value_type v(1.0);
62  ad_type a(v);
63  TEUCHOS_TEST_EQUALITY(Sacado::Value<ad_type>::eval(a), v, out, success);
64 }
65 
66 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( Traits, ScalarValue, ad_type, scalar_type )
67 {
68  scalar_type v(1.0);
69  ad_type a(v);
70  TEUCHOS_TEST_EQUALITY(Sacado::ScalarValue<ad_type>::eval(a), v, out, success);
71 }
72 
73 #ifdef HAVE_STOKHOS_PCE_SCALAR_TYPE
74 //
75 // Sacado::ETPCE::OrthogPoly
76 //
79 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, ScalarType, pce_type, double )
80 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, ValueType, pce_type, double )
81 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Traits, IsADType, pce_type )
82 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, Value, pce_type, double )
83 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, ScalarValue, pce_type, double )
84 
85 typedef Sacado::ETPCE::Expr< Sacado::ETPCE::OrthogPolyImpl<double,storage_type> > pce_expr_type;
86 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, ScalarType, pce_expr_type, double )
87 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, ValueType, pce_expr_type, double )
88 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Traits, IsADType, pce_expr_type )
89 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, Value, pce_expr_type, double )
90 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, ScalarValue, pce_expr_type, double )
91 #endif
92 
93 #ifdef HAVE_STOKHOS_ENSEMBLE_SCALAR_TYPE
94 //
95 // Sacado::MP::Vector
96 //
97 typedef Stokhos::DynamicStorage<int,double,node_type> kokkos_storage_type;
99 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, ScalarType, mp_type, double )
100 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, ValueType, mp_type, double )
101 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Traits, IsADType, mp_type )
102 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, Value, mp_type, double )
103 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Traits, ScalarValue, mp_type, double )
104 #endif
105 
106 // Can't test Expr because there is no way to actually create one
107 
108 int main( int argc, char* argv[] ) {
109  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
111 }
Stokhos::StandardStorage< int, double > storage_type
Sacado::ETPCE::OrthogPoly< double, Stokhos::StandardStorage< int, double > > pce_type
Kokkos::Serial node_type
static int runUnitTestsFromMain(int argc, char *argv[])
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(Kokkos_SG_SpMv, CrsProductTensorCijk, Scalar, Device)
int main(int argc, char **argv)
TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(Tpetra_CrsMatrix, MatVec, double, Node) TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(Tpetra_CrsMatrix
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Kokkos_CrsMatrix_MP, ReplaceValues, MatrixScalar)
SparseArrayIterator< index_iterator, value_iterator >::value_reference value(const SparseArrayIterator< index_iterator, value_iterator > &it)