Sacado Package Browser (Single Doxygen Collection) Version of the Day
Sacado_Fad_SimpleFad.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_SIMPLEFAD_HPP
00033 #define SACADO_FAD_SIMPLEFAD_HPP
00034 
00035 #include "Sacado_Fad_DynamicStorage.hpp"
00036 #include "Sacado_Fad_SimpleFadTraits.hpp"
00037 #include "Sacado_dummy_arg.hpp"
00038 
00039 namespace Sacado {
00040 
00041   namespace Fad {
00042 
00053     template <typename ValueT>
00054     class SimpleFad : public GeneralFad<ValueT,DynamicStorage<ValueT> >  {
00055 
00056     public:
00057 
00059       typedef typename ScalarType<ValueT>::type ScalarT;
00060 
00062       template <typename T> 
00063       struct apply {
00064   typedef SimpleFad<T> type;
00065       };
00066 
00071 
00073 
00076       SimpleFad() : 
00077   GeneralFad< ValueT,DynamicStorage<ValueT> >() {}
00078 
00080 
00083       SimpleFad(const ValueT& x) : 
00084   GeneralFad< ValueT,DynamicStorage<ValueT> >(x) {}
00085 
00087 
00091       SimpleFad(const typename dummy<ValueT,ScalarT>::type& x) : 
00092   GeneralFad< ValueT,DynamicStorage<ValueT> >(ValueT(x)) {}
00093 
00095 
00098       SimpleFad(const int sz, const ValueT& x) : 
00099   GeneralFad< ValueT,DynamicStorage<ValueT> >(sz,x) {}
00100 
00102 
00107       SimpleFad(const int sz, const int i, const ValueT & x) : 
00108   GeneralFad< ValueT,DynamicStorage<ValueT> >(sz,i,x) {}
00109 
00111       SimpleFad(const SimpleFad& x) : 
00112   GeneralFad< ValueT,DynamicStorage<ValueT> >(x) {}
00113 
00115       SimpleFad(const SimpleFad& x, const ValueT& v, const ValueT& partial) :
00116   GeneralFad< ValueT,DynamicStorage<ValueT> >(x.size(), v) {
00117   for (int i=0; i<this->size(); i++)
00118     this->fastAccessDx(i) = x.fastAccessDx(i)*partial;
00119       }
00120 
00122 
00124       ~SimpleFad() {}
00125 
00127       SimpleFad& operator=(const ValueT& v) {
00128   GeneralFad< ValueT,DynamicStorage<ValueT> >::operator=(v);
00129   return *this;
00130       }
00131 
00133 
00136       SimpleFad& operator=(const typename dummy<ValueT,ScalarT>::type& v) {
00137   GeneralFad< ValueT,DynamicStorage<ValueT> >::operator=(ValueT(v));
00138   return *this;
00139       }
00140 
00142       SimpleFad& operator=(const SimpleFad& x) {
00143   GeneralFad< ValueT,DynamicStorage<ValueT> >::operator=(static_cast<const GeneralFad< ValueT,DynamicStorage<ValueT> >&>(x));
00144   return *this;
00145       }
00146 
00148       SimpleFad& operator += (const SimpleFad& x);
00149 
00151       SimpleFad& operator -= (const SimpleFad& x);
00152   
00154       SimpleFad& operator *= (const SimpleFad& x);
00155 
00157       SimpleFad& operator /= (const SimpleFad& x);
00158   
00159     }; // class SimpleFad<ValueT>
00160 
00161   } // namespace Fad
00162 
00163 } // namespace Sacado
00164 
00165 // Include method definitions
00166 #include "Sacado_Fad_SimpleFadImp.hpp"
00167 
00168 // Include elementary operation overloads
00169 #include "Sacado_Fad_SimpleFadOps.hpp"
00170 
00171 #endif // SACADO_FAD_SIMPLEFAD_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines