|
Sacado Package Browser (Single Doxygen Collection) Version of the Day
|
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_VECTOR_HPP 00033 #define SACADO_FAD_VECTOR_HPP 00034 00035 #include <vector> 00036 #include "Sacado_Fad_DVFad.hpp" 00037 00038 namespace Sacado { 00039 00040 namespace Fad { 00041 00042 enum VectorDerivOrientation { 00043 Row, 00044 Column 00045 }; 00046 00054 template <typename OrdinalType, typename FadType > 00055 class Vector { 00056 public: 00057 00059 typedef typename Sacado::ValueType<FadType>::type ValueType; 00060 00062 Vector(OrdinalType vec_size, OrdinalType deriv_sz, 00063 VectorDerivOrientation orient = Row) : 00064 deriv_size_(deriv_sz), vec_(vec_size) { 00065 for (OrdinalType i=0; i<vec_size; i++) 00066 vec_[i] = FadType(deriv_size_, ValueType(0.0)); 00067 } 00068 00070 Vector(const Vector& fv) : deriv_size_(fv.deriv_size_), vec_(fv.vec_) {} 00071 00073 ~Vector() {} 00074 00076 Vector& operator=(const Vector& fv) { 00077 deriv_size_ = fv.deriv_size_; 00078 vec_ = fv.vec_; 00079 return *this; 00080 } 00081 00083 OrdinalType size() const { return vec_.size(); } 00084 00086 OrdinalType deriv_size() const { return deriv_size_; } 00087 00089 OrdinalType deriv_stride() const { return 1; } 00090 00092 VectorDerivOrientation deriv_orientation() const { return Column; } 00093 00095 FadType& operator[] (OrdinalType i) { return vec_[i]; } 00096 00098 const FadType& operator[](OrdinalType i) const { return vec_[i]; } 00099 00100 protected: 00101 00103 OrdinalType deriv_size_; 00104 00106 std::vector<FadType> vec_; 00107 00108 }; // class Vector 00109 00116 template <typename OrdinalType, typename ValueType> 00117 class Vector< OrdinalType, Sacado::Fad::DVFad<ValueType> > { 00118 public: 00119 00121 typedef Sacado::Fad::DVFad<ValueType> FadType; 00122 00124 Vector(OrdinalType vec_size, OrdinalType deriv_size, 00125 VectorDerivOrientation orient = Row); 00126 00128 Vector(const Vector& fv); 00129 00131 ~Vector(); 00132 00134 Vector& operator=(const Vector& fv); 00135 00137 OrdinalType size() const { return vec_.size(); } 00138 00140 OrdinalType deriv_size() const { return deriv_size_; } 00141 00143 OrdinalType deriv_stride() const { return stride_; } 00144 00146 VectorDerivOrientation deriv_orientation() const { return orient_; } 00147 00149 FadType& operator[] (OrdinalType i) { return vec_[i]; } 00150 00152 const FadType& operator[](OrdinalType i) const { return vec_[i]; } 00153 00155 ValueType* vals(); 00156 00158 const ValueType* vals() const; 00159 00161 ValueType* dx(); 00162 00164 const ValueType* dx() const; 00165 00166 protected: 00167 00169 OrdinalType deriv_size_; 00170 00172 VectorDerivOrientation orient_; 00173 00175 OrdinalType stride_; 00176 00178 std::vector<FadType> vec_; 00179 00180 }; // class Vector 00181 00182 } // namespace Fad 00183 00184 } // namespace Sacado 00185 00186 #include "Sacado_Fad_VectorImp.hpp" 00187 00188 #endif // SACADO_FAD_VECTOR_HPP
1.7.4