Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Sacado_Fad_Vector.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_VECTOR_HPP
33#define SACADO_FAD_VECTOR_HPP
34
35#include <vector>
36#include "Sacado_Fad_DVFad.hpp"
37
38namespace Sacado {
39
40 namespace Fad {
41
44 Column
45 };
46
54 template <typename OrdinalType, typename FadType >
55 class Vector {
56 public:
57
60
62 Vector(OrdinalType vec_size, OrdinalType deriv_sz,
63 VectorDerivOrientation orient = Row) :
64 deriv_size_(deriv_sz), vec_(vec_size) {
65 for (OrdinalType i=0; i<vec_size; i++)
67 }
68
70 Vector(const Vector& fv) : deriv_size_(fv.deriv_size_), vec_(fv.vec_) {}
71
74
76 Vector& operator=(const Vector& fv) {
78 vec_ = fv.vec_;
79 return *this;
80 }
81
83 OrdinalType size() const { return vec_.size(); }
84
86 OrdinalType deriv_size() const { return deriv_size_; }
87
89 OrdinalType deriv_stride() const { return 1; }
90
93
95 FadType& operator[] (OrdinalType i) { return vec_[i]; }
96
98 const FadType& operator[](OrdinalType i) const { return vec_[i]; }
99
100 protected:
101
103 OrdinalType deriv_size_;
104
106 std::vector<FadType> vec_;
107
108 }; // class Vector
109
116 template <typename OrdinalType, typename ValueType>
117 class Vector< OrdinalType, Sacado::Fad::DVFad<ValueType> > {
118 public:
119
122
124 Vector(OrdinalType vec_size, OrdinalType deriv_size,
125 VectorDerivOrientation orient = Row);
126
128 Vector(const Vector& fv);
129
131 ~Vector();
132
134 Vector& operator=(const Vector& fv);
135
137 OrdinalType size() const { return vec_.size(); }
138
140 OrdinalType deriv_size() const { return deriv_size_; }
141
143 OrdinalType deriv_stride() const { return stride_; }
144
146 VectorDerivOrientation deriv_orientation() const { return orient_; }
147
149 FadType& operator[] (OrdinalType i) { return vec_[i]; }
150
152 const FadType& operator[](OrdinalType i) const { return vec_[i]; }
153
155 ValueType* vals();
156
158 const ValueType* vals() const;
159
161 ValueType* dx();
162
164 const ValueType* dx() const;
165
166 protected:
167
169 OrdinalType deriv_size_;
170
173
175 OrdinalType stride_;
176
178 std::vector<FadType> vec_;
179
180 }; // class Vector
181
182 } // namespace Fad
183
184} // namespace Sacado
185
187
188#endif // SACADO_FAD_VECTOR_HPP
expr expr dx(i)
Sacado::Fad::DFad< double > FadType
Forward-mode AD class using dynamic memory allocation and expression templates.
Sacado::Fad::DVFad< ValueType > FadType
Synonym for Fad type.
const FadType & operator[](OrdinalType i) const
Array access.
VectorDerivOrientation deriv_orientation() const
Derivative array orientation.
VectorDerivOrientation orient_
Derivative array orientation.
A class for storing a contiguously allocated array of Fad objects. This is a general definition that ...
VectorDerivOrientation deriv_orientation() const
Derivative array orientation.
OrdinalType deriv_stride() const
Derivative array stride.
const FadType & operator[](OrdinalType i) const
Array access.
std::vector< FadType > vec_
Vector of Fad's.
Vector(OrdinalType vec_size, OrdinalType deriv_sz, VectorDerivOrientation orient=Row)
Constructor.
FadType & operator[](OrdinalType i)
Array access.
Vector & operator=(const Vector &fv)
Assignment.
Sacado::ValueType< FadType >::type ValueType
Typename of values.
OrdinalType deriv_size_
Size of derivative array.
OrdinalType size() const
Vector size.
Vector(const Vector &fv)
Copy constructor.
OrdinalType deriv_size() const
Derivative size.
@ Column
Derivatives are stored row-wise (strided)
Base template specification for ValueType.