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  typedef Kokkos::ArithTraits<val_type> KAT;
26  typedef typename KAT::mag_type magnitudeType;
27  static inline val_type reciprocal(val_type c){ return 1.0/c; }
28  static inline val_type divide(val_type a, val_type b){ return a/b; }
29  static inline magnitudeType approxABS(val_type a) { return KAT::abs(a); }
30  static inline magnitudeType abs(val_type a) { return KAT::abs(a); }
31  static inline bool gt (val_type a, val_type b){ return (a>b); }
32 };
33 
34 namespace Amesos2 {
35 
36  // Enable MP::Vector as a valid Scalar type for Basker
37  template <class ST>
38  struct TypeMap< Basker,Sacado::MP::Vector<ST> > {
39  typedef Sacado::MP::Vector<ST> dtype;
40  typedef Sacado::MP::Vector<ST> type;
41  typedef typename Kokkos::ArithTraits< Sacado::MP::Vector<ST> >::mag_type magnitude_type;
42  };
43 
44  // Specialize our specialization for create_solver_with_supported_type
45  // to pass the scalar type directly to Basker
46  template < class ST, class LO, class GO, class NO >
47  struct create_mp_vector_solver_impl < Basker, ST, LO, GO, NO > {
48  typedef Sacado::MP::Vector<ST> SC;
49  typedef Tpetra::CrsMatrix<SC,LO,GO,NO> Matrix;
50  typedef Tpetra::MultiVector<SC,LO,GO,NO> Vector;
55  {
56  ctassert<
57  std::is_same_v<
58  typename MatrixTraits<Matrix>::scalar_t,
59  typename MultiVecAdapter<Vector>::scalar_t
60  >
61  > same_scalar_assertion;
62  (void)same_scalar_assertion; // This stops the compiler from warning about unused declared variables
63 
64  // If our assertion did not fail, then create and return a new solver
65  typedef Tpetra::CrsMatrix<Sacado::MP::Vector<ST>,LO,GO,NO> Matrix;
66  typedef Tpetra::MultiVector<Sacado::MP::Vector<ST>,LO,GO,NO> Vector;
67  return Teuchos::rcp( new Basker<Matrix,Vector>(A, X, B) );
68  }
69  };
70 }
71 #endif // HAVE_AMESOS2_BASKER
72 
73 #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