Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_Fad_LAPACK.hpp
Go to the documentation of this file.
1 // $Id$
2 // $Source$
3 // @HEADER
4 // ***********************************************************************
5 //
6 // Sacado Package
7 // Copyright (2006) Sandia Corporation
8 //
9 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
10 // the U.S. Government retains certain rights in this software.
11 //
12 // This library is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU Lesser General Public License as
14 // published by the Free Software Foundation; either version 2.1 of the
15 // License, or (at your option) any later version.
16 //
17 // This library is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
25 // USA
26 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
27 // (etphipp@sandia.gov).
28 //
29 // ***********************************************************************
30 // @HEADER
31 
32 #ifndef SACADO_FAD_LAPACK_HPP
33 #define SACADO_FAD_LAPACK_HPP
34 
35 #include "Teuchos_LAPACK.hpp"
36 #include "Sacado_No_Kokkos.hpp"
37 #include "Sacado_CacheFad_DFad.hpp"
38 #include "Sacado_dummy_arg.hpp"
39 
40 namespace Sacado {
41 
42  namespace Fad {
43 
44  template <typename OrdinalType, typename FadType>
45  class ArrayTraits {
46 
50 
51  public:
52 
53  ArrayTraits(bool use_dynamic = true,
54  OrdinalType workspace_size = 0);
55 
56  ArrayTraits(const ArrayTraits& a);
57 
58  ~ArrayTraits();
59 
60  void unpack() const;
61 
62  void pack() const;
63 
64  void free() const;
65 
66  ValueType* allocate_array(OrdinalType size) const;
67 
68  void free_array(const ValueType* ptr, OrdinalType size) const;
69 
70  bool is_array_contiguous(const FadType* a, OrdinalType n,
71  OrdinalType n_dot) const;
72 
73  protected:
74 
76  bool use_dynamic;
77 
79  OrdinalType workspace_size;
80 
82  mutable ValueType *workspace;
83 
86 
87  };
88 
89  template <typename T> struct ArrayValueType { typedef T type; };
90 
92  template <typename OrdinalType, typename FadType>
93  class Fad_LAPACK {
94 
100 
101  public:
103 
104 
106  Fad_LAPACK(bool use_default_impl = true,
107  bool use_dynamic = true,
108  OrdinalType static_workspace_size = 0);
109 
111 
112  Fad_LAPACK(const Fad_LAPACK& x);
113 
115  virtual ~Fad_LAPACK();
116 
118 
120  void GESV(const OrdinalType n, const OrdinalType nrhs, FadType* A, const OrdinalType lda,
121  OrdinalType* IPIV, FadType* B, const OrdinalType ldb, OrdinalType* info) const;
122 
123  protected:
124 
127 
130 
133 
134  protected:
135 
137  void Fad_GESV() const;
138 
139  }; // class FadLAPACK
140 
141  } // namespace Fad
142 
143 } // namespace Sacado
144 
145 namespace Teuchos {
146  // Specialization of Teuchos::LAPACK for Sacado::Fad::DFad
147  template <typename OrdinalType, typename ScalarType>
148  class LAPACK< OrdinalType, Sacado::Fad::DFad<ScalarType> > :
149  public Sacado::Fad::Fad_LAPACK< OrdinalType, Sacado::Fad::DFad<ScalarType> > {};
150 }
151 
152 #include "Sacado_Fad_LAPACKImp.hpp"
153 
154 #endif // SACADO_FAD_LAPACK_HPP
bool is_array_contiguous(const FadType *a, OrdinalType n, OrdinalType n_dot) const
Teuchos::ScalarTraits< FadType >::magnitudeType MagnitudeType
bool use_dynamic
Use dynamic memory allocation.
ValueType * allocate_array(OrdinalType size) const
virtual ~Fad_LAPACK()
Destructor.
Sacado::dummy< ValueType, scalar_type >::type ScalarType
Sacado::ValueType< FadType >::type ValueType
void GESV(const OrdinalType n, const OrdinalType nrhs, FadType *A, const OrdinalType lda, OrdinalType *IPIV, FadType *B, const OrdinalType ldb, OrdinalType *info) const
Computes the solution to a real system of linear equations.
ValueType * workspace_pointer
Pointer to current free entry in workspace.
#define T
Definition: Sacado_rad.hpp:573
Fad specializations for Teuchos::LAPACK wrappers.
OrdinalType workspace_size
Size of static workspace.
GeneralFad< DynamicStorage< T > > DFad
Sacado::dummy< ValueType, scalar_type >::type ScalarType
ArrayTraits(bool use_dynamic=true, OrdinalType workspace_size=0)
Teuchos::LAPACK< OrdinalType, FadType > LAPACKType
Fad_LAPACK(bool use_default_impl=true, bool use_dynamic=true, OrdinalType static_workspace_size=0)
Default constructor.
void Fad_GESV() const
Implementation of GESV.
void free_array(const ValueType *ptr, OrdinalType size) const
ValueType * workspace
Workspace for holding contiguous values/derivatives.
Sacado::ScalarType< FadType >::type scalar_type
Sacado::ScalarType< FadType >::type scalar_type
Sacado::ValueType< FadType >::type ValueType
bool use_default_impl
Use custom or default implementation.
ArrayTraits< OrdinalType, FadType > arrayTraits
ArrayTraits for packing/unpacking value/derivative arrays.
Teuchos::LAPACK< OrdinalType, ValueType > lapack
LAPACK for values.