Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Amesos2_Basker_MP_Vector.hpp
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 #ifndef AMESOS2_BASKER_MP_VECTOR_HPP
11 #define AMESOS2_BASKER_MP_VECTOR_HPP
12 
13 #include "Amesos2_config.h"
14 #ifdef HAVE_AMESOS2_BASKER
15 
16 #include "Amesos2_Basker.hpp"
19 
20 // Specialization of BASKER_ScalarTraits for MP::Vector
21 template <class T> struct BASKER_ScalarTraits;
22 template <class S>
23 struct BASKER_ScalarTraits< Sacado::MP::Vector<S> > {
24  typedef Sacado::MP::Vector<S> val_type;
25 #if KOKKOS_VERSION >= 40799
26  typedef KokkosKernels::ArithTraits<val_type> KAT;
27 #else
28  typedef Kokkos::ArithTraits<val_type> KAT;
29 #endif
30  typedef typename KAT::mag_type magnitudeType;
31  static inline val_type reciprocal(val_type c){ return 1.0/c; }
32  static inline val_type divide(val_type a, val_type b){ return a/b; }
33  static inline magnitudeType approxABS(val_type a) { return KAT::abs(a); }
34  static inline magnitudeType abs(val_type a) { return KAT::abs(a); }
35  static inline bool gt (val_type a, val_type b){ return (a>b); }
36 };
37 
38 namespace Amesos2 {
39 
40  // Enable MP::Vector as a valid Scalar type for Basker
41  template <class ST>
42  struct TypeMap< Basker,Sacado::MP::Vector<ST> > {
43  typedef Sacado::MP::Vector<ST> dtype;
44  typedef Sacado::MP::Vector<ST> type;
45 #if KOKKOS_VERSION >= 40799
46  typedef typename KokkosKernels::ArithTraits< Sacado::MP::Vector<ST> >::mag_type magnitude_type;
47 #else
48  typedef typename Kokkos::ArithTraits< Sacado::MP::Vector<ST> >::mag_type magnitude_type;
49 #endif
50  };
51 
52  // Specialize our specialization for create_solver_with_supported_type
53  // to pass the scalar type directly to Basker
54  template < class ST, class LO, class GO, class NO >
55  struct create_mp_vector_solver_impl < Basker, ST, LO, GO, NO > {
56  typedef Sacado::MP::Vector<ST> SC;
57  typedef Tpetra::CrsMatrix<SC,LO,GO,NO> Matrix;
58  typedef Tpetra::MultiVector<SC,LO,GO,NO> Vector;
63  {
64  ctassert<
65  std::is_same_v<
66  typename MatrixTraits<Matrix>::scalar_t,
67  typename MultiVecAdapter<Vector>::scalar_t
68  >
69  > same_scalar_assertion;
70  (void)same_scalar_assertion; // This stops the compiler from warning about unused declared variables
71 
72  // If our assertion did not fail, then create and return a new solver
73  typedef Tpetra::CrsMatrix<Sacado::MP::Vector<ST>,LO,GO,NO> Matrix;
74  typedef Tpetra::MultiVector<Sacado::MP::Vector<ST>,LO,GO,NO> Vector;
75  return Teuchos::rcp( new Basker<Matrix,Vector>(A, X, B) );
76  }
77  };
78 }
79 #endif // HAVE_AMESOS2_BASKER
80 
81 #endif // AMESOS2_BASKER_MP_VECTOR_HPP
static Teuchos::RCP< Solver< Matrix, Vector > > apply(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
Tpetra::MultiVector< SC, LO, GO, NO > Vector
Tpetra::CrsMatrix< SC, LO, GO, NO > Matrix