Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Sacado_Fad_Exp_ViewFad.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 SACADO_FAD_EXP_VIEWFAD_HPP
31#define SACADO_FAD_EXP_VIEWFAD_HPP
32
35
36#if defined(HAVE_SACADO_KOKKOSCORE)
37#include "Kokkos_Atomic.hpp"
38#include "impl/Kokkos_Error.hpp"
39#endif
40
41namespace Sacado {
42
43 namespace Fad {
44 namespace Exp {
45
46 template <typename T, unsigned static_length, unsigned static_stride, typename U>
48
49 // Class representing a pointer to ViewFad so that &ViewFad is supported
50 template <typename T, unsigned sl, unsigned ss, typename U>
51 class ViewFadPtr : public ViewFad<T,sl,ss,U> {
52 public:
53
54 // Storage type base class
56
57 // Bring in constructors
58 using view_fad_type::view_fad_type;
59
60 // Add overload of dereference operator
62 view_fad_type* operator->() { return this; }
63
64 // Add overload of dereference operator
66 view_fad_type& operator*() { return *this; }
67 };
68
69 } // namespace Exp
70 } // namespace Fad
71
72 template <typename,unsigned,unsigned> struct ViewFadType;
73
75 template< class S, unsigned length, unsigned stride >
76 struct ViewFadType< Fad::Exp::GeneralFad<S>, length, stride > {
78 };
79
81
84 template< class S, unsigned length, unsigned stride >
85 struct ViewFadType< const Fad::Exp::GeneralFad<S>, length, stride > {
87 };
88
89 // Specialization of BaseExprType for ViewFad, to use the base fad type
90 template <typename T, unsigned static_length, unsigned static_stride, typename U>
91 struct BaseExprType< Fad::Exp::GeneralFad< Fad::Exp::ViewStorage<T,static_length,static_stride,U> > > {
92 typedef U type;
93 };
94
96
100 template <typename ValueT, unsigned Size, unsigned Stride, typename Base>
101 struct ScalarType< Fad::Exp::ViewFad<ValueT,Size,Stride,Base> > {
103 };
104
109 template <typename ValueT, unsigned Size, unsigned Stride, typename Base>
110 struct ValueType< Fad::Exp::ViewFad<ValueT,Size,Stride,Base> > {
111 typedef ValueT type;
112 };
113
114} // namespace Sacado
115
116#endif // SACADO_FAD_EXP_VIEWFAD_HPP
#define SACADO_INLINE_FUNCTION
Forward-mode AD class templated on the storage for the derivative array.
ViewFad< T, sl, ss, U > view_fad_type
SACADO_INLINE_FUNCTION view_fad_type * operator->()
SACADO_INLINE_FUNCTION view_fad_type & operator*()
Get the base Fad type from a view/expression.
Base template specification for ScalarType.
Base template specification for ValueType.
Fad::Exp::ViewFad< typename S::value_type, length, stride, Fad::Exp::GeneralFad< S > > type
Fad::Exp::ViewFad< const typename S::value_type, length, stride, Fad::Exp::GeneralFad< S > > type
Get view type for any Fad type.