Sacado Package Browser (Single Doxygen Collection) Version of the Day
Sacado_Fad_LAPACK.hpp
Go to the documentation of this file.
00001 // $Id$
00002 // $Source$
00003 // @HEADER
00004 // ***********************************************************************
00005 //
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 //
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 //
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 //
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 #ifndef SACADO_FAD_LAPACK_HPP
00033 #define SACADO_FAD_LAPACK_HPP
00034 
00035 #include "Teuchos_LAPACK.hpp"
00036 #include "Sacado.hpp"
00037 #include "Sacado_CacheFad_DFad.hpp"
00038 #include "Sacado_dummy_arg.hpp"
00039 
00040 namespace Sacado {
00041 
00042   namespace Fad {
00043 
00044     template <typename OrdinalType, typename FadType>
00045     class ArrayTraits {
00046 
00047       typedef typename Sacado::ValueType<FadType>::type ValueType;
00048       typedef typename Sacado::ScalarType<FadType>::type scalar_type;
00049       typedef typename Sacado::dummy<ValueType,scalar_type>::type ScalarType;
00050 
00051     public:
00052 
00053       ArrayTraits(bool use_dynamic = true,
00054                   OrdinalType workspace_size = 0);
00055 
00056       ArrayTraits(const ArrayTraits& a);
00057 
00058       ~ArrayTraits();
00059 
00060       void unpack() const;
00061 
00062       void pack() const;
00063 
00064       void free() const;
00065 
00066       ValueType* allocate_array(OrdinalType size) const;
00067 
00068       void free_array(const ValueType* ptr, OrdinalType size) const;
00069 
00070       bool is_array_contiguous(const FadType* a, OrdinalType n,
00071                                OrdinalType n_dot) const;
00072 
00073     protected:
00074 
00076       bool use_dynamic;
00077 
00079       OrdinalType workspace_size;
00080 
00082       mutable ValueType *workspace;
00083 
00085       mutable ValueType *workspace_pointer;
00086 
00087     };
00088 
00089     template <typename T> struct ArrayValueType { typedef T type; };
00090 
00092     template <typename OrdinalType, typename FadType>
00093     class Fad_LAPACK {
00094 
00095       typedef typename Teuchos::ScalarTraits<FadType>::magnitudeType MagnitudeType;
00096       typedef typename Sacado::ValueType<FadType>::type ValueType;
00097       typedef typename Sacado::ScalarType<FadType>::type scalar_type;
00098       typedef typename Sacado::dummy<ValueType,scalar_type>::type ScalarType;
00099       typedef Teuchos::LAPACK<OrdinalType,FadType> LAPACKType;
00100 
00101     public:
00103 
00104 
00106       Fad_LAPACK(bool use_default_impl = true,
00107                  bool use_dynamic = true, 
00108                  OrdinalType static_workspace_size = 0);
00109 
00111 
00112       Fad_LAPACK(const Fad_LAPACK& x);
00113 
00115       virtual ~Fad_LAPACK();
00116 
00118 
00120       void GESV(const OrdinalType n, const OrdinalType nrhs, FadType* A, const OrdinalType lda,
00121                 OrdinalType* IPIV, FadType* B, const OrdinalType ldb, OrdinalType* info) const; 
00122 
00123     protected:
00124 
00126       ArrayTraits<OrdinalType,FadType> arrayTraits;
00127 
00129       Teuchos::LAPACK<OrdinalType, ValueType> lapack;
00130 
00132       bool use_default_impl;
00133 
00134     protected:
00135 
00137       void Fad_GESV() const;
00138 
00139     }; // class FadLAPACK
00140 
00141   } // namespace Fad
00142 
00143 } // namespace Sacado
00144 
00145 namespace Teuchos {
00146   // Specialization of Teuchos::LAPACK for Sacado::Fad::DFad
00147   template <typename OrdinalType, typename ScalarType>
00148   class LAPACK< OrdinalType, Sacado::Fad::DFad<ScalarType> > :
00149     public Sacado::Fad::Fad_LAPACK< OrdinalType, Sacado::Fad::DFad<ScalarType> > {};
00150 }
00151 
00152 #include "Sacado_Fad_LAPACKImp.hpp"
00153 
00154 #endif // SACADO_FAD_LAPACK_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines